@skmtc/core 0.51.0 → 0.53.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/esm/anchors/CaptureSink.d.ts +3 -2
- package/esm/anchors/CaptureSink.js +3 -2
- package/esm/context/CoreContext.d.ts +4 -3
- package/esm/context/CoreContext.js +10 -8
- package/esm/context/GenerateContext.d.ts +8 -1
- package/esm/context/GenerateContext.js +8 -0
- package/esm/context/RenderContext.js +2 -3
- package/esm/context/generateTypes.d.ts +12 -7
- package/esm/dsl/DeclaredProjection.d.ts +48 -0
- package/esm/dsl/DeclaredProjection.js +1 -0
- package/esm/dsl/SnippetBase.d.ts +5 -2
- package/esm/dsl/SnippetBase.js +18 -12
- package/esm/dsl/model/toModelEntry.d.ts +10 -1
- package/esm/dsl/model/toModelEntry.js +2 -1
- package/esm/dsl/operation/gql/toGqlOperationEntry.d.ts +10 -1
- package/esm/dsl/operation/gql/toGqlOperationEntry.js +2 -1
- package/esm/dsl/operation/oas/toOasOperationEntry.d.ts +10 -1
- package/esm/dsl/operation/oas/toOasOperationEntry.js +2 -1
- package/esm/dsl/webhook/toWebhookEntry.d.ts +10 -1
- package/esm/dsl/webhook/toWebhookEntry.js +2 -1
- package/esm/mod.d.ts +1 -0
- package/esm/types/AttributionState.d.ts +10 -9
- package/esm/types/AttributionState.js +10 -9
- package/package.json +1 -1
- package/script/anchors/CaptureSink.d.ts +3 -2
- package/script/anchors/CaptureSink.js +3 -2
- package/script/context/CoreContext.d.ts +4 -3
- package/script/context/CoreContext.js +10 -8
- package/script/context/GenerateContext.d.ts +8 -1
- package/script/context/GenerateContext.js +8 -0
- package/script/context/RenderContext.js +2 -3
- package/script/context/generateTypes.d.ts +12 -7
- package/script/dsl/DeclaredProjection.d.ts +48 -0
- package/script/dsl/DeclaredProjection.js +2 -0
- package/script/dsl/SnippetBase.d.ts +5 -2
- package/script/dsl/SnippetBase.js +18 -12
- package/script/dsl/model/toModelEntry.d.ts +10 -1
- package/script/dsl/model/toModelEntry.js +2 -1
- package/script/dsl/operation/gql/toGqlOperationEntry.d.ts +10 -1
- package/script/dsl/operation/gql/toGqlOperationEntry.js +2 -1
- package/script/dsl/operation/oas/toOasOperationEntry.d.ts +10 -1
- package/script/dsl/operation/oas/toOasOperationEntry.js +2 -1
- package/script/dsl/webhook/toWebhookEntry.d.ts +10 -1
- package/script/dsl/webhook/toWebhookEntry.js +2 -1
- package/script/mod.d.ts +1 -0
- package/script/types/AttributionState.d.ts +10 -9
- package/script/types/AttributionState.js +10 -9
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* The capture mechanism for gen-maps. A {@link CaptureSink} is owned by
|
|
5
5
|
* {@link import('@/context/RenderContext.ts').RenderContext} for the
|
|
6
6
|
* duration of the single render pass and published to snippets through the
|
|
7
|
-
* shared {@link CaptureChannel}:
|
|
8
|
-
* its `toString` at construction
|
|
7
|
+
* shared {@link CaptureChannel}: in a run that has a channel, every
|
|
8
|
+
* `SnippetBase` instance self-wraps its `toString` at construction
|
|
9
|
+
* (own-property wrapper), and the wrapper
|
|
9
10
|
* observes into the channel's sink while the **capture interval** is open
|
|
10
11
|
* — the span while `channel.sink` is set. Each `toString` invocation is
|
|
11
12
|
* observed into an **occurrence tree** — one node per call, keyed by
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* The capture mechanism for gen-maps. A {@link CaptureSink} is owned by
|
|
5
5
|
* {@link import('@/context/RenderContext.ts').RenderContext} for the
|
|
6
6
|
* duration of the single render pass and published to snippets through the
|
|
7
|
-
* shared {@link CaptureChannel}:
|
|
8
|
-
* its `toString` at construction
|
|
7
|
+
* shared {@link CaptureChannel}: in a run that has a channel, every
|
|
8
|
+
* `SnippetBase` instance self-wraps its `toString` at construction
|
|
9
|
+
* (own-property wrapper), and the wrapper
|
|
9
10
|
* observes into the channel's sink while the **capture interval** is open
|
|
10
11
|
* — the span while `channel.sink` is set. Each `toString` invocation is
|
|
11
12
|
* observed into an **occurrence tree** — one node per call, keyed by
|
|
@@ -96,9 +96,10 @@ export type ToArtifactsArgs = {
|
|
|
96
96
|
/** Whether to suppress console output */
|
|
97
97
|
silent: boolean;
|
|
98
98
|
/**
|
|
99
|
-
* Optional attribution (gen-maps) **emission** config.
|
|
100
|
-
* always on; when `postPass` is set, the
|
|
101
|
-
*
|
|
99
|
+
* Optional attribution (gen-maps) **emission** config. Location
|
|
100
|
+
* capture is always on; when `postPass` is set, the run's snippets wrap
|
|
101
|
+
* their `toString` and the pipeline emits sidecars + a generation map
|
|
102
|
+
* alongside the usual artifacts. See
|
|
102
103
|
* {@link AttributionState}.
|
|
103
104
|
*/
|
|
104
105
|
attribution?: AttributionState;
|
|
@@ -314,8 +314,12 @@ export class CoreContext {
|
|
|
314
314
|
// The shared attribution capture channel: snippets constructed
|
|
315
315
|
// during generate hold the GenerateContext, whose `captureSink`
|
|
316
316
|
// reads this slot; RenderContext flips it around the one capturing
|
|
317
|
-
// render. One object per run wires the two phases together.
|
|
318
|
-
|
|
317
|
+
// render. One object per run wires the two phases together. A run
|
|
318
|
+
// with no `attribution.postPass` has no capturing render, so it has
|
|
319
|
+
// no channel, and its snippets install no `toString` wrapper.
|
|
320
|
+
const captureChannel = attribution?.postPass
|
|
321
|
+
? { sink: undefined }
|
|
322
|
+
: undefined;
|
|
319
323
|
const { files, previews, inspection, enrichmentWarnings } = stackTrail.trace('generate', st => {
|
|
320
324
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'generate', "f");
|
|
321
325
|
const generatePhase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
@@ -416,13 +420,12 @@ export class CoreContext {
|
|
|
416
420
|
__classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_logParseLine).call(this, parsedDocument, phase.context.issues, runStartedAt);
|
|
417
421
|
const subjects = stackTrail.trace('generate', () => {
|
|
418
422
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'generate', "f");
|
|
419
|
-
// Capability probing never renders, so
|
|
420
|
-
// opens — a throwaway channel satisfies the wiring.
|
|
423
|
+
// Capability probing never renders, so it has no capture channel.
|
|
421
424
|
const generatePhase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
422
425
|
toGeneratorConfigMap,
|
|
423
426
|
document: parsedDocument,
|
|
424
427
|
settings,
|
|
425
|
-
captureChannel:
|
|
428
|
+
captureChannel: undefined
|
|
426
429
|
});
|
|
427
430
|
__classPrivateFieldSet(this, _CoreContext_phase, generatePhase, "f");
|
|
428
431
|
return generatePhase.context.toSupportedSubjects();
|
|
@@ -466,13 +469,12 @@ export class CoreContext {
|
|
|
466
469
|
__classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_logParseLine).call(this, parsedDocument, phase.context.issues, runStartedAt);
|
|
467
470
|
const enrichmentDefaults = stackTrail.trace('generate', () => {
|
|
468
471
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'generate', "f");
|
|
469
|
-
// Seeding never renders, so
|
|
470
|
-
// throwaway channel satisfies the wiring.
|
|
472
|
+
// Seeding never renders, so it has no capture channel.
|
|
471
473
|
const generatePhase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
472
474
|
toGeneratorConfigMap,
|
|
473
475
|
document: parsedDocument,
|
|
474
476
|
settings,
|
|
475
|
-
captureChannel:
|
|
477
|
+
captureChannel: undefined
|
|
476
478
|
});
|
|
477
479
|
__classPrivateFieldSet(this, _CoreContext_phase, generatePhase, "f");
|
|
478
480
|
return generatePhase.context.toEnrichmentDefaults();
|
|
@@ -47,7 +47,8 @@ type ConstructorArgs = {
|
|
|
47
47
|
* Shared attribution capture channel — the slot `RenderContext` flips to
|
|
48
48
|
* open/close the capture interval. Snippets read it through this
|
|
49
49
|
* context's {@link GenerateContext.captureSink}. Optional: when omitted
|
|
50
|
-
* (tests, capture-less runs) `captureSink` is always `undefined
|
|
50
|
+
* (tests, capture-less runs) `captureSink` is always `undefined` and
|
|
51
|
+
* `capturesRender` is false, so no snippet installs a `toString` wrapper.
|
|
51
52
|
*/
|
|
52
53
|
captureChannel?: CaptureChannel;
|
|
53
54
|
/**
|
|
@@ -178,6 +179,12 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
178
179
|
* shared channel's `sink`.
|
|
179
180
|
*/
|
|
180
181
|
get captureSink(): CaptureSink | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Whether this run has a capturing render: it was given a capture
|
|
184
|
+
* channel. A `SnippetBase` instance installs its `toString` wrapper only
|
|
185
|
+
* then.
|
|
186
|
+
*/
|
|
187
|
+
get capturesRender(): boolean;
|
|
181
188
|
/**
|
|
182
189
|
* The trail of the subject whose variant is being generated, or
|
|
183
190
|
* `undefined` outside one. Log lines and the results the logger
|
|
@@ -218,6 +218,14 @@ export class GenerateContext {
|
|
|
218
218
|
get captureSink() {
|
|
219
219
|
return __classPrivateFieldGet(this, _GenerateContext_captureChannel, "f")?.sink;
|
|
220
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Whether this run has a capturing render: it was given a capture
|
|
223
|
+
* channel. A `SnippetBase` instance installs its `toString` wrapper only
|
|
224
|
+
* then.
|
|
225
|
+
*/
|
|
226
|
+
get capturesRender() {
|
|
227
|
+
return __classPrivateFieldGet(this, _GenerateContext_captureChannel, "f") !== undefined;
|
|
228
|
+
}
|
|
221
229
|
/**
|
|
222
230
|
* The trail of the subject whose variant is being generated, or
|
|
223
231
|
* `undefined` outside one. Log lines and the results the logger
|
|
@@ -123,9 +123,8 @@ export class RenderContext {
|
|
|
123
123
|
*/
|
|
124
124
|
render(stackTrail) {
|
|
125
125
|
const postPassConfig = this.attribution?.postPass;
|
|
126
|
-
// No emission configured → plain render, no capture: the
|
|
127
|
-
//
|
|
128
|
-
// the pass-through path.
|
|
126
|
+
// No emission configured → plain render, no capture: the run has no
|
|
127
|
+
// capture channel, so its snippets have no `toString` wrapper.
|
|
129
128
|
if (!postPassConfig) {
|
|
130
129
|
const result = this.collate(stackTrail);
|
|
131
130
|
return {
|
|
@@ -450,11 +450,8 @@ export type GenerateContextType = {
|
|
|
450
450
|
pendingStack: PendingDefinition[];
|
|
451
451
|
document: SkmtcParsedDocument;
|
|
452
452
|
/**
|
|
453
|
-
* Attribution (gen-maps) state.
|
|
454
|
-
*
|
|
455
|
-
* module-level render stack, so the post-render span resolver can
|
|
456
|
-
* attribute byte ranges to producers. When omitted, the wrap is
|
|
457
|
-
* skipped entirely — zero cost.
|
|
453
|
+
* Attribution (gen-maps) state. It does not decide whether a
|
|
454
|
+
* `SnippetBase` wraps its `toString`: {@link capturesRender} does.
|
|
458
455
|
*/
|
|
459
456
|
attribution?: AttributionState;
|
|
460
457
|
/**
|
|
@@ -462,10 +459,18 @@ export type GenerateContextType = {
|
|
|
462
459
|
* capture interval. Read by every `SnippetBase` instance's `toString`
|
|
463
460
|
* wrapper; `RenderContext` opens/closes the interval through the shared
|
|
464
461
|
* {@link import('@/anchors/CaptureSink.ts').CaptureChannel} that
|
|
465
|
-
* `CoreContext` wires into both contexts.
|
|
466
|
-
* `
|
|
462
|
+
* `CoreContext` wires into both contexts. In a run with no capturing
|
|
463
|
+
* render (`capturesRender` false, as in a bare test mock) no snippet
|
|
464
|
+
* has a wrapper, so nothing reads it.
|
|
467
465
|
*/
|
|
468
466
|
captureSink: CaptureSink | undefined;
|
|
467
|
+
/**
|
|
468
|
+
* Whether the run has a capturing render (attribution emission is
|
|
469
|
+
* configured). Read once by every `SnippetBase` instance, at
|
|
470
|
+
* construction: it installs its `toString` wrapper only when this is
|
|
471
|
+
* true.
|
|
472
|
+
*/
|
|
473
|
+
capturesRender: boolean;
|
|
469
474
|
toArtifacts: (stackTrail: StackTrail) => GenerateResult;
|
|
470
475
|
registerJson: ({ destinationPath, json }: RegisterJsonArgs) => void;
|
|
471
476
|
registerMarkdown: ({ destinationPath, markdown }: RegisterMarkdownArgs) => void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ToModelEnrichmentsArgs, ToModelExportPathArgs } from './model/types.js';
|
|
2
|
+
import type { ToOasOperationEnrichmentsArgs, ToOasOperationExportPathArgs } from './operation/oas/types.js';
|
|
3
|
+
import type { ToGqlOperationEnrichmentsArgs, ToGqlOperationExportPathArgs } from './operation/gql/types.js';
|
|
4
|
+
import type { ToWebhookEnrichmentsArgs, ToWebhookExportPathArgs } from './webhook/types.js';
|
|
5
|
+
/**
|
|
6
|
+
* A model projection class as a generator's entry declares it: the statics
|
|
7
|
+
* core can read before it constructs anything.
|
|
8
|
+
*
|
|
9
|
+
* The statics are methods, not function properties. TypeScript compares a
|
|
10
|
+
* method's parameters both ways, so projection classes with different
|
|
11
|
+
* enrichment and option types fit in one list.
|
|
12
|
+
*/
|
|
13
|
+
export type DeclaredModelProjection = {
|
|
14
|
+
id: string;
|
|
15
|
+
type: 'model';
|
|
16
|
+
toEnrichments(args: ToModelEnrichmentsArgs): unknown;
|
|
17
|
+
toExportPath(args: ToModelExportPathArgs<unknown, unknown>): string;
|
|
18
|
+
};
|
|
19
|
+
/** An OpenAPI operation projection class as an entry declares it. See {@link DeclaredModelProjection}. */
|
|
20
|
+
export type DeclaredOasOperationProjection = {
|
|
21
|
+
id: string;
|
|
22
|
+
type: 'oasOperation';
|
|
23
|
+
toEnrichments(args: ToOasOperationEnrichmentsArgs): unknown;
|
|
24
|
+
toExportPath(args: ToOasOperationExportPathArgs<unknown, unknown>): string;
|
|
25
|
+
};
|
|
26
|
+
/** A webhook projection class as an entry declares it. See {@link DeclaredModelProjection}. */
|
|
27
|
+
export type DeclaredWebhookProjection = {
|
|
28
|
+
id: string;
|
|
29
|
+
type: 'webhook';
|
|
30
|
+
toEnrichments(args: ToWebhookEnrichmentsArgs): unknown;
|
|
31
|
+
toExportPath(args: ToWebhookExportPathArgs<unknown, unknown>): string;
|
|
32
|
+
};
|
|
33
|
+
/** A GraphQL operation projection class as an entry declares it. See {@link DeclaredModelProjection}. */
|
|
34
|
+
export type DeclaredGqlOperationProjection = {
|
|
35
|
+
id: string;
|
|
36
|
+
type: 'gqlOperation';
|
|
37
|
+
toEnrichments(args: ToGqlOperationEnrichmentsArgs): unknown;
|
|
38
|
+
toExportPath(args: ToGqlOperationExportPathArgs<unknown, unknown>): string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* A projection class in an entry's `projections` list.
|
|
42
|
+
*
|
|
43
|
+
* An entry lists every projection class its generator can insert: its own,
|
|
44
|
+
* and each one of another generator that it inserts, such as the model
|
|
45
|
+
* projection an operation generator takes its schemas from. From the list,
|
|
46
|
+
* core can know before a run which files the generator can write.
|
|
47
|
+
*/
|
|
48
|
+
export type DeclaredProjection = DeclaredModelProjection | DeclaredOasOperationProjection | DeclaredWebhookProjection | DeclaredGqlOperationProjection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/dsl/SnippetBase.d.ts
CHANGED
|
@@ -47,8 +47,11 @@ export type SnippetBaseArgs = {
|
|
|
47
47
|
*
|
|
48
48
|
* ## Attribution (gen-maps)
|
|
49
49
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
50
|
+
* In a run that captures a render (`context.capturesRender`: attribution
|
|
51
|
+
* emission is configured), every instance self-wraps its `toString` at
|
|
52
|
+
* construction (an own-property wrapper — shared function,
|
|
53
|
+
* non-enumerable). In any other run no instance has a wrapper, and
|
|
54
|
+
* `toString` is the subclass's own. The wrapper is
|
|
52
55
|
* gated by the **capture interval**: the span while
|
|
53
56
|
* {@link import('@/context/generateTypes.ts').GenerateContextType.captureSink}
|
|
54
57
|
* is set, which `RenderContext` opens around the one capturing render and
|
package/esm/dsl/SnippetBase.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { StackTrail } from '../context/StackTrail.js';
|
|
2
2
|
/**
|
|
3
|
-
* The own-property `toString` wrapper
|
|
4
|
-
* installs at construction
|
|
3
|
+
* The own-property `toString` wrapper a {@link SnippetBase} instance
|
|
4
|
+
* installs at construction, in a run that captures a render
|
|
5
|
+
* (`context.capturesRender`) — ONE shared function, no per-instance closure.
|
|
5
6
|
*
|
|
6
7
|
* Own properties shadow every prototype, so this intercepts the leaf
|
|
7
8
|
* subclass's `toString` no matter where in the hierarchy it is declared —
|
|
@@ -11,9 +12,7 @@ import { StackTrail } from '../context/StackTrail.js';
|
|
|
11
12
|
* instance's own property).
|
|
12
13
|
*
|
|
13
14
|
* Outside the capture interval (`context.captureSink` unset) this is a
|
|
14
|
-
* pure pass-through — one property read and one branch.
|
|
15
|
-
* (`{} as GenerateContextType`) read `undefined` and take the pass-through
|
|
16
|
-
* path.
|
|
15
|
+
* pure pass-through — one property read and one branch.
|
|
17
16
|
*/
|
|
18
17
|
const capturingToString = function () {
|
|
19
18
|
const impl = Object.getPrototypeOf(this).toString;
|
|
@@ -43,8 +42,11 @@ const capturingToString = function () {
|
|
|
43
42
|
*
|
|
44
43
|
* ## Attribution (gen-maps)
|
|
45
44
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* In a run that captures a render (`context.capturesRender`: attribution
|
|
46
|
+
* emission is configured), every instance self-wraps its `toString` at
|
|
47
|
+
* construction (an own-property wrapper — shared function,
|
|
48
|
+
* non-enumerable). In any other run no instance has a wrapper, and
|
|
49
|
+
* `toString` is the subclass's own. The wrapper is
|
|
48
50
|
* gated by the **capture interval**: the span while
|
|
49
51
|
* {@link import('@/context/generateTypes.ts').GenerateContextType.captureSink}
|
|
50
52
|
* is set, which `RenderContext` opens around the one capturing render and
|
|
@@ -104,10 +106,14 @@ export class SnippetBase {
|
|
|
104
106
|
// Self-wrap for attribution capture: an own-property `toString`
|
|
105
107
|
// (shared function value, non-enumerable) that observes into the
|
|
106
108
|
// context's capture sink while the capture interval is open and
|
|
107
|
-
// passes through otherwise.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
// passes through otherwise. A run with no capturing render never
|
|
110
|
+
// opens the interval, so its snippets get no wrapper: one property
|
|
111
|
+
// definition for each snippet of the run is otherwise made for nothing.
|
|
112
|
+
if (context.capturesRender) {
|
|
113
|
+
Object.defineProperty(this, 'toString', {
|
|
114
|
+
value: capturingToString,
|
|
115
|
+
configurable: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
112
118
|
}
|
|
113
119
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeclaredProjection } from '../DeclaredProjection.js';
|
|
1
2
|
import type { RefParts } from '../../helpers/refFns.js';
|
|
2
3
|
import type { EnrichmentRequest } from '../../types/EnrichmentRequest.js';
|
|
3
4
|
import type { TransformModelArgs, ToModelPreviewModuleArgs, ToModelEnrichmentsArgs, IsSupportedModelArgs } from './types.js';
|
|
@@ -5,6 +6,12 @@ import type { PreviewModule } from '../../types/Preview.js';
|
|
|
5
6
|
import type * as v from 'valibot';
|
|
6
7
|
type ToModelEntryArgs<EnrichmentType = undefined> = {
|
|
7
8
|
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* Every projection class this generator can insert: its own, and each one
|
|
11
|
+
* of another generator that it inserts. Core reads only their statics. See
|
|
12
|
+
* {@link DeclaredProjection}. Optional.
|
|
13
|
+
*/
|
|
14
|
+
projections?: readonly DeclaredProjection[];
|
|
8
15
|
transform: ({ context, ref, variant }: TransformModelArgs) => void;
|
|
9
16
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
10
17
|
isSupported?: (args: IsSupportedModelArgs) => boolean;
|
|
@@ -20,6 +27,8 @@ type ToModelEntryArgs<EnrichmentType = undefined> = {
|
|
|
20
27
|
export type ModelEntry<EnrichmentType = undefined> = {
|
|
21
28
|
id: string;
|
|
22
29
|
type: 'model';
|
|
30
|
+
/** The projection classes the entry declared; absent when it declared none. See {@link DeclaredProjection}. */
|
|
31
|
+
projections?: readonly DeclaredProjection[];
|
|
23
32
|
transform: ({ context, ref, variant }: TransformModelArgs) => void;
|
|
24
33
|
isSupported: (args: IsSupportedModelArgs) => boolean;
|
|
25
34
|
supportsVariant: () => boolean;
|
|
@@ -86,5 +95,5 @@ export type ModelEntry<EnrichmentType = undefined> = {
|
|
|
86
95
|
* });
|
|
87
96
|
* ```
|
|
88
97
|
*/
|
|
89
|
-
export declare const toModelEntry: <EnrichmentType = undefined>({ id, transform, isSupported, supportsVariant, toPreviewModule, toEnrichmentSchema, toEnrichmentRequest, toEnrichmentDefaults }: ToModelEntryArgs<EnrichmentType>) => ModelEntry<EnrichmentType>;
|
|
98
|
+
export declare const toModelEntry: <EnrichmentType = undefined>({ id, projections, transform, isSupported, supportsVariant, toPreviewModule, toEnrichmentSchema, toEnrichmentRequest, toEnrichmentDefaults }: ToModelEntryArgs<EnrichmentType>) => ModelEntry<EnrichmentType>;
|
|
90
99
|
export {};
|
|
@@ -56,10 +56,11 @@
|
|
|
56
56
|
* });
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
export const toModelEntry = ({ id, transform, isSupported, supportsVariant, toPreviewModule, toEnrichmentSchema, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
59
|
+
export const toModelEntry = ({ id, projections, transform, isSupported, supportsVariant, toPreviewModule, toEnrichmentSchema, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
60
60
|
return {
|
|
61
61
|
id,
|
|
62
62
|
type: 'model',
|
|
63
|
+
projections,
|
|
63
64
|
transform,
|
|
64
65
|
isSupported: isSupported ?? (() => true),
|
|
65
66
|
supportsVariant: supportsVariant ?? (() => false),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeclaredProjection } from '../../DeclaredProjection.js';
|
|
1
2
|
import type * as v from 'valibot';
|
|
2
3
|
import type { GqlOperation } from '../../../gql/operation/GqlOperation.js';
|
|
3
4
|
import type { EnrichmentRequest } from '../../../types/EnrichmentRequest.js';
|
|
@@ -13,6 +14,12 @@ import type { PreviewModule } from '../../../types/Preview.js';
|
|
|
13
14
|
*/
|
|
14
15
|
export type ToGqlOperationConfigArgs<EnrichmentType = undefined> = {
|
|
15
16
|
id: string;
|
|
17
|
+
/**
|
|
18
|
+
* Every projection class this generator can insert: its own, and each one
|
|
19
|
+
* of another generator that it inserts. Core reads only their statics. See
|
|
20
|
+
* {@link DeclaredProjection}. Optional.
|
|
21
|
+
*/
|
|
22
|
+
projections?: readonly DeclaredProjection[];
|
|
16
23
|
transform: ({ context, operation, variant }: TransformGqlOperationArgs) => void;
|
|
17
24
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
18
25
|
isSupported?: (args: IsSupportedGqlOperationArgs) => boolean;
|
|
@@ -27,6 +34,8 @@ export type ToGqlOperationConfigArgs<EnrichmentType = undefined> = {
|
|
|
27
34
|
export type GqlOperationEntry<EnrichmentType = undefined> = {
|
|
28
35
|
id: string;
|
|
29
36
|
type: 'gqlOperation';
|
|
37
|
+
/** The projection classes the entry declared; absent when it declared none. See {@link DeclaredProjection}. */
|
|
38
|
+
projections?: readonly DeclaredProjection[];
|
|
30
39
|
transform: ({ context, operation, variant }: TransformGqlOperationArgs) => void;
|
|
31
40
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
32
41
|
isSupported: (args: IsSupportedGqlOperationArgs) => boolean;
|
|
@@ -45,4 +54,4 @@ export type GqlOperationEntry<EnrichmentType = undefined> = {
|
|
|
45
54
|
* @param config - Configuration object defining operation behavior
|
|
46
55
|
* @returns Configured operation generator entry ready for pipeline integration
|
|
47
56
|
*/
|
|
48
|
-
export declare const toGqlOperationEntry: <EnrichmentType = undefined>({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest }: ToGqlOperationConfigArgs<EnrichmentType>) => GqlOperationEntry<EnrichmentType>;
|
|
57
|
+
export declare const toGqlOperationEntry: <EnrichmentType = undefined>({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest }: ToGqlOperationConfigArgs<EnrichmentType>) => GqlOperationEntry<EnrichmentType>;
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
* @param config - Configuration object defining operation behavior
|
|
10
10
|
* @returns Configured operation generator entry ready for pipeline integration
|
|
11
11
|
*/
|
|
12
|
-
export const toGqlOperationEntry = ({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest }) => {
|
|
12
|
+
export const toGqlOperationEntry = ({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest }) => {
|
|
13
13
|
return {
|
|
14
14
|
id,
|
|
15
15
|
type: 'gqlOperation',
|
|
16
|
+
projections,
|
|
16
17
|
transform,
|
|
17
18
|
toEnrichmentSchema,
|
|
18
19
|
isSupported: isSupported ?? (() => true),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeclaredProjection } from '../../DeclaredProjection.js';
|
|
1
2
|
import type * as v from 'valibot';
|
|
2
3
|
import type { OasOperation } from '../../../oas/operation/Operation.js';
|
|
3
4
|
import type { EnrichmentRequest } from '../../../types/EnrichmentRequest.js';
|
|
@@ -13,6 +14,12 @@ import type { PreviewModule } from '../../../types/Preview.js';
|
|
|
13
14
|
*/
|
|
14
15
|
export type ToOasOperationConfigArgs<EnrichmentType = undefined> = {
|
|
15
16
|
id: string;
|
|
17
|
+
/**
|
|
18
|
+
* Every projection class this generator can insert: its own, and each one
|
|
19
|
+
* of another generator that it inserts. Core reads only their statics. See
|
|
20
|
+
* {@link DeclaredProjection}. Optional.
|
|
21
|
+
*/
|
|
22
|
+
projections?: readonly DeclaredProjection[];
|
|
16
23
|
transform: ({ context, operation, variant }: TransformOasOperationArgs) => void;
|
|
17
24
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
18
25
|
isSupported?: (args: IsSupportedOasOperationArgs) => boolean;
|
|
@@ -36,6 +43,8 @@ export type ToOasOperationConfigArgs<EnrichmentType = undefined> = {
|
|
|
36
43
|
export type OasOperationEntry<EnrichmentType = undefined> = {
|
|
37
44
|
id: string;
|
|
38
45
|
type: 'oasOperation';
|
|
46
|
+
/** The projection classes the entry declared; absent when it declared none. See {@link DeclaredProjection}. */
|
|
47
|
+
projections?: readonly DeclaredProjection[];
|
|
39
48
|
transform: ({ context, operation, variant }: TransformOasOperationArgs) => void;
|
|
40
49
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
41
50
|
isSupported: (args: IsSupportedOasOperationArgs) => boolean;
|
|
@@ -70,4 +79,4 @@ export type OasOperationEntry<EnrichmentType = undefined> = {
|
|
|
70
79
|
* });
|
|
71
80
|
* ```
|
|
72
81
|
*/
|
|
73
|
-
export declare const toOasOperationEntry: <EnrichmentType = undefined>({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }: ToOasOperationConfigArgs<EnrichmentType>) => OasOperationEntry<EnrichmentType>;
|
|
82
|
+
export declare const toOasOperationEntry: <EnrichmentType = undefined>({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }: ToOasOperationConfigArgs<EnrichmentType>) => OasOperationEntry<EnrichmentType>;
|
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
* });
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
export const toOasOperationEntry = ({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
27
|
+
export const toOasOperationEntry = ({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
28
28
|
return {
|
|
29
29
|
id,
|
|
30
30
|
type: 'oasOperation',
|
|
31
|
+
projections,
|
|
31
32
|
transform,
|
|
32
33
|
toEnrichmentSchema,
|
|
33
34
|
isSupported: isSupported ?? (() => true),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeclaredProjection } from '../DeclaredProjection.js';
|
|
1
2
|
import type * as v from 'valibot';
|
|
2
3
|
import type { OasWebhook } from '../../oas/webhook/Webhook.js';
|
|
3
4
|
import type { EnrichmentRequest } from '../../types/EnrichmentRequest.js';
|
|
@@ -14,6 +15,12 @@ import type { PreviewModule } from '../../types/Preview.js';
|
|
|
14
15
|
*/
|
|
15
16
|
export type ToWebhookConfigArgs<EnrichmentType = undefined> = {
|
|
16
17
|
id: string;
|
|
18
|
+
/**
|
|
19
|
+
* Every projection class this generator can insert: its own, and each one
|
|
20
|
+
* of another generator that it inserts. Core reads only their statics. See
|
|
21
|
+
* {@link DeclaredProjection}. Optional.
|
|
22
|
+
*/
|
|
23
|
+
projections?: readonly DeclaredProjection[];
|
|
17
24
|
transform: ({ context, webhook, variant }: TransformWebhookArgs) => void;
|
|
18
25
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
19
26
|
isSupported?: (args: IsSupportedWebhookArgs) => boolean;
|
|
@@ -29,6 +36,8 @@ export type ToWebhookConfigArgs<EnrichmentType = undefined> = {
|
|
|
29
36
|
export type WebhookEntry<EnrichmentType = undefined> = {
|
|
30
37
|
id: string;
|
|
31
38
|
type: 'webhook';
|
|
39
|
+
/** The projection classes the entry declared; absent when it declared none. See {@link DeclaredProjection}. */
|
|
40
|
+
projections?: readonly DeclaredProjection[];
|
|
32
41
|
transform: ({ context, webhook, variant }: TransformWebhookArgs) => void;
|
|
33
42
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
34
43
|
isSupported: (args: IsSupportedWebhookArgs) => boolean;
|
|
@@ -59,4 +68,4 @@ export type WebhookEntry<EnrichmentType = undefined> = {
|
|
|
59
68
|
* });
|
|
60
69
|
* ```
|
|
61
70
|
*/
|
|
62
|
-
export declare const toWebhookEntry: <EnrichmentType = undefined>({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }: ToWebhookConfigArgs<EnrichmentType>) => WebhookEntry<EnrichmentType>;
|
|
71
|
+
export declare const toWebhookEntry: <EnrichmentType = undefined>({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }: ToWebhookConfigArgs<EnrichmentType>) => WebhookEntry<EnrichmentType>;
|
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
* });
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
export const toWebhookEntry = ({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
23
|
+
export const toWebhookEntry = ({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
24
24
|
return {
|
|
25
25
|
id,
|
|
26
26
|
type: 'webhook',
|
|
27
|
+
projections,
|
|
27
28
|
transform,
|
|
28
29
|
toEnrichmentSchema,
|
|
29
30
|
isSupported: isSupported ?? (() => true),
|
package/esm/mod.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ export * from './dsl/IdentifierType.js';
|
|
|
92
92
|
export * from './dsl/Inserted.js';
|
|
93
93
|
export * from './dsl/model/ModelDriver.js';
|
|
94
94
|
export * from './dsl/model/toModelProjectionBase.js';
|
|
95
|
+
export type * from './dsl/DeclaredProjection.js';
|
|
95
96
|
export * from './dsl/model/toModelEntry.js';
|
|
96
97
|
export * from './dsl/model/types.js';
|
|
97
98
|
export * from './dsl/operation/oas/OasOperationDriver.js';
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Attribution (gen-maps) **emission** config.
|
|
3
3
|
*
|
|
4
|
-
* Attribution *capture* is always on and needs no configuration
|
|
5
|
-
* intrinsic to the pipeline:
|
|
4
|
+
* Attribution *location capture* is always on and needs no configuration:
|
|
6
5
|
*
|
|
7
6
|
* - **Parse phase**: every parsed OAS / GQL node snapshots the visitor's
|
|
8
7
|
* `StackTrail` into its `OasBase` base (`toLocation()` → JSON Pointer).
|
|
9
|
-
* - **Generate phase**: every `SnippetBase`
|
|
10
|
-
* `toString` to capture parent/child edges
|
|
11
|
-
*
|
|
8
|
+
* - **Generate phase**: in a run with `postPass`, every `SnippetBase`
|
|
9
|
+
* instance wraps its `toString` to capture parent/child edges, so the
|
|
10
|
+
* post-render span resolver can attribute byte ranges to producers. A
|
|
11
|
+
* run with no `postPass` installs no wrapper.
|
|
12
12
|
*
|
|
13
13
|
* This type configures only **emission**: it is supplied at the run level
|
|
14
14
|
* (`CoreContext.toArtifacts`) and consumed solely by the post-render
|
|
15
|
-
* pass. The parse and generate contexts do not carry it
|
|
16
|
-
*
|
|
17
|
-
* on-disk output; setting
|
|
18
|
-
* `
|
|
15
|
+
* pass. The parse and generate contexts do not carry it; the generate
|
|
16
|
+
* context only knows whether the run has a capture channel. Without
|
|
17
|
+
* `postPass` you get location capture but no on-disk output; setting
|
|
18
|
+
* `postPass` activates the pass and surfaces `sidecars` /
|
|
19
|
+
* `generationMap` on the result.
|
|
19
20
|
*/
|
|
20
21
|
import type { ParserAdapter } from '../anchors/ParserAdapter.js';
|
|
21
22
|
import type { GeneratorMetaLookup } from '../anchors/postPass.js';
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Attribution (gen-maps) **emission** config.
|
|
3
3
|
*
|
|
4
|
-
* Attribution *capture* is always on and needs no configuration
|
|
5
|
-
* intrinsic to the pipeline:
|
|
4
|
+
* Attribution *location capture* is always on and needs no configuration:
|
|
6
5
|
*
|
|
7
6
|
* - **Parse phase**: every parsed OAS / GQL node snapshots the visitor's
|
|
8
7
|
* `StackTrail` into its `OasBase` base (`toLocation()` → JSON Pointer).
|
|
9
|
-
* - **Generate phase**: every `SnippetBase`
|
|
10
|
-
* `toString` to capture parent/child edges
|
|
11
|
-
*
|
|
8
|
+
* - **Generate phase**: in a run with `postPass`, every `SnippetBase`
|
|
9
|
+
* instance wraps its `toString` to capture parent/child edges, so the
|
|
10
|
+
* post-render span resolver can attribute byte ranges to producers. A
|
|
11
|
+
* run with no `postPass` installs no wrapper.
|
|
12
12
|
*
|
|
13
13
|
* This type configures only **emission**: it is supplied at the run level
|
|
14
14
|
* (`CoreContext.toArtifacts`) and consumed solely by the post-render
|
|
15
|
-
* pass. The parse and generate contexts do not carry it
|
|
16
|
-
*
|
|
17
|
-
* on-disk output; setting
|
|
18
|
-
* `
|
|
15
|
+
* pass. The parse and generate contexts do not carry it; the generate
|
|
16
|
+
* context only knows whether the run has a capture channel. Without
|
|
17
|
+
* `postPass` you get location capture but no on-disk output; setting
|
|
18
|
+
* `postPass` activates the pass and surfaces `sidecars` /
|
|
19
|
+
* `generationMap` on the result.
|
|
19
20
|
*/
|
|
20
21
|
export {};
|
package/package.json
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* The capture mechanism for gen-maps. A {@link CaptureSink} is owned by
|
|
5
5
|
* {@link import('@/context/RenderContext.ts').RenderContext} for the
|
|
6
6
|
* duration of the single render pass and published to snippets through the
|
|
7
|
-
* shared {@link CaptureChannel}:
|
|
8
|
-
* its `toString` at construction
|
|
7
|
+
* shared {@link CaptureChannel}: in a run that has a channel, every
|
|
8
|
+
* `SnippetBase` instance self-wraps its `toString` at construction
|
|
9
|
+
* (own-property wrapper), and the wrapper
|
|
9
10
|
* observes into the channel's sink while the **capture interval** is open
|
|
10
11
|
* — the span while `channel.sink` is set. Each `toString` invocation is
|
|
11
12
|
* observed into an **occurrence tree** — one node per call, keyed by
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* The capture mechanism for gen-maps. A {@link CaptureSink} is owned by
|
|
6
6
|
* {@link import('@/context/RenderContext.ts').RenderContext} for the
|
|
7
7
|
* duration of the single render pass and published to snippets through the
|
|
8
|
-
* shared {@link CaptureChannel}:
|
|
9
|
-
* its `toString` at construction
|
|
8
|
+
* shared {@link CaptureChannel}: in a run that has a channel, every
|
|
9
|
+
* `SnippetBase` instance self-wraps its `toString` at construction
|
|
10
|
+
* (own-property wrapper), and the wrapper
|
|
10
11
|
* observes into the channel's sink while the **capture interval** is open
|
|
11
12
|
* — the span while `channel.sink` is set. Each `toString` invocation is
|
|
12
13
|
* observed into an **occurrence tree** — one node per call, keyed by
|
|
@@ -96,9 +96,10 @@ export type ToArtifactsArgs = {
|
|
|
96
96
|
/** Whether to suppress console output */
|
|
97
97
|
silent: boolean;
|
|
98
98
|
/**
|
|
99
|
-
* Optional attribution (gen-maps) **emission** config.
|
|
100
|
-
* always on; when `postPass` is set, the
|
|
101
|
-
*
|
|
99
|
+
* Optional attribution (gen-maps) **emission** config. Location
|
|
100
|
+
* capture is always on; when `postPass` is set, the run's snippets wrap
|
|
101
|
+
* their `toString` and the pipeline emits sidecars + a generation map
|
|
102
|
+
* alongside the usual artifacts. See
|
|
102
103
|
* {@link AttributionState}.
|
|
103
104
|
*/
|
|
104
105
|
attribution?: AttributionState;
|
|
@@ -352,8 +352,12 @@ class CoreContext {
|
|
|
352
352
|
// The shared attribution capture channel: snippets constructed
|
|
353
353
|
// during generate hold the GenerateContext, whose `captureSink`
|
|
354
354
|
// reads this slot; RenderContext flips it around the one capturing
|
|
355
|
-
// render. One object per run wires the two phases together.
|
|
356
|
-
|
|
355
|
+
// render. One object per run wires the two phases together. A run
|
|
356
|
+
// with no `attribution.postPass` has no capturing render, so it has
|
|
357
|
+
// no channel, and its snippets install no `toString` wrapper.
|
|
358
|
+
const captureChannel = attribution?.postPass
|
|
359
|
+
? { sink: undefined }
|
|
360
|
+
: undefined;
|
|
357
361
|
const { files, previews, inspection, enrichmentWarnings } = stackTrail.trace('generate', st => {
|
|
358
362
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'generate', "f");
|
|
359
363
|
const generatePhase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
@@ -454,13 +458,12 @@ class CoreContext {
|
|
|
454
458
|
__classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_logParseLine).call(this, parsedDocument, phase.context.issues, runStartedAt);
|
|
455
459
|
const subjects = stackTrail.trace('generate', () => {
|
|
456
460
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'generate', "f");
|
|
457
|
-
// Capability probing never renders, so
|
|
458
|
-
// opens — a throwaway channel satisfies the wiring.
|
|
461
|
+
// Capability probing never renders, so it has no capture channel.
|
|
459
462
|
const generatePhase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
460
463
|
toGeneratorConfigMap,
|
|
461
464
|
document: parsedDocument,
|
|
462
465
|
settings,
|
|
463
|
-
captureChannel:
|
|
466
|
+
captureChannel: undefined
|
|
464
467
|
});
|
|
465
468
|
__classPrivateFieldSet(this, _CoreContext_phase, generatePhase, "f");
|
|
466
469
|
return generatePhase.context.toSupportedSubjects();
|
|
@@ -504,13 +507,12 @@ class CoreContext {
|
|
|
504
507
|
__classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_logParseLine).call(this, parsedDocument, phase.context.issues, runStartedAt);
|
|
505
508
|
const enrichmentDefaults = stackTrail.trace('generate', () => {
|
|
506
509
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'generate', "f");
|
|
507
|
-
// Seeding never renders, so
|
|
508
|
-
// throwaway channel satisfies the wiring.
|
|
510
|
+
// Seeding never renders, so it has no capture channel.
|
|
509
511
|
const generatePhase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
510
512
|
toGeneratorConfigMap,
|
|
511
513
|
document: parsedDocument,
|
|
512
514
|
settings,
|
|
513
|
-
captureChannel:
|
|
515
|
+
captureChannel: undefined
|
|
514
516
|
});
|
|
515
517
|
__classPrivateFieldSet(this, _CoreContext_phase, generatePhase, "f");
|
|
516
518
|
return generatePhase.context.toEnrichmentDefaults();
|
|
@@ -47,7 +47,8 @@ type ConstructorArgs = {
|
|
|
47
47
|
* Shared attribution capture channel — the slot `RenderContext` flips to
|
|
48
48
|
* open/close the capture interval. Snippets read it through this
|
|
49
49
|
* context's {@link GenerateContext.captureSink}. Optional: when omitted
|
|
50
|
-
* (tests, capture-less runs) `captureSink` is always `undefined
|
|
50
|
+
* (tests, capture-less runs) `captureSink` is always `undefined` and
|
|
51
|
+
* `capturesRender` is false, so no snippet installs a `toString` wrapper.
|
|
51
52
|
*/
|
|
52
53
|
captureChannel?: CaptureChannel;
|
|
53
54
|
/**
|
|
@@ -178,6 +179,12 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
178
179
|
* shared channel's `sink`.
|
|
179
180
|
*/
|
|
180
181
|
get captureSink(): CaptureSink | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Whether this run has a capturing render: it was given a capture
|
|
184
|
+
* channel. A `SnippetBase` instance installs its `toString` wrapper only
|
|
185
|
+
* then.
|
|
186
|
+
*/
|
|
187
|
+
get capturesRender(): boolean;
|
|
181
188
|
/**
|
|
182
189
|
* The trail of the subject whose variant is being generated, or
|
|
183
190
|
* `undefined` outside one. Log lines and the results the logger
|
|
@@ -224,6 +224,14 @@ class GenerateContext {
|
|
|
224
224
|
get captureSink() {
|
|
225
225
|
return __classPrivateFieldGet(this, _GenerateContext_captureChannel, "f")?.sink;
|
|
226
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Whether this run has a capturing render: it was given a capture
|
|
229
|
+
* channel. A `SnippetBase` instance installs its `toString` wrapper only
|
|
230
|
+
* then.
|
|
231
|
+
*/
|
|
232
|
+
get capturesRender() {
|
|
233
|
+
return __classPrivateFieldGet(this, _GenerateContext_captureChannel, "f") !== undefined;
|
|
234
|
+
}
|
|
227
235
|
/**
|
|
228
236
|
* The trail of the subject whose variant is being generated, or
|
|
229
237
|
* `undefined` outside one. Log lines and the results the logger
|
|
@@ -129,9 +129,8 @@ class RenderContext {
|
|
|
129
129
|
*/
|
|
130
130
|
render(stackTrail) {
|
|
131
131
|
const postPassConfig = this.attribution?.postPass;
|
|
132
|
-
// No emission configured → plain render, no capture: the
|
|
133
|
-
//
|
|
134
|
-
// the pass-through path.
|
|
132
|
+
// No emission configured → plain render, no capture: the run has no
|
|
133
|
+
// capture channel, so its snippets have no `toString` wrapper.
|
|
135
134
|
if (!postPassConfig) {
|
|
136
135
|
const result = this.collate(stackTrail);
|
|
137
136
|
return {
|
|
@@ -450,11 +450,8 @@ export type GenerateContextType = {
|
|
|
450
450
|
pendingStack: PendingDefinition[];
|
|
451
451
|
document: SkmtcParsedDocument;
|
|
452
452
|
/**
|
|
453
|
-
* Attribution (gen-maps) state.
|
|
454
|
-
*
|
|
455
|
-
* module-level render stack, so the post-render span resolver can
|
|
456
|
-
* attribute byte ranges to producers. When omitted, the wrap is
|
|
457
|
-
* skipped entirely — zero cost.
|
|
453
|
+
* Attribution (gen-maps) state. It does not decide whether a
|
|
454
|
+
* `SnippetBase` wraps its `toString`: {@link capturesRender} does.
|
|
458
455
|
*/
|
|
459
456
|
attribution?: AttributionState;
|
|
460
457
|
/**
|
|
@@ -462,10 +459,18 @@ export type GenerateContextType = {
|
|
|
462
459
|
* capture interval. Read by every `SnippetBase` instance's `toString`
|
|
463
460
|
* wrapper; `RenderContext` opens/closes the interval through the shared
|
|
464
461
|
* {@link import('@/anchors/CaptureSink.ts').CaptureChannel} that
|
|
465
|
-
* `CoreContext` wires into both contexts.
|
|
466
|
-
* `
|
|
462
|
+
* `CoreContext` wires into both contexts. In a run with no capturing
|
|
463
|
+
* render (`capturesRender` false, as in a bare test mock) no snippet
|
|
464
|
+
* has a wrapper, so nothing reads it.
|
|
467
465
|
*/
|
|
468
466
|
captureSink: CaptureSink | undefined;
|
|
467
|
+
/**
|
|
468
|
+
* Whether the run has a capturing render (attribution emission is
|
|
469
|
+
* configured). Read once by every `SnippetBase` instance, at
|
|
470
|
+
* construction: it installs its `toString` wrapper only when this is
|
|
471
|
+
* true.
|
|
472
|
+
*/
|
|
473
|
+
capturesRender: boolean;
|
|
469
474
|
toArtifacts: (stackTrail: StackTrail) => GenerateResult;
|
|
470
475
|
registerJson: ({ destinationPath, json }: RegisterJsonArgs) => void;
|
|
471
476
|
registerMarkdown: ({ destinationPath, markdown }: RegisterMarkdownArgs) => void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ToModelEnrichmentsArgs, ToModelExportPathArgs } from './model/types.js';
|
|
2
|
+
import type { ToOasOperationEnrichmentsArgs, ToOasOperationExportPathArgs } from './operation/oas/types.js';
|
|
3
|
+
import type { ToGqlOperationEnrichmentsArgs, ToGqlOperationExportPathArgs } from './operation/gql/types.js';
|
|
4
|
+
import type { ToWebhookEnrichmentsArgs, ToWebhookExportPathArgs } from './webhook/types.js';
|
|
5
|
+
/**
|
|
6
|
+
* A model projection class as a generator's entry declares it: the statics
|
|
7
|
+
* core can read before it constructs anything.
|
|
8
|
+
*
|
|
9
|
+
* The statics are methods, not function properties. TypeScript compares a
|
|
10
|
+
* method's parameters both ways, so projection classes with different
|
|
11
|
+
* enrichment and option types fit in one list.
|
|
12
|
+
*/
|
|
13
|
+
export type DeclaredModelProjection = {
|
|
14
|
+
id: string;
|
|
15
|
+
type: 'model';
|
|
16
|
+
toEnrichments(args: ToModelEnrichmentsArgs): unknown;
|
|
17
|
+
toExportPath(args: ToModelExportPathArgs<unknown, unknown>): string;
|
|
18
|
+
};
|
|
19
|
+
/** An OpenAPI operation projection class as an entry declares it. See {@link DeclaredModelProjection}. */
|
|
20
|
+
export type DeclaredOasOperationProjection = {
|
|
21
|
+
id: string;
|
|
22
|
+
type: 'oasOperation';
|
|
23
|
+
toEnrichments(args: ToOasOperationEnrichmentsArgs): unknown;
|
|
24
|
+
toExportPath(args: ToOasOperationExportPathArgs<unknown, unknown>): string;
|
|
25
|
+
};
|
|
26
|
+
/** A webhook projection class as an entry declares it. See {@link DeclaredModelProjection}. */
|
|
27
|
+
export type DeclaredWebhookProjection = {
|
|
28
|
+
id: string;
|
|
29
|
+
type: 'webhook';
|
|
30
|
+
toEnrichments(args: ToWebhookEnrichmentsArgs): unknown;
|
|
31
|
+
toExportPath(args: ToWebhookExportPathArgs<unknown, unknown>): string;
|
|
32
|
+
};
|
|
33
|
+
/** A GraphQL operation projection class as an entry declares it. See {@link DeclaredModelProjection}. */
|
|
34
|
+
export type DeclaredGqlOperationProjection = {
|
|
35
|
+
id: string;
|
|
36
|
+
type: 'gqlOperation';
|
|
37
|
+
toEnrichments(args: ToGqlOperationEnrichmentsArgs): unknown;
|
|
38
|
+
toExportPath(args: ToGqlOperationExportPathArgs<unknown, unknown>): string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* A projection class in an entry's `projections` list.
|
|
42
|
+
*
|
|
43
|
+
* An entry lists every projection class its generator can insert: its own,
|
|
44
|
+
* and each one of another generator that it inserts, such as the model
|
|
45
|
+
* projection an operation generator takes its schemas from. From the list,
|
|
46
|
+
* core can know before a run which files the generator can write.
|
|
47
|
+
*/
|
|
48
|
+
export type DeclaredProjection = DeclaredModelProjection | DeclaredOasOperationProjection | DeclaredWebhookProjection | DeclaredGqlOperationProjection;
|
|
@@ -47,8 +47,11 @@ export type SnippetBaseArgs = {
|
|
|
47
47
|
*
|
|
48
48
|
* ## Attribution (gen-maps)
|
|
49
49
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
50
|
+
* In a run that captures a render (`context.capturesRender`: attribution
|
|
51
|
+
* emission is configured), every instance self-wraps its `toString` at
|
|
52
|
+
* construction (an own-property wrapper — shared function,
|
|
53
|
+
* non-enumerable). In any other run no instance has a wrapper, and
|
|
54
|
+
* `toString` is the subclass's own. The wrapper is
|
|
52
55
|
* gated by the **capture interval**: the span while
|
|
53
56
|
* {@link import('@/context/generateTypes.ts').GenerateContextType.captureSink}
|
|
54
57
|
* is set, which `RenderContext` opens around the one capturing render and
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SnippetBase = void 0;
|
|
4
4
|
const StackTrail_js_1 = require("../context/StackTrail.js");
|
|
5
5
|
/**
|
|
6
|
-
* The own-property `toString` wrapper
|
|
7
|
-
* installs at construction
|
|
6
|
+
* The own-property `toString` wrapper a {@link SnippetBase} instance
|
|
7
|
+
* installs at construction, in a run that captures a render
|
|
8
|
+
* (`context.capturesRender`) — ONE shared function, no per-instance closure.
|
|
8
9
|
*
|
|
9
10
|
* Own properties shadow every prototype, so this intercepts the leaf
|
|
10
11
|
* subclass's `toString` no matter where in the hierarchy it is declared —
|
|
@@ -14,9 +15,7 @@ const StackTrail_js_1 = require("../context/StackTrail.js");
|
|
|
14
15
|
* instance's own property).
|
|
15
16
|
*
|
|
16
17
|
* Outside the capture interval (`context.captureSink` unset) this is a
|
|
17
|
-
* pure pass-through — one property read and one branch.
|
|
18
|
-
* (`{} as GenerateContextType`) read `undefined` and take the pass-through
|
|
19
|
-
* path.
|
|
18
|
+
* pure pass-through — one property read and one branch.
|
|
20
19
|
*/
|
|
21
20
|
const capturingToString = function () {
|
|
22
21
|
const impl = Object.getPrototypeOf(this).toString;
|
|
@@ -46,8 +45,11 @@ const capturingToString = function () {
|
|
|
46
45
|
*
|
|
47
46
|
* ## Attribution (gen-maps)
|
|
48
47
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
48
|
+
* In a run that captures a render (`context.capturesRender`: attribution
|
|
49
|
+
* emission is configured), every instance self-wraps its `toString` at
|
|
50
|
+
* construction (an own-property wrapper — shared function,
|
|
51
|
+
* non-enumerable). In any other run no instance has a wrapper, and
|
|
52
|
+
* `toString` is the subclass's own. The wrapper is
|
|
51
53
|
* gated by the **capture interval**: the span while
|
|
52
54
|
* {@link import('@/context/generateTypes.ts').GenerateContextType.captureSink}
|
|
53
55
|
* is set, which `RenderContext` opens around the one capturing render and
|
|
@@ -107,11 +109,15 @@ class SnippetBase {
|
|
|
107
109
|
// Self-wrap for attribution capture: an own-property `toString`
|
|
108
110
|
// (shared function value, non-enumerable) that observes into the
|
|
109
111
|
// context's capture sink while the capture interval is open and
|
|
110
|
-
// passes through otherwise.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
// passes through otherwise. A run with no capturing render never
|
|
113
|
+
// opens the interval, so its snippets get no wrapper: one property
|
|
114
|
+
// definition for each snippet of the run is otherwise made for nothing.
|
|
115
|
+
if (context.capturesRender) {
|
|
116
|
+
Object.defineProperty(this, 'toString', {
|
|
117
|
+
value: capturingToString,
|
|
118
|
+
configurable: true
|
|
119
|
+
});
|
|
120
|
+
}
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
123
|
exports.SnippetBase = SnippetBase;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeclaredProjection } from '../DeclaredProjection.js';
|
|
1
2
|
import type { RefParts } from '../../helpers/refFns.js';
|
|
2
3
|
import type { EnrichmentRequest } from '../../types/EnrichmentRequest.js';
|
|
3
4
|
import type { TransformModelArgs, ToModelPreviewModuleArgs, ToModelEnrichmentsArgs, IsSupportedModelArgs } from './types.js';
|
|
@@ -5,6 +6,12 @@ import type { PreviewModule } from '../../types/Preview.js';
|
|
|
5
6
|
import type * as v from 'valibot';
|
|
6
7
|
type ToModelEntryArgs<EnrichmentType = undefined> = {
|
|
7
8
|
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* Every projection class this generator can insert: its own, and each one
|
|
11
|
+
* of another generator that it inserts. Core reads only their statics. See
|
|
12
|
+
* {@link DeclaredProjection}. Optional.
|
|
13
|
+
*/
|
|
14
|
+
projections?: readonly DeclaredProjection[];
|
|
8
15
|
transform: ({ context, ref, variant }: TransformModelArgs) => void;
|
|
9
16
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
10
17
|
isSupported?: (args: IsSupportedModelArgs) => boolean;
|
|
@@ -20,6 +27,8 @@ type ToModelEntryArgs<EnrichmentType = undefined> = {
|
|
|
20
27
|
export type ModelEntry<EnrichmentType = undefined> = {
|
|
21
28
|
id: string;
|
|
22
29
|
type: 'model';
|
|
30
|
+
/** The projection classes the entry declared; absent when it declared none. See {@link DeclaredProjection}. */
|
|
31
|
+
projections?: readonly DeclaredProjection[];
|
|
23
32
|
transform: ({ context, ref, variant }: TransformModelArgs) => void;
|
|
24
33
|
isSupported: (args: IsSupportedModelArgs) => boolean;
|
|
25
34
|
supportsVariant: () => boolean;
|
|
@@ -86,5 +95,5 @@ export type ModelEntry<EnrichmentType = undefined> = {
|
|
|
86
95
|
* });
|
|
87
96
|
* ```
|
|
88
97
|
*/
|
|
89
|
-
export declare const toModelEntry: <EnrichmentType = undefined>({ id, transform, isSupported, supportsVariant, toPreviewModule, toEnrichmentSchema, toEnrichmentRequest, toEnrichmentDefaults }: ToModelEntryArgs<EnrichmentType>) => ModelEntry<EnrichmentType>;
|
|
98
|
+
export declare const toModelEntry: <EnrichmentType = undefined>({ id, projections, transform, isSupported, supportsVariant, toPreviewModule, toEnrichmentSchema, toEnrichmentRequest, toEnrichmentDefaults }: ToModelEntryArgs<EnrichmentType>) => ModelEntry<EnrichmentType>;
|
|
90
99
|
export {};
|
|
@@ -59,10 +59,11 @@ exports.toModelEntry = void 0;
|
|
|
59
59
|
* });
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
|
-
const toModelEntry = ({ id, transform, isSupported, supportsVariant, toPreviewModule, toEnrichmentSchema, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
62
|
+
const toModelEntry = ({ id, projections, transform, isSupported, supportsVariant, toPreviewModule, toEnrichmentSchema, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
63
63
|
return {
|
|
64
64
|
id,
|
|
65
65
|
type: 'model',
|
|
66
|
+
projections,
|
|
66
67
|
transform,
|
|
67
68
|
isSupported: isSupported ?? (() => true),
|
|
68
69
|
supportsVariant: supportsVariant ?? (() => false),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeclaredProjection } from '../../DeclaredProjection.js';
|
|
1
2
|
import type * as v from 'valibot';
|
|
2
3
|
import type { GqlOperation } from '../../../gql/operation/GqlOperation.js';
|
|
3
4
|
import type { EnrichmentRequest } from '../../../types/EnrichmentRequest.js';
|
|
@@ -13,6 +14,12 @@ import type { PreviewModule } from '../../../types/Preview.js';
|
|
|
13
14
|
*/
|
|
14
15
|
export type ToGqlOperationConfigArgs<EnrichmentType = undefined> = {
|
|
15
16
|
id: string;
|
|
17
|
+
/**
|
|
18
|
+
* Every projection class this generator can insert: its own, and each one
|
|
19
|
+
* of another generator that it inserts. Core reads only their statics. See
|
|
20
|
+
* {@link DeclaredProjection}. Optional.
|
|
21
|
+
*/
|
|
22
|
+
projections?: readonly DeclaredProjection[];
|
|
16
23
|
transform: ({ context, operation, variant }: TransformGqlOperationArgs) => void;
|
|
17
24
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
18
25
|
isSupported?: (args: IsSupportedGqlOperationArgs) => boolean;
|
|
@@ -27,6 +34,8 @@ export type ToGqlOperationConfigArgs<EnrichmentType = undefined> = {
|
|
|
27
34
|
export type GqlOperationEntry<EnrichmentType = undefined> = {
|
|
28
35
|
id: string;
|
|
29
36
|
type: 'gqlOperation';
|
|
37
|
+
/** The projection classes the entry declared; absent when it declared none. See {@link DeclaredProjection}. */
|
|
38
|
+
projections?: readonly DeclaredProjection[];
|
|
30
39
|
transform: ({ context, operation, variant }: TransformGqlOperationArgs) => void;
|
|
31
40
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
32
41
|
isSupported: (args: IsSupportedGqlOperationArgs) => boolean;
|
|
@@ -45,4 +54,4 @@ export type GqlOperationEntry<EnrichmentType = undefined> = {
|
|
|
45
54
|
* @param config - Configuration object defining operation behavior
|
|
46
55
|
* @returns Configured operation generator entry ready for pipeline integration
|
|
47
56
|
*/
|
|
48
|
-
export declare const toGqlOperationEntry: <EnrichmentType = undefined>({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest }: ToGqlOperationConfigArgs<EnrichmentType>) => GqlOperationEntry<EnrichmentType>;
|
|
57
|
+
export declare const toGqlOperationEntry: <EnrichmentType = undefined>({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest }: ToGqlOperationConfigArgs<EnrichmentType>) => GqlOperationEntry<EnrichmentType>;
|
|
@@ -12,10 +12,11 @@ exports.toGqlOperationEntry = void 0;
|
|
|
12
12
|
* @param config - Configuration object defining operation behavior
|
|
13
13
|
* @returns Configured operation generator entry ready for pipeline integration
|
|
14
14
|
*/
|
|
15
|
-
const toGqlOperationEntry = ({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest }) => {
|
|
15
|
+
const toGqlOperationEntry = ({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest }) => {
|
|
16
16
|
return {
|
|
17
17
|
id,
|
|
18
18
|
type: 'gqlOperation',
|
|
19
|
+
projections,
|
|
19
20
|
transform,
|
|
20
21
|
toEnrichmentSchema,
|
|
21
22
|
isSupported: isSupported ?? (() => true),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeclaredProjection } from '../../DeclaredProjection.js';
|
|
1
2
|
import type * as v from 'valibot';
|
|
2
3
|
import type { OasOperation } from '../../../oas/operation/Operation.js';
|
|
3
4
|
import type { EnrichmentRequest } from '../../../types/EnrichmentRequest.js';
|
|
@@ -13,6 +14,12 @@ import type { PreviewModule } from '../../../types/Preview.js';
|
|
|
13
14
|
*/
|
|
14
15
|
export type ToOasOperationConfigArgs<EnrichmentType = undefined> = {
|
|
15
16
|
id: string;
|
|
17
|
+
/**
|
|
18
|
+
* Every projection class this generator can insert: its own, and each one
|
|
19
|
+
* of another generator that it inserts. Core reads only their statics. See
|
|
20
|
+
* {@link DeclaredProjection}. Optional.
|
|
21
|
+
*/
|
|
22
|
+
projections?: readonly DeclaredProjection[];
|
|
16
23
|
transform: ({ context, operation, variant }: TransformOasOperationArgs) => void;
|
|
17
24
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
18
25
|
isSupported?: (args: IsSupportedOasOperationArgs) => boolean;
|
|
@@ -36,6 +43,8 @@ export type ToOasOperationConfigArgs<EnrichmentType = undefined> = {
|
|
|
36
43
|
export type OasOperationEntry<EnrichmentType = undefined> = {
|
|
37
44
|
id: string;
|
|
38
45
|
type: 'oasOperation';
|
|
46
|
+
/** The projection classes the entry declared; absent when it declared none. See {@link DeclaredProjection}. */
|
|
47
|
+
projections?: readonly DeclaredProjection[];
|
|
39
48
|
transform: ({ context, operation, variant }: TransformOasOperationArgs) => void;
|
|
40
49
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
41
50
|
isSupported: (args: IsSupportedOasOperationArgs) => boolean;
|
|
@@ -70,4 +79,4 @@ export type OasOperationEntry<EnrichmentType = undefined> = {
|
|
|
70
79
|
* });
|
|
71
80
|
* ```
|
|
72
81
|
*/
|
|
73
|
-
export declare const toOasOperationEntry: <EnrichmentType = undefined>({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }: ToOasOperationConfigArgs<EnrichmentType>) => OasOperationEntry<EnrichmentType>;
|
|
82
|
+
export declare const toOasOperationEntry: <EnrichmentType = undefined>({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }: ToOasOperationConfigArgs<EnrichmentType>) => OasOperationEntry<EnrichmentType>;
|
|
@@ -27,10 +27,11 @@ exports.toOasOperationEntry = void 0;
|
|
|
27
27
|
* });
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
const toOasOperationEntry = ({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
30
|
+
const toOasOperationEntry = ({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
31
31
|
return {
|
|
32
32
|
id,
|
|
33
33
|
type: 'oasOperation',
|
|
34
|
+
projections,
|
|
34
35
|
transform,
|
|
35
36
|
toEnrichmentSchema,
|
|
36
37
|
isSupported: isSupported ?? (() => true),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeclaredProjection } from '../DeclaredProjection.js';
|
|
1
2
|
import type * as v from 'valibot';
|
|
2
3
|
import type { OasWebhook } from '../../oas/webhook/Webhook.js';
|
|
3
4
|
import type { EnrichmentRequest } from '../../types/EnrichmentRequest.js';
|
|
@@ -14,6 +15,12 @@ import type { PreviewModule } from '../../types/Preview.js';
|
|
|
14
15
|
*/
|
|
15
16
|
export type ToWebhookConfigArgs<EnrichmentType = undefined> = {
|
|
16
17
|
id: string;
|
|
18
|
+
/**
|
|
19
|
+
* Every projection class this generator can insert: its own, and each one
|
|
20
|
+
* of another generator that it inserts. Core reads only their statics. See
|
|
21
|
+
* {@link DeclaredProjection}. Optional.
|
|
22
|
+
*/
|
|
23
|
+
projections?: readonly DeclaredProjection[];
|
|
17
24
|
transform: ({ context, webhook, variant }: TransformWebhookArgs) => void;
|
|
18
25
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
19
26
|
isSupported?: (args: IsSupportedWebhookArgs) => boolean;
|
|
@@ -29,6 +36,8 @@ export type ToWebhookConfigArgs<EnrichmentType = undefined> = {
|
|
|
29
36
|
export type WebhookEntry<EnrichmentType = undefined> = {
|
|
30
37
|
id: string;
|
|
31
38
|
type: 'webhook';
|
|
39
|
+
/** The projection classes the entry declared; absent when it declared none. See {@link DeclaredProjection}. */
|
|
40
|
+
projections?: readonly DeclaredProjection[];
|
|
32
41
|
transform: ({ context, webhook, variant }: TransformWebhookArgs) => void;
|
|
33
42
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
34
43
|
isSupported: (args: IsSupportedWebhookArgs) => boolean;
|
|
@@ -59,4 +68,4 @@ export type WebhookEntry<EnrichmentType = undefined> = {
|
|
|
59
68
|
* });
|
|
60
69
|
* ```
|
|
61
70
|
*/
|
|
62
|
-
export declare const toWebhookEntry: <EnrichmentType = undefined>({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }: ToWebhookConfigArgs<EnrichmentType>) => WebhookEntry<EnrichmentType>;
|
|
71
|
+
export declare const toWebhookEntry: <EnrichmentType = undefined>({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }: ToWebhookConfigArgs<EnrichmentType>) => WebhookEntry<EnrichmentType>;
|
|
@@ -23,10 +23,11 @@ exports.toWebhookEntry = void 0;
|
|
|
23
23
|
* });
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
const toWebhookEntry = ({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
26
|
+
const toWebhookEntry = ({ id, projections, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }) => {
|
|
27
27
|
return {
|
|
28
28
|
id,
|
|
29
29
|
type: 'webhook',
|
|
30
|
+
projections,
|
|
30
31
|
transform,
|
|
31
32
|
toEnrichmentSchema,
|
|
32
33
|
isSupported: isSupported ?? (() => true),
|
package/script/mod.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ export * from './dsl/IdentifierType.js';
|
|
|
92
92
|
export * from './dsl/Inserted.js';
|
|
93
93
|
export * from './dsl/model/ModelDriver.js';
|
|
94
94
|
export * from './dsl/model/toModelProjectionBase.js';
|
|
95
|
+
export type * from './dsl/DeclaredProjection.js';
|
|
95
96
|
export * from './dsl/model/toModelEntry.js';
|
|
96
97
|
export * from './dsl/model/types.js';
|
|
97
98
|
export * from './dsl/operation/oas/OasOperationDriver.js';
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Attribution (gen-maps) **emission** config.
|
|
3
3
|
*
|
|
4
|
-
* Attribution *capture* is always on and needs no configuration
|
|
5
|
-
* intrinsic to the pipeline:
|
|
4
|
+
* Attribution *location capture* is always on and needs no configuration:
|
|
6
5
|
*
|
|
7
6
|
* - **Parse phase**: every parsed OAS / GQL node snapshots the visitor's
|
|
8
7
|
* `StackTrail` into its `OasBase` base (`toLocation()` → JSON Pointer).
|
|
9
|
-
* - **Generate phase**: every `SnippetBase`
|
|
10
|
-
* `toString` to capture parent/child edges
|
|
11
|
-
*
|
|
8
|
+
* - **Generate phase**: in a run with `postPass`, every `SnippetBase`
|
|
9
|
+
* instance wraps its `toString` to capture parent/child edges, so the
|
|
10
|
+
* post-render span resolver can attribute byte ranges to producers. A
|
|
11
|
+
* run with no `postPass` installs no wrapper.
|
|
12
12
|
*
|
|
13
13
|
* This type configures only **emission**: it is supplied at the run level
|
|
14
14
|
* (`CoreContext.toArtifacts`) and consumed solely by the post-render
|
|
15
|
-
* pass. The parse and generate contexts do not carry it
|
|
16
|
-
*
|
|
17
|
-
* on-disk output; setting
|
|
18
|
-
* `
|
|
15
|
+
* pass. The parse and generate contexts do not carry it; the generate
|
|
16
|
+
* context only knows whether the run has a capture channel. Without
|
|
17
|
+
* `postPass` you get location capture but no on-disk output; setting
|
|
18
|
+
* `postPass` activates the pass and surfaces `sidecars` /
|
|
19
|
+
* `generationMap` on the result.
|
|
19
20
|
*/
|
|
20
21
|
import type { ParserAdapter } from '../anchors/ParserAdapter.js';
|
|
21
22
|
import type { GeneratorMetaLookup } from '../anchors/postPass.js';
|
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Attribution (gen-maps) **emission** config.
|
|
4
4
|
*
|
|
5
|
-
* Attribution *capture* is always on and needs no configuration
|
|
6
|
-
* intrinsic to the pipeline:
|
|
5
|
+
* Attribution *location capture* is always on and needs no configuration:
|
|
7
6
|
*
|
|
8
7
|
* - **Parse phase**: every parsed OAS / GQL node snapshots the visitor's
|
|
9
8
|
* `StackTrail` into its `OasBase` base (`toLocation()` → JSON Pointer).
|
|
10
|
-
* - **Generate phase**: every `SnippetBase`
|
|
11
|
-
* `toString` to capture parent/child edges
|
|
12
|
-
*
|
|
9
|
+
* - **Generate phase**: in a run with `postPass`, every `SnippetBase`
|
|
10
|
+
* instance wraps its `toString` to capture parent/child edges, so the
|
|
11
|
+
* post-render span resolver can attribute byte ranges to producers. A
|
|
12
|
+
* run with no `postPass` installs no wrapper.
|
|
13
13
|
*
|
|
14
14
|
* This type configures only **emission**: it is supplied at the run level
|
|
15
15
|
* (`CoreContext.toArtifacts`) and consumed solely by the post-render
|
|
16
|
-
* pass. The parse and generate contexts do not carry it
|
|
17
|
-
*
|
|
18
|
-
* on-disk output; setting
|
|
19
|
-
* `
|
|
16
|
+
* pass. The parse and generate contexts do not carry it; the generate
|
|
17
|
+
* context only knows whether the run has a capture channel. Without
|
|
18
|
+
* `postPass` you get location capture but no on-disk output; setting
|
|
19
|
+
* `postPass` activates the pass and surfaces `sidecars` /
|
|
20
|
+
* `generationMap` on the result.
|
|
20
21
|
*/
|
|
21
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|