@zapier/kitcore 0.10.1 → 0.12.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/CHANGELOG.md +27 -0
- package/README.md +63 -5
- package/dist/index.cjs +486 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +252 -26
- package/dist/index.d.ts +252 -26
- package/dist/index.mjs +484 -98
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -8,9 +8,33 @@ declare module "zod" {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* The response `meta` sidecar, shared by both output modes: an item method's
|
|
13
|
+
* `{ data, meta }` envelope and a list method's page carry the same shape, so a
|
|
14
|
+
* caller reads a framework report the same way regardless of the mode it came
|
|
15
|
+
* from.
|
|
16
|
+
*
|
|
17
|
+
* Every member is optional and framework-owned. A method's `run` returns `data`;
|
|
18
|
+
* the boundary attaches what belongs here.
|
|
19
|
+
*/
|
|
20
|
+
interface ResponseMeta {
|
|
21
|
+
/**
|
|
22
|
+
* What output validation's strip removed from the response, present only when
|
|
23
|
+
* the head enables the `includeOutputValidationDroppedPaths` core option AND
|
|
24
|
+
* something was actually dropped. Paths are relative to `data` in both modes
|
|
25
|
+
* (`a.b` for an item), with array elements collapsed to one `[]` segment and
|
|
26
|
+
* unioned (`[].b` on a page, `items[].b` for an array inside an item), matching
|
|
27
|
+
* connectors' format.
|
|
28
|
+
*/
|
|
29
|
+
outputValidation?: {
|
|
30
|
+
droppedPaths: string[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
11
34
|
/**
|
|
12
35
|
* Pagination shapes used by the plugin framework.
|
|
13
36
|
*/
|
|
37
|
+
|
|
14
38
|
/**
|
|
15
39
|
* Single page of a paginated SDK list result. Returned from the page-level
|
|
16
40
|
* promise and yielded from the page-level async iterable.
|
|
@@ -18,6 +42,10 @@ declare module "zod" {
|
|
|
18
42
|
interface SdkPage<T = unknown> {
|
|
19
43
|
data: T[];
|
|
20
44
|
nextCursor?: string;
|
|
45
|
+
/** Additive per-page framework sidecar, the same shape an item method's
|
|
46
|
+
* envelope carries. Framework-set, not something a handler or `adaptPage`
|
|
47
|
+
* returns. See {@link ResponseMeta}. */
|
|
48
|
+
meta?: ResponseMeta;
|
|
21
49
|
}
|
|
22
50
|
/**
|
|
23
51
|
* Return type of every paginated SDK method. The documented surface is:
|
|
@@ -78,26 +106,67 @@ type PaginatedSdkFunction<TOptions, TItem> = (options: TOptions) => PaginatedSdk
|
|
|
78
106
|
* unforgeability the `INTERNAL_CALL` sentinel relies on.
|
|
79
107
|
*/
|
|
80
108
|
declare const CALL_CONTEXT_BRAND: unique symbol;
|
|
109
|
+
/**
|
|
110
|
+
* The per-invocation annotation bag: an open string-keyed map a head fills with
|
|
111
|
+
* telemetry-shaping fields (via the boundary annotator, a method's pre-run
|
|
112
|
+
* `annotator`, or the run bag's mid-`run` `annotate`) and reads back on the
|
|
113
|
+
* method-lifecycle hook context. Framework-neutral: kitcore does not know or
|
|
114
|
+
* constrain the keys.
|
|
115
|
+
*/
|
|
116
|
+
type Annotations = Record<string, unknown>;
|
|
117
|
+
/**
|
|
118
|
+
* Origin of a call's root. `"surface"` = entered through the SDK surface, or a
|
|
119
|
+
* parent-less runtime delegation that still represents real user work;
|
|
120
|
+
* `"internal"` = a framework-internal root minted by kitcore's own machinery,
|
|
121
|
+
* which a head can suppress from telemetry.
|
|
122
|
+
*/
|
|
123
|
+
type CallOrigin = "surface" | "internal";
|
|
81
124
|
interface CallContext {
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Minted once at the root call; copied verbatim to every nested (child) call.
|
|
127
|
+
* `readonly`: method code owns only the `annotations` bag. A child copies this
|
|
128
|
+
* off the live parent when the delegated call fires, so mutating it mid-run
|
|
129
|
+
* would corrupt the child's correlation id.
|
|
130
|
+
*/
|
|
131
|
+
readonly callId: string | null;
|
|
132
|
+
/**
|
|
133
|
+
* 0 at the outermost call; `parent.depth + 1` for a delegated call. `readonly`
|
|
134
|
+
* for the same reason as `callId` — a mutated depth would mis-nest children
|
|
135
|
+
* and, where ALS can't correct it (browsers), duplicate telemetry.
|
|
136
|
+
*/
|
|
137
|
+
readonly depth: number;
|
|
86
138
|
/**
|
|
87
139
|
* Per-invocation scratch space. Never forwarded to callees — a child call
|
|
88
140
|
* gets a fresh bag — so annotations describe one method's own invocation.
|
|
141
|
+
* Method `run` code contributes through the run bag's `annotate` function
|
|
142
|
+
* rather than writing here directly; the bag reference is fixed, only its
|
|
143
|
+
* contents change.
|
|
144
|
+
*/
|
|
145
|
+
readonly annotations: Annotations;
|
|
146
|
+
/**
|
|
147
|
+
* Origin of the call's root, copied verbatim to every child. `"surface"`
|
|
148
|
+
* (the default) marks a surface-origin root — a call that entered through the
|
|
149
|
+
* SDK surface, or a parent-less runtime delegation that still represents real
|
|
150
|
+
* user work (e.g. a delegation proxy reaching another method). `"internal"`
|
|
151
|
+
* marks a framework-internal root minted by kitcore's own build-time machinery
|
|
152
|
+
* (resolver/formatter/dispose/observer twins, `resolvePlugin`), which a head
|
|
153
|
+
* can suppress from telemetry. Orthogonal to `depth`: an internal root is
|
|
154
|
+
* still `depth 0`. `readonly` so a child can't inherit a mutated origin.
|
|
89
155
|
*/
|
|
90
|
-
|
|
156
|
+
readonly callOrigin: CallOrigin;
|
|
91
157
|
readonly [CALL_CONTEXT_BRAND]: true;
|
|
92
158
|
}
|
|
93
159
|
|
|
94
160
|
/**
|
|
95
161
|
* Method-call lifecycle hooks. Plugins contribute `onMethodStart` and/or
|
|
96
|
-
* `onMethodEnd`
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
162
|
+
* `onMethodEnd` observers, plus an optional pre-run `annotator` that returns
|
|
163
|
+
* fields merged into the call's annotation bag; `buildHooks` composes each
|
|
164
|
+
* across plugins so multiple contributors coexist. Composition is right-additive
|
|
165
|
+
* (newer plugins fire — and `annotator` fields win — after earlier ones); only
|
|
166
|
+
* opt-in methods built through `createPluginMethod` /
|
|
167
|
+
* `createPaginatedPluginMethod` trigger the hooks.
|
|
100
168
|
*/
|
|
169
|
+
|
|
101
170
|
interface OnMethodStartContext {
|
|
102
171
|
methodName: string;
|
|
103
172
|
args: unknown[];
|
|
@@ -109,20 +178,48 @@ interface OnMethodStartContext {
|
|
|
109
178
|
* top-level events.
|
|
110
179
|
*/
|
|
111
180
|
depth: number;
|
|
181
|
+
/** The call's correlation id, copied from the per-call context; `null` where
|
|
182
|
+
* id minting was unavailable. */
|
|
183
|
+
callId: string | null;
|
|
184
|
+
/**
|
|
185
|
+
* Origin of the call's root, copied from the per-call context. `"surface"` =
|
|
186
|
+
* surface-origin (an SDK-surface call or a runtime delegation — real user
|
|
187
|
+
* work); `"internal"` = a framework-internal call minted by kitcore's own
|
|
188
|
+
* machinery (resolver/formatter/dispose/observer twins, `resolvePlugin`).
|
|
189
|
+
* Orthogonal to `depth` (an internal call is still `depth 0`); a head can drop
|
|
190
|
+
* internal-origin calls from telemetry.
|
|
191
|
+
*/
|
|
192
|
+
callOrigin: CallOrigin;
|
|
193
|
+
/**
|
|
194
|
+
* The call's annotation bag, carried live from the per-call context. At
|
|
195
|
+
* `onMethodStart` it holds the early-knowable fields (boundary annotator +
|
|
196
|
+
* a method's pre-run `annotator`); by `onMethodEnd` any mid-`run` writes
|
|
197
|
+
* are visible too (same object reference throughout the call).
|
|
198
|
+
*/
|
|
199
|
+
annotations: Annotations;
|
|
112
200
|
}
|
|
113
201
|
type OnMethodStart = (ctx: OnMethodStartContext) => void;
|
|
114
|
-
interface OnMethodEndContext {
|
|
115
|
-
methodName: string;
|
|
116
|
-
args: unknown[];
|
|
117
|
-
isPaginated: boolean;
|
|
118
|
-
depth: number;
|
|
202
|
+
interface OnMethodEndContext extends OnMethodStartContext {
|
|
119
203
|
durationMs: number;
|
|
120
204
|
error?: Error;
|
|
121
205
|
}
|
|
122
206
|
type OnMethodEnd = (ctx: OnMethodEndContext) => void;
|
|
207
|
+
/**
|
|
208
|
+
* A composed pre-run annotator: given a call's method name and (normalized,
|
|
209
|
+
* pre-validation) input, it returns {@link Annotations} the boundary merges into
|
|
210
|
+
* the call's bag before `onMethodStart`. Unlike the `void` lifecycle observers,
|
|
211
|
+
* this one returns a value; composition merges the returned bags rather than
|
|
212
|
+
* chaining side effects. A contributor with nothing to add returns an empty bag,
|
|
213
|
+
* so absence is modelled by no annotator rather than an `undefined` return.
|
|
214
|
+
*/
|
|
215
|
+
type ComposedAnnotator = (ctx: {
|
|
216
|
+
methodName: string;
|
|
217
|
+
input: unknown;
|
|
218
|
+
}) => Annotations;
|
|
123
219
|
interface MethodHooks {
|
|
124
220
|
onMethodStart?: OnMethodStart;
|
|
125
221
|
onMethodEnd?: OnMethodEnd;
|
|
222
|
+
annotator?: ComposedAnnotator;
|
|
126
223
|
}
|
|
127
224
|
|
|
128
225
|
/**
|
|
@@ -435,6 +532,13 @@ interface LeafMetaFields {
|
|
|
435
532
|
itemType?: string;
|
|
436
533
|
returnType?: string;
|
|
437
534
|
outputSchema?: z.ZodSchema;
|
|
535
|
+
/** Behavioral opt-out that rides on this config for every `defineMethod`
|
|
536
|
+
* overload (all merge `LeafMetaFields`), the partner of `outputSchema`: when
|
|
537
|
+
* true, the materializer skips validating/stripping the output. It is
|
|
538
|
+
* consumed at build time and stored as a first-class plugin field, NOT folded
|
|
539
|
+
* into the projected meta (hence absent from `LEAF_META_KEYS`), so it stays
|
|
540
|
+
* off the registry / CLI / MCP surface, exactly like `skipInputValidation`. */
|
|
541
|
+
skipOutputValidation?: boolean;
|
|
438
542
|
packages?: string[];
|
|
439
543
|
experimental?: boolean;
|
|
440
544
|
confirm?: "create-secret" | "delete";
|
|
@@ -536,13 +640,42 @@ type ImportsOf<TImports extends ImportsInput> = TImports extends readonly [] ? R
|
|
|
536
640
|
/**
|
|
537
641
|
* The bag a method body receives. `imports` is the dependency-narrowed reach;
|
|
538
642
|
* `state` is the plugin's private constructor result (undefined when none);
|
|
539
|
-
* `input` is the canonical call argument
|
|
643
|
+
* `input` is the canonical call argument; `callContext` is the live per-call
|
|
644
|
+
* context (call identity plus the annotation bag the boundary reads back on the
|
|
645
|
+
* lifecycle hooks); `annotate` merges mid-run-derived telemetry fields into that
|
|
646
|
+
* bag. Prefer `annotate` over writing `callContext.annotations` directly.
|
|
540
647
|
*/
|
|
541
648
|
interface MethodRunBag<TImports, TInput, TState = unknown> {
|
|
542
649
|
imports: TImports;
|
|
543
650
|
state: TState;
|
|
544
651
|
input: TInput;
|
|
652
|
+
callContext: CallContext;
|
|
653
|
+
/** Merge mid-run-derived telemetry fields into the call's annotation bag. The
|
|
654
|
+
* declarative pre-run sibling is the method's `annotator` config; both add
|
|
655
|
+
* to the same bag, one during `run`, one before it. */
|
|
656
|
+
annotate: (metadata: Annotations) => void;
|
|
545
657
|
}
|
|
658
|
+
/**
|
|
659
|
+
* A method's declarative pre-`run` annotator: given the method's raw,
|
|
660
|
+
* pre-validation `input`, it returns {@link Annotations} the boundary merges
|
|
661
|
+
* into the call's bag before `onMethodStart`. The input is `unknown` because
|
|
662
|
+
* schema coercion/transformation has not run; an annotator must narrow it before
|
|
663
|
+
* reading fields. A provider with nothing to add returns an empty bag, so absence
|
|
664
|
+
* is modelled by no provider rather than an `undefined` return.
|
|
665
|
+
*/
|
|
666
|
+
type MethodAnnotator = (bag: {
|
|
667
|
+
input: unknown;
|
|
668
|
+
}) => Annotations;
|
|
669
|
+
/**
|
|
670
|
+
* A hook's declarative pre-`run` annotator: like {@link MethodAnnotator} but
|
|
671
|
+
* cross-cutting, so it also receives the `methodName` and the hook's `state`.
|
|
672
|
+
* Many hooks' annotators coexist; the boundary composes them.
|
|
673
|
+
*/
|
|
674
|
+
type HookAnnotator<TState = unknown> = (bag: {
|
|
675
|
+
methodName: string;
|
|
676
|
+
input: unknown;
|
|
677
|
+
state: TState;
|
|
678
|
+
}) => Annotations;
|
|
546
679
|
/** Shared plumbing for the method attachments: each declares its own
|
|
547
680
|
* dependencies. Resolvers and formatters are otherwise separate concepts. */
|
|
548
681
|
interface MethodAttachment {
|
|
@@ -910,9 +1043,15 @@ interface MethodPlugin<TName extends string = string, TInput = unknown, TOutput
|
|
|
910
1043
|
/** True for a `declareMethod` stand-in: a typed reference with no real
|
|
911
1044
|
* implementation. A real plugin under the same id satisfies it. */
|
|
912
1045
|
standIn?: boolean;
|
|
913
|
-
/** True for a `
|
|
914
|
-
*
|
|
1046
|
+
/** True for a `declareOptionalMethod` stand-in: dependents bind `undefined` if
|
|
1047
|
+
* no real plugin satisfies it, and `PluginSurface` types the binding
|
|
1048
|
+
* `| undefined`. */
|
|
915
1049
|
optional?: boolean;
|
|
1050
|
+
/** Present on a `declareDefault` wrapper: this entry is the DEFAULT provider
|
|
1051
|
+
* for its id (preempted by any explicit provider). Its value is the wrapped
|
|
1052
|
+
* plugin, so two defaults for one id dedup (same source) or conflict
|
|
1053
|
+
* (different source). */
|
|
1054
|
+
defaultSource?: AnyLeafPlugin;
|
|
916
1055
|
imports: readonly AnyPlugin[];
|
|
917
1056
|
/** Binding-name to plugin-id edges, normalized from `imports`;
|
|
918
1057
|
* what the `imports` bag is built from. */
|
|
@@ -934,6 +1073,10 @@ interface MethodPlugin<TName extends string = string, TInput = unknown, TOutput
|
|
|
934
1073
|
* For raw methods that own their own validation and must not have their input
|
|
935
1074
|
* transformed, e.g. `fetch` passing a `RequestInit` bag through unchanged. */
|
|
936
1075
|
skipInputValidation?: boolean;
|
|
1076
|
+
/** When true, the materializer skips validating/stripping `run`'s output
|
|
1077
|
+
* against `meta.outputSchema` (the schema stays for projection). The output
|
|
1078
|
+
* partner of {@link MethodPlugin.skipInputValidation}. */
|
|
1079
|
+
skipOutputValidation?: boolean;
|
|
937
1080
|
/** Descriptive metadata for the registry / CLI / MCP / docs (carry-only at
|
|
938
1081
|
* runtime). */
|
|
939
1082
|
meta?: LeafMeta;
|
|
@@ -943,6 +1086,14 @@ interface MethodPlugin<TName extends string = string, TInput = unknown, TOutput
|
|
|
943
1086
|
resolvers?: Record<string, Resolver>;
|
|
944
1087
|
/** Output formatter (method attachment). Bound into the entry at createSdk. */
|
|
945
1088
|
formatter?: Formatter;
|
|
1089
|
+
/** Declarative pre-`run` annotator: the boundary invokes it before
|
|
1090
|
+
* `onMethodStart` with the (pre-validation) `input`, and merges its returned
|
|
1091
|
+
* `Annotations` into the call's bag. Runs synchronously and receives only
|
|
1092
|
+
* `input` — the per-method sibling of the run bag's mid-`run` `annotate`,
|
|
1093
|
+
* which is where fields needing imports or async work are written. For
|
|
1094
|
+
* telemetry fields knowable before the method's own work; never passed to
|
|
1095
|
+
* `run`. */
|
|
1096
|
+
annotator?: MethodAnnotator;
|
|
946
1097
|
run: (bag: MethodRunBag<any, TInput, any>) => TOutput;
|
|
947
1098
|
/** How `run`'s result is shaped into the public surface (see Output in the
|
|
948
1099
|
* design doc). Omitted is "raw". Stored loosely; the precise per-mode typing
|
|
@@ -1040,6 +1191,11 @@ interface PropertyPlugin<TName extends string = string, TValue = unknown> {
|
|
|
1040
1191
|
* property satisfies it, dependents bind `undefined` rather than the build
|
|
1041
1192
|
* failing on a missing dependency. */
|
|
1042
1193
|
optional?: boolean;
|
|
1194
|
+
/** Present on a `declareDefault` wrapper: this entry is the DEFAULT provider
|
|
1195
|
+
* for its id (preempted by any explicit provider). Its value is the wrapped
|
|
1196
|
+
* plugin, so two defaults for one id dedup (same source) or conflict
|
|
1197
|
+
* (different source). */
|
|
1198
|
+
defaultSource?: AnyLeafPlugin;
|
|
1043
1199
|
imports: readonly AnyPlugin[];
|
|
1044
1200
|
/** Binding-name to plugin-id edges, normalized from `imports`;
|
|
1045
1201
|
* what the `imports` bag is built from. */
|
|
@@ -1218,6 +1374,9 @@ interface HookPlugin<TName extends string = string> {
|
|
|
1218
1374
|
state: unknown;
|
|
1219
1375
|
}) => void;
|
|
1220
1376
|
};
|
|
1377
|
+
/** Composable pre-run annotator: returns `Annotations` merged into the call's
|
|
1378
|
+
* bag before `onMethodStart`. Coexists with other hooks' annotators. */
|
|
1379
|
+
annotator?: HookAnnotator;
|
|
1221
1380
|
}
|
|
1222
1381
|
type AnyPlugin = AnyLeafPlugin | AnyAggregatePlugin | AnyLegacyPlugin | HookPlugin | MethodOverridePlugin;
|
|
1223
1382
|
/**
|
|
@@ -1263,10 +1422,16 @@ interface MethodEntry {
|
|
|
1263
1422
|
* on legacy graph entries (they bind `value`). */
|
|
1264
1423
|
internalValue?: (input: any) => any;
|
|
1265
1424
|
/** Produce the import-facing twin for a given call context: with a context,
|
|
1266
|
-
* the twin mints a fresh child per invocation (callee inherits `callId`,
|
|
1267
|
-
* one level deeper); without one it is
|
|
1268
|
-
* `
|
|
1269
|
-
|
|
1425
|
+
* the twin mints a fresh child per invocation (callee inherits `callId`, its
|
|
1426
|
+
* origin, and sits one level deeper); without one it is parent-less — the
|
|
1427
|
+
* surface-origin `internalValue` by default, or a framework-internal root when
|
|
1428
|
+
* `frameworkOrigin` is set (kitcore's own build-time passes request it, so
|
|
1429
|
+
* their delegated calls can be dropped from telemetry). `buildImports` binds
|
|
1430
|
+
* this. Absent on legacy graph entries. */
|
|
1431
|
+
bindInternal?: (opts: {
|
|
1432
|
+
ctx?: CallContext;
|
|
1433
|
+
frameworkOrigin?: boolean;
|
|
1434
|
+
}) => (...args: any[]) => any;
|
|
1270
1435
|
chain: MiddlewareWrap[];
|
|
1271
1436
|
/** Carried from the descriptor for the registry / CLI / MCP / docs. */
|
|
1272
1437
|
inputSchema?: z.ZodType;
|
|
@@ -1368,7 +1533,11 @@ type ExportSurface<TChild extends AnyLeafPlugin> = TChild extends MethodPlugin<a
|
|
|
1368
1533
|
* bag and `ProvidesOf` is the completeness ledger's phantom ids — both
|
|
1369
1534
|
* different concepts.
|
|
1370
1535
|
*/
|
|
1371
|
-
type PluginSurface<P extends AnyPlugin> = P extends MethodPlugin<infer TName, infer TInput, infer TOutput, infer TPositional> ? {
|
|
1536
|
+
type PluginSurface<P extends AnyPlugin> = P extends MethodPlugin<infer TName, infer TInput, infer TOutput, infer TPositional> ? P extends {
|
|
1537
|
+
optional: true;
|
|
1538
|
+
} ? {
|
|
1539
|
+
[K in TName]: SurfaceCall<TInput, TOutput, TPositional> | undefined;
|
|
1540
|
+
} : {
|
|
1372
1541
|
[K in TName]: SurfaceCall<TInput, TOutput, TPositional>;
|
|
1373
1542
|
} : P extends PropertyPlugin<infer TName, infer TValue> ? {
|
|
1374
1543
|
[K in TName]: TValue;
|
|
@@ -2077,6 +2246,7 @@ declare function defineMethod<const TName extends string, TInput, TOutput, const
|
|
|
2077
2246
|
skipInputValidation?: boolean;
|
|
2078
2247
|
resolvers?: Record<string, Resolver>;
|
|
2079
2248
|
formatter?: Formatter;
|
|
2249
|
+
annotator?: MethodAnnotator;
|
|
2080
2250
|
output?: "raw" | {
|
|
2081
2251
|
type: "raw";
|
|
2082
2252
|
};
|
|
@@ -2098,6 +2268,7 @@ declare function defineMethod<const TName extends string, TInput, TResponse exte
|
|
|
2098
2268
|
inputSchema?: z.ZodType<TInput>;
|
|
2099
2269
|
resolvers?: Record<string, Resolver>;
|
|
2100
2270
|
formatter?: Formatter;
|
|
2271
|
+
annotator?: MethodAnnotator;
|
|
2101
2272
|
output: "item" | {
|
|
2102
2273
|
type: "item";
|
|
2103
2274
|
};
|
|
@@ -2112,6 +2283,7 @@ declare function defineMethod<const TName extends string, TInput, TResponse exte
|
|
|
2112
2283
|
run: (bag: MethodRunBag<ImportsOf<TImports>, TInput, TState>) => TResponse | Promise<TResponse>;
|
|
2113
2284
|
} & LeafMetaFields): MethodPlugin<TName, TInput, Promise<{
|
|
2114
2285
|
data: TData;
|
|
2286
|
+
meta?: ResponseMeta;
|
|
2115
2287
|
}>> & LeafSummary<TNamespace, TName, TImports>;
|
|
2116
2288
|
declare function defineMethod<const TName extends string, TInput, TResponse extends StrictPage$1<TResponse>, TItem = ItemOf$1<TResponse>, const TImports extends ImportsInput = readonly [], const TNamespace extends string = "", TState = undefined>(config: {
|
|
2117
2289
|
name: TName;
|
|
@@ -2120,6 +2292,7 @@ declare function defineMethod<const TName extends string, TInput, TResponse exte
|
|
|
2120
2292
|
inputSchema?: z.ZodType<TInput>;
|
|
2121
2293
|
resolvers?: Record<string, Resolver>;
|
|
2122
2294
|
formatter?: Formatter;
|
|
2295
|
+
annotator?: MethodAnnotator;
|
|
2123
2296
|
output: "list" | {
|
|
2124
2297
|
type: "list";
|
|
2125
2298
|
adaptPage?: undefined;
|
|
@@ -2142,6 +2315,7 @@ declare function defineMethod<const TName extends string, TInput, TResponse, TIt
|
|
|
2142
2315
|
inputSchema?: z.ZodType<TInput>;
|
|
2143
2316
|
resolvers?: Record<string, Resolver>;
|
|
2144
2317
|
formatter?: Formatter;
|
|
2318
|
+
annotator?: MethodAnnotator;
|
|
2145
2319
|
output: {
|
|
2146
2320
|
type: "list";
|
|
2147
2321
|
adaptPage: (response: TResponse) => SdkPage<TItem>;
|
|
@@ -2331,6 +2505,19 @@ declare function defineFormatter<const TImports extends ImportsInput = readonly
|
|
|
2331
2505
|
declare function declareMethod<const TId extends string, TInput = unknown, TOutput = unknown>(config: {
|
|
2332
2506
|
id: LiteralString<TId>;
|
|
2333
2507
|
}): MethodPlugin<LastSegment<TId>, TInput, TOutput> & PluginSummary<TId, never>;
|
|
2508
|
+
/**
|
|
2509
|
+
* Declare an OPTIONAL stand-in for a method registered elsewhere: the method twin
|
|
2510
|
+
* of `declareOptionalProperty`. Unlike `declareMethod`, an unsatisfied optional
|
|
2511
|
+
* reference is NOT a missing dependency; the binding is typed
|
|
2512
|
+
* `((input) => output) | undefined`, so the consumer must handle the absent case
|
|
2513
|
+
* (`imports.track?.(...)`). Use it to reference a foreign method userland may or
|
|
2514
|
+
* may not import, without claiming its slot.
|
|
2515
|
+
*/
|
|
2516
|
+
declare function declareOptionalMethod<const TId extends string, TInput = unknown, TOutput = unknown>(config: {
|
|
2517
|
+
id: LiteralString<TId>;
|
|
2518
|
+
}): MethodPlugin<LastSegment<TId>, TInput, TOutput> & {
|
|
2519
|
+
optional: true;
|
|
2520
|
+
} & PluginSummary<never, never>;
|
|
2334
2521
|
/**
|
|
2335
2522
|
* Define a property leaf. Either a static `value` or a computed `get` (eager,
|
|
2336
2523
|
* dependencies first, like `setup`). `createSdk`, a dependent's `imports`, or
|
|
@@ -2388,6 +2575,21 @@ declare function declareProperty<const TId extends string, TValue = unknown>(con
|
|
|
2388
2575
|
declare function declareOptionalProperty<const TId extends string, TValue = unknown>(config: {
|
|
2389
2576
|
id: LiteralString<TId>;
|
|
2390
2577
|
}): PropertyPlugin<LastSegment<TId>, TValue | undefined> & PluginSummary<never, never>;
|
|
2578
|
+
/**
|
|
2579
|
+
* Declare a DEFAULT provider for a dependency you own: import the capability the
|
|
2580
|
+
* given plugin provides, and fall back to that plugin when nothing else provides
|
|
2581
|
+
* its id. Kind-agnostic (the plugin supplies id, type, and kind), so no
|
|
2582
|
+
* method/property split.
|
|
2583
|
+
*
|
|
2584
|
+
* A default materializes a real, single node, so it works out of the box and can
|
|
2585
|
+
* be wrapped or replaced: an explicit provider of the same id silently preempts
|
|
2586
|
+
* it, and two different defaults for one id error only when nothing else provides
|
|
2587
|
+
* it. See the Defaults section in the kitcore README for default vs optional
|
|
2588
|
+
* reference.
|
|
2589
|
+
*/
|
|
2590
|
+
declare function declareDefault<P extends AnyLeafPlugin>({ plugin, }: {
|
|
2591
|
+
plugin: P;
|
|
2592
|
+
}): P;
|
|
2391
2593
|
/**
|
|
2392
2594
|
* Define a method-lifecycle hook: a leaf whose `observe` contributes
|
|
2393
2595
|
* fire-and-forget observers (`onMethodStart` / `onMethodEnd`) the method
|
|
@@ -2433,6 +2635,14 @@ declare function defineHook<const TImports extends ImportsInput = readonly [], T
|
|
|
2433
2635
|
state: TState;
|
|
2434
2636
|
}) => void;
|
|
2435
2637
|
};
|
|
2638
|
+
/** Cross-cutting pre-run annotation. The boundary composes hook annotators
|
|
2639
|
+
* right-additively (a later hook's fields win on collision) ahead of the
|
|
2640
|
+
* method's own `annotator`, invokes them best-effort for the outermost
|
|
2641
|
+
* surface-origin call only, and merges their returned `Annotations` into the
|
|
2642
|
+
* call's bag. Synchronous and import-less; fields needing imports or async
|
|
2643
|
+
* work are written mid-`run` via the run bag's `annotate`. Returns a value
|
|
2644
|
+
* (unlike `observe`) and never reaches `run`. */
|
|
2645
|
+
annotator?: HookAnnotator<TState>;
|
|
2436
2646
|
}): HookPlugin;
|
|
2437
2647
|
/**
|
|
2438
2648
|
* Declare a stand-in for a whole aggregate (module) registered elsewhere: the
|
|
@@ -2732,6 +2942,15 @@ interface CoreOptions {
|
|
|
2732
2942
|
* reserved for an `on*`-named observer when the unified event bus lands.
|
|
2733
2943
|
*/
|
|
2734
2944
|
logDeprecation?: (warning: DeprecationWarning) => void;
|
|
2945
|
+
/**
|
|
2946
|
+
* Report what output validation stripped, on the response's
|
|
2947
|
+
* `meta.outputValidation.droppedPaths` (the name mirrors that path). Off by
|
|
2948
|
+
* default: the report is a debugging aid for reconciling a schema against the
|
|
2949
|
+
* wire, and a sidecar every caller has to ignore is worse than one a head
|
|
2950
|
+
* turns on while it audits its schemas. Off also skips the recursive
|
|
2951
|
+
* raw-vs-parsed diff, so the strip costs a parse and nothing more.
|
|
2952
|
+
*/
|
|
2953
|
+
includeOutputValidationDroppedPaths?: boolean;
|
|
2735
2954
|
}
|
|
2736
2955
|
|
|
2737
2956
|
/**
|
|
@@ -3280,6 +3499,10 @@ declare function createFunction<TOptions, TResult, TSchemaOptions extends TOptio
|
|
|
3280
3499
|
sdk: FunctionSdk;
|
|
3281
3500
|
schema?: z.ZodSchema<TSchemaOptions>;
|
|
3282
3501
|
name?: string;
|
|
3502
|
+
/** Pre-run per-method annotator (see applyAnnotations): invoked before
|
|
3503
|
+
* onMethodStart with the normalized input, its result merged into the
|
|
3504
|
+
* call's annotation bag. */
|
|
3505
|
+
annotator?: (input: unknown) => Annotations;
|
|
3283
3506
|
/** Live read of the method's deprecation meta (see signalDeprecation). */
|
|
3284
3507
|
getDeprecation?: () => FunctionDeprecation | undefined;
|
|
3285
3508
|
}): (callOptions?: TOptions) => Promise<TResult>;
|
|
@@ -3316,6 +3539,10 @@ declare function createPaginatedFunction<TUserOptions, TResponse, TItem = ItemTy
|
|
|
3316
3539
|
* would collapse `TItem` to `unknown`.
|
|
3317
3540
|
*/
|
|
3318
3541
|
adaptPage?: (response: TResponse) => SdkPage<NoInfer<TItem>>;
|
|
3542
|
+
/** Pre-run per-method annotator (see applyAnnotations). */
|
|
3543
|
+
annotator?: (input: unknown) => Annotations;
|
|
3544
|
+
/** Applied to each canonical page after the shape guard (output validation). */
|
|
3545
|
+
finalizePage?: (page: SdkPage<TItem>) => SdkPage<TItem>;
|
|
3319
3546
|
/** Live read of the method's deprecation meta (see signalDeprecation). */
|
|
3320
3547
|
getDeprecation?: () => FunctionDeprecation | undefined;
|
|
3321
3548
|
}): (options?: TUserOptions & {
|
|
@@ -3344,9 +3571,8 @@ declare function createCorePlugin(options: CoreOptions): Plugin<object, {
|
|
|
3344
3571
|
* runs in its own AsyncLocalStorage scope (via `runInMethodScope`), isolating
|
|
3345
3572
|
* its depth counter and any plugin-specific state from concurrent calls.
|
|
3346
3573
|
*
|
|
3347
|
-
* The toolkit reserves the `depth` field;
|
|
3348
|
-
*
|
|
3349
|
-
* its `MethodMetadata` under its own key).
|
|
3574
|
+
* The toolkit reserves the `depth` field; additional fields remain available
|
|
3575
|
+
* for plugin-specific scoped state.
|
|
3350
3576
|
*/
|
|
3351
3577
|
/**
|
|
3352
3578
|
* The per-call scope object held in ALS. Toolkit owns `depth`; everything
|
|
@@ -3617,4 +3843,4 @@ declare class CoreCancelledSignal extends CoreSignal {
|
|
|
3617
3843
|
*/
|
|
3618
3844
|
declare function isCoreCancelledSignal(value: unknown): value is CoreCancelledSignal;
|
|
3619
3845
|
|
|
3620
|
-
export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CategoryDefinition, type ConstantResolver$1 as ConstantResolver, type Controller, type ControllerAction, type ControllerAffordance, type ControllerAnswerFn, type ControllerChoice, type ControllerError, type ControllerIssue, type ControllerListingPage, type ControllerListingPosition, type ControllerMethodDescription, type ControllerMethodSummary, type ControllerPagination, type ControllerParameterDescription, type ControllerPath, type ControllerQuestion, type ControllerResult, type ControllerSdk, type ControllerSelectPage, type ControllerState, type CoreApiError, CoreCancelledSignal, CoreDisposeError, CoreError, CoreErrorCode, type CoreErrorOptions, type CoreOptions, CoreSignal, type CreateSdkOptions, type DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, type HookPlugin, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputFormatter, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, type RegistryResult, type RequiredSdkOf, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverType, type Sdk, type SdkContext, type SdkPage, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, canonicalInputSchema, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createValidator, dangerousContextPlugin, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getOutputSchema, getRegistryPlugin, getSchemaDescription, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, validateOptions, withOutputSchema, withPositional, withResolver };
|
|
3846
|
+
export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type Annotations, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CallContext, type CallOrigin, type CategoryDefinition, type ComposedAnnotator, type ConstantResolver$1 as ConstantResolver, type Controller, type ControllerAction, type ControllerAffordance, type ControllerAnswerFn, type ControllerChoice, type ControllerError, type ControllerIssue, type ControllerListingPage, type ControllerListingPosition, type ControllerMethodDescription, type ControllerMethodSummary, type ControllerPagination, type ControllerParameterDescription, type ControllerPath, type ControllerQuestion, type ControllerResult, type ControllerSdk, type ControllerSelectPage, type ControllerState, type CoreApiError, CoreCancelledSignal, CoreDisposeError, CoreError, CoreErrorCode, type CoreErrorOptions, type CoreOptions, CoreSignal, type CreateSdkOptions, type DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, type HookAnnotator, type HookPlugin, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAnnotator, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputFormatter, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, type RegistryResult, type RequiredSdkOf, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverType, type ResponseMeta, type Sdk, type SdkContext, type SdkPage, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, canonicalInputSchema, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createValidator, dangerousContextPlugin, declareDefault, declareMethod, declareOptionalMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getOutputSchema, getRegistryPlugin, getSchemaDescription, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, validateOptions, withOutputSchema, withPositional, withResolver };
|