@diagonal-hq/workflows 0.10.0 → 0.10.1
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.
|
@@ -97,7 +97,7 @@ function isFailure(value2) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// packages/workflows/src/generated/capabilities.ts
|
|
100
|
-
var SDK_VERSION =
|
|
100
|
+
var SDK_VERSION = 77;
|
|
101
101
|
var ai = {
|
|
102
102
|
/** Ask a decisions model typed questions about some content and get labelled answers with their probabilities */
|
|
103
103
|
decide: (input) => invoke("ai.decide", input),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ResourceKeyWith } from "../data.js";
|
|
2
2
|
import type { ContentDocument } from "../input.js";
|
|
3
3
|
import type { DeepReadonly, Liquid, StaticLiquid } from "../liquid.js";
|
|
4
|
-
export declare const SDK_VERSION =
|
|
4
|
+
export declare const SDK_VERSION = 77;
|
|
5
5
|
export interface WorkspaceSystemFields {
|
|
6
6
|
"ai_custom_system_prompt": string | null;
|
|
7
7
|
"brand_kit": {
|
package/dist/index.js
CHANGED
package/dist/profiles/test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The options of `defineWorkflow(config, handler)` other than `input` and `validate`.
|
|
3
|
-
* reads them as static data, checks them, and removes them from the compiled script, so
|
|
4
|
-
* compiler sees only `input` and `validate`. `@diagonal-hq/cli` replaces this
|
|
5
|
-
* `WorkflowConfig`, so the editor checks each option.
|
|
2
|
+
* The options of `defineWorkflow(config, handler)` other than `input`, `output`, and `validate`.
|
|
3
|
+
* The build reads them as static data, checks them, and removes them from the compiled script, so
|
|
4
|
+
* the compiler sees only `input`, `output`, and `validate`. `@diagonal-hq/cli` replaces this
|
|
5
|
+
* declaration with its `WorkflowConfig`, so the editor checks each option.
|
|
6
6
|
*/
|
|
7
7
|
export type WorkflowConfig = Record<never, never>;
|
package/dist/workflow.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ResourceKeyWith } from "./data.js";
|
|
2
2
|
import type { ScriptHostContext } from "./index.js";
|
|
3
|
-
import { InputSchema, type InferInput, type InputFieldSpec, type InputShape } from "./input.js";
|
|
3
|
+
import { type Infer, type InputField, InputSchema, type InferInput, type InputFieldSpec, type InputShape } from "./input.js";
|
|
4
4
|
import type { WorkflowConfig } from "./workflow-config.js";
|
|
5
5
|
export interface Identity {
|
|
6
6
|
id: string;
|
|
@@ -90,23 +90,40 @@ export type InputValidator<I> = (input: I, ctx: WorkflowContext) => InputErrors<
|
|
|
90
90
|
/** Runs a script's input validator and ends the run with a validation error when it reports one. */
|
|
91
91
|
export declare function validateWorkflowInput<I>(validator: InputValidator<I>, input: I, ctx: WorkflowContext): Promise<void>;
|
|
92
92
|
type Handler<I, O> = (input: I, ctx: WorkflowContext) => Promise<O> | O;
|
|
93
|
+
/** A declared output: any `v` field, usually `v.object({ ... })`. */
|
|
94
|
+
type OutputField = InputField<unknown, boolean>;
|
|
95
|
+
/** The handler input of a config: the type of its `input` schema, or `I` without one. */
|
|
96
|
+
type ConfigInput<C, I> = C extends InputSchema<infer S> ? InferInput<S> : I;
|
|
97
|
+
/**
|
|
98
|
+
* A value of a declared output type that a handler may return. A const context makes a returned
|
|
99
|
+
* array a readonly tuple, so arrays and objects may be readonly at every level.
|
|
100
|
+
*/
|
|
101
|
+
type Returnable<T> = T extends readonly (infer E)[] ? readonly Returnable<E>[] : T extends object ? {
|
|
102
|
+
readonly [K in keyof T]: Returnable<T[K]>;
|
|
103
|
+
} : T;
|
|
104
|
+
/** The handler result of a config: the type of its `output` schema, or `O` without one. */
|
|
105
|
+
type ConfigOutput<F, O> = F extends OutputField ? Infer<F> : O;
|
|
93
106
|
/**
|
|
94
107
|
* Declares a workflow. A file-based workflow passes its config first, as `definePage` does. The
|
|
95
108
|
* build reads the config as static data. With an `input` schema in the config, or a schema first,
|
|
96
109
|
* the platform validates every run's input against it before the script starts, and the handler's
|
|
97
110
|
* `input` type comes from the schema. A `validate` function in the config runs after that check
|
|
98
|
-
* and before the handler, with the same input type.
|
|
111
|
+
* and before the handler, with the same input type. With an `output` schema in the config of a
|
|
112
|
+
* file-based workflow, the handler must return a value of that type: the platform documents it as
|
|
113
|
+
* the response of a Request workflow and verifies each return value against it.
|
|
99
114
|
*/
|
|
100
|
-
export declare function defineWorkflow<
|
|
101
|
-
readonly input
|
|
102
|
-
readonly
|
|
103
|
-
|
|
115
|
+
export declare function defineWorkflow<const O, C extends InputSchema<InputShape> | undefined = undefined, I = Record<string, unknown>>(config: WorkflowConfig & {
|
|
116
|
+
readonly input?: C;
|
|
117
|
+
readonly output: InputField<O, boolean>;
|
|
118
|
+
readonly validate?: InputValidator<ConfigInput<C, I>>;
|
|
119
|
+
}, handler: Handler<ConfigInput<C, I>, Returnable<NoInfer<O>>>): WorkflowDefinition<ConfigInput<C, I>, O>;
|
|
104
120
|
export declare function defineWorkflow<S extends InputShape, O = unknown>(input: InputSchema<S>, handler: Handler<InferInput<S>, O>): WorkflowDefinition<InferInput<S>, O>;
|
|
105
|
-
export declare function defineWorkflow<I = Record<string, unknown>, O = unknown>(config: WorkflowConfig & {
|
|
106
|
-
readonly input?: undefined;
|
|
107
|
-
readonly validate?: InputValidator<I>;
|
|
108
|
-
}, handler: Handler<I, O>): WorkflowDefinition<I, O>;
|
|
109
121
|
export declare function defineWorkflow<I = Record<string, unknown>, O = unknown>(handler: Handler<I, O>): WorkflowDefinition<I, O>;
|
|
122
|
+
export declare function defineWorkflow<I = Record<string, unknown>, O = unknown, C extends InputSchema<InputShape> | undefined = undefined, F extends OutputField | undefined = undefined>(config: WorkflowConfig & {
|
|
123
|
+
readonly input?: C;
|
|
124
|
+
readonly output?: F;
|
|
125
|
+
readonly validate?: InputValidator<ConfigInput<C, I>>;
|
|
126
|
+
}, handler: Handler<ConfigInput<C, I>, ConfigOutput<F, O>>): WorkflowDefinition<ConfigInput<C, I>, ConfigOutput<F, O>>;
|
|
110
127
|
export type ResponseOutput = {
|
|
111
128
|
$response_status: number;
|
|
112
129
|
$response_body: unknown;
|
package/package.json
CHANGED