@boboddy/sdk 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import type { ZodType } from "zod";
2
- import type { SignalKeysOf, SignalTypeMapOf, TypedStepDefinitionSpec } from "./define-step";
2
+ import type { EffectiveResult, SignalKeysOf, SignalTypeMapOf, TypedStepDefinitionSpec } from "./define-step";
3
+ import type { AnyStepFeature, FeatureSignalKeys } from "./step-features";
3
4
  /**
4
5
  * `codeStep()`'s own signal spec shape — unlike `defineStep()`'s
5
6
  * `SignalSpecInput`, `type` is required rather than inferred from the
@@ -17,7 +18,7 @@ export type CodeStepSignalSpec = {
17
18
  availableWhenResultStatusIn?: string[] | null;
18
19
  };
19
20
  export type CodeStepFn<TInput, TResult> = (input: TInput) => TResult | Promise<TResult>;
20
- export type DefineCodeStepInput<TInput extends ZodType = ZodType, TResult extends ZodType = ZodType> = {
21
+ export type DefineCodeStepInput<TInput extends ZodType = ZodType, TResult extends ZodType = ZodType, TFeatures extends ReadonlyArray<AnyStepFeature> = never[]> = {
21
22
  key: string;
22
23
  name: string;
23
24
  description?: string | null;
@@ -30,11 +31,22 @@ export type DefineCodeStepInput<TInput extends ZodType = ZodType, TResult extend
30
31
  * Must be a plain named export of the same module `codeStep()` is
31
32
  * called from (see docs/research/flat-pipeline-sdk-and-visual-designer.md
32
33
  * §7.7/§8's "code-step entrypoints resolve against the target repo").
34
+ *
35
+ * Typed against `EffectiveResult`, not the bare `resultSchema` output, so
36
+ * a step with `features: [Features.notifications()]` can return the
37
+ * `$boboddy_notifications_v1` field (e.g. via `Notify.inApp(...)`)
38
+ * without a type error.
33
39
  */
34
- fn: CodeStepFn<TInput["_output"], TResult["_output"]>;
40
+ fn: CodeStepFn<TInput["_output"], EffectiveResult<TResult["_output"], TFeatures>>;
35
41
  inputSchema?: TInput;
36
42
  resultSchema?: TResult;
37
43
  signals?: readonly CodeStepSignalSpec[];
44
+ /**
45
+ * Step features to attach — unlike `defineStep()`, only each feature's
46
+ * `_resultExtension`/`_signals` apply here (there is no prompt to append
47
+ * to on a `kind: "code"` step).
48
+ */
49
+ features?: TFeatures;
38
50
  status?: "draft" | "active";
39
51
  };
40
52
  /**
@@ -45,6 +57,6 @@ export type DefineCodeStepInput<TInput extends ZodType = ZodType, TResult extend
45
57
  * `entrypoint.fn` reference attached instead — see `StepDefinitionSpec`'s
46
58
  * own doc comment for what happens to it during collection.
47
59
  */
48
- export declare function codeStep<TInput extends ZodType = ZodType, TResult extends ZodType = ZodType, const TSignals extends ReadonlyArray<CodeStepSignalSpec> = never[]>(config: DefineCodeStepInput<TInput, TResult> & {
60
+ export declare function codeStep<TInput extends ZodType = ZodType, TResult extends ZodType = ZodType, const TSignals extends ReadonlyArray<CodeStepSignalSpec> = never[], const TFeatures extends ReadonlyArray<AnyStepFeature> = never[]>(config: DefineCodeStepInput<TInput, TResult, TFeatures> & {
49
61
  signals?: TSignals;
50
- }): TypedStepDefinitionSpec<TInput["_output"], TResult["_output"], SignalKeysOf<TSignals>, SignalTypeMapOf<TSignals, TResult["_output"]>>;
62
+ }): TypedStepDefinitionSpec<TInput["_output"], EffectiveResult<TResult["_output"], TFeatures>, SignalKeysOf<TSignals> | FeatureSignalKeys<TFeatures>, SignalTypeMapOf<TSignals, TResult["_output"]>>;
@@ -159,7 +159,7 @@ export type SignalTypeMapOf<TSignals extends readonly unknown[], TResult> = Pret
159
159
  sourcePath: infer P extends string;
160
160
  } ? TypeAtPath<TResult, P> : unknown;
161
161
  }>;
162
- type EffectiveResult<TResult, TFeatures extends ReadonlyArray<AnyStepFeature>> = Prettify<TResult & FeatureResultExtensions<TFeatures>>;
162
+ export type EffectiveResult<TResult, TFeatures extends ReadonlyArray<AnyStepFeature>> = Prettify<TResult & FeatureResultExtensions<TFeatures>>;
163
163
  type HasAdditionalInput<T> = 0 extends 1 & T ? boolean : [unknown] extends [T] ? false : true;
164
164
  export type TypedStepDefinitionSpec<TInput = unknown, TResult = unknown, TSignalKeys extends string = string, TSignalTypeMap extends Partial<Record<string, unknown>> = Record<string, unknown>> = StepDefinitionSpec & {
165
165
  readonly __inputType: TInput;