@diagonal-hq/workflows 0.9.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.
- package/dist/chunks/{chunk-2ZP6OJZZ.js → chunk-GDVUCCNR.js} +3 -3
- package/dist/generated/capabilities.d.ts +11 -13
- package/dist/index.js +1 -1
- package/dist/profiles/test.js +1 -1
- package/dist/workflow-config.d.ts +4 -4
- package/dist/workflow.d.ts +27 -10
- package/dist/workspace-values.d.ts +2 -2
- package/package.json +1 -1
|
@@ -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),
|
|
@@ -334,7 +334,7 @@ var text = {
|
|
|
334
334
|
/** Hash a text value */
|
|
335
335
|
hash: (input) => invoke("text.hash", input),
|
|
336
336
|
/** Generate a random UUID v7 */
|
|
337
|
-
randomUuid: (input) => invoke("text.random_uuid", input),
|
|
337
|
+
randomUuid: (input = {}) => invoke("text.random_uuid", input),
|
|
338
338
|
/** Convert a plain text string into rich Content */
|
|
339
339
|
toContent: (input) => invoke("text.to_content", input)
|
|
340
340
|
};
|
|
@@ -404,7 +404,7 @@ var workspace = {
|
|
|
404
404
|
/** Get the value of a field in a workspace */
|
|
405
405
|
value: (input) => invoke("workspace.value", input),
|
|
406
406
|
/** Get all workspace field values as a dictionary */
|
|
407
|
-
values: (input) => invoke("workspace.values", input)
|
|
407
|
+
values: (input = {}) => invoke("workspace.values", input)
|
|
408
408
|
};
|
|
409
409
|
|
|
410
410
|
// packages/workflows/src/data.ts
|
|
@@ -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": {
|
|
@@ -964,6 +964,8 @@ export interface NumberFormatInput {
|
|
|
964
964
|
}
|
|
965
965
|
export type NumberFormatOutput = string;
|
|
966
966
|
export interface PackageInstallInputInput {
|
|
967
|
+
package_id: string;
|
|
968
|
+
key: string;
|
|
967
969
|
}
|
|
968
970
|
export type PackageInstallInputOutput = unknown;
|
|
969
971
|
export interface PageUrlInput {
|
|
@@ -1811,8 +1813,7 @@ export interface TextHashInput {
|
|
|
1811
1813
|
value: string;
|
|
1812
1814
|
}
|
|
1813
1815
|
export type TextHashOutput = string;
|
|
1814
|
-
export
|
|
1815
|
-
}
|
|
1816
|
+
export type TextRandomUuidInput = Record<string, never>;
|
|
1816
1817
|
export type TextRandomUuidOutput = string;
|
|
1817
1818
|
export interface TextToContentInput {
|
|
1818
1819
|
value: string;
|
|
@@ -1870,11 +1871,9 @@ export interface TiptapParseInput {
|
|
|
1870
1871
|
placeholder?: string;
|
|
1871
1872
|
}
|
|
1872
1873
|
export type TiptapParseOutput = unknown;
|
|
1873
|
-
export
|
|
1874
|
-
}
|
|
1874
|
+
export type TransactionBeginInput = Record<string, never>;
|
|
1875
1875
|
export type TransactionBeginOutput = null;
|
|
1876
|
-
export
|
|
1877
|
-
}
|
|
1876
|
+
export type TransactionCommitInput = Record<string, never>;
|
|
1878
1877
|
export type TransactionCommitOutput = null;
|
|
1879
1878
|
export interface TransactionRollbackInput {
|
|
1880
1879
|
error?: {
|
|
@@ -2097,8 +2096,7 @@ export interface WorkspaceValueInput {
|
|
|
2097
2096
|
defaultValue?: unknown;
|
|
2098
2097
|
}
|
|
2099
2098
|
export type WorkspaceValueOutput = unknown;
|
|
2100
|
-
export
|
|
2101
|
-
}
|
|
2099
|
+
export type WorkspaceValuesInput = Record<string, never>;
|
|
2102
2100
|
export type WorkspaceValuesOutput = Record<string, unknown>;
|
|
2103
2101
|
export declare const ai: {
|
|
2104
2102
|
/** Ask a decisions model typed questions about some content and get labelled answers with their probabilities */
|
|
@@ -2337,7 +2335,7 @@ export declare const text: {
|
|
|
2337
2335
|
/** Hash a text value */
|
|
2338
2336
|
hash: (input: TextHashInput) => Promise<TextHashOutput>;
|
|
2339
2337
|
/** Generate a random UUID v7 */
|
|
2340
|
-
randomUuid: (input
|
|
2338
|
+
randomUuid: (input?: TextRandomUuidInput) => Promise<TextRandomUuidOutput>;
|
|
2341
2339
|
/** Convert a plain text string into rich Content */
|
|
2342
2340
|
toContent: (input: TextToContentInput) => Promise<TextToContentOutput>;
|
|
2343
2341
|
};
|
|
@@ -2367,9 +2365,9 @@ export declare const tiptap: {
|
|
|
2367
2365
|
};
|
|
2368
2366
|
export declare const transaction: {
|
|
2369
2367
|
/** Transaction control for transaction(). */
|
|
2370
|
-
begin: (input
|
|
2368
|
+
begin: (input?: TransactionBeginInput) => Promise<TransactionBeginOutput>;
|
|
2371
2369
|
/** Transaction control for transaction(). */
|
|
2372
|
-
commit: (input
|
|
2370
|
+
commit: (input?: TransactionCommitInput) => Promise<TransactionCommitOutput>;
|
|
2373
2371
|
/** Transaction control for transaction(). */
|
|
2374
2372
|
rollback: (input: TransactionRollbackInput) => Promise<TransactionRollbackOutput>;
|
|
2375
2373
|
};
|
|
@@ -2415,5 +2413,5 @@ export declare const workspace: {
|
|
|
2415
2413
|
/** Get the value of a field in a workspace */
|
|
2416
2414
|
value: (input: WorkspaceValueInput) => Promise<WorkspaceValueOutput>;
|
|
2417
2415
|
/** Get all workspace field values as a dictionary */
|
|
2418
|
-
values: (input
|
|
2416
|
+
values: (input?: WorkspaceValuesInput) => Promise<WorkspaceValuesOutput>;
|
|
2419
2417
|
};
|
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type WorkspaceSystemFields } from "./generated/capabilities.js";
|
|
1
|
+
import { type WorkspaceSystemFields, type WorkspaceValuesInput } from "./generated/capabilities.js";
|
|
2
2
|
import type { WorkspaceFieldCatalog } from "./index.js";
|
|
3
3
|
type Fields = Omit<WorkspaceSystemFields, keyof WorkspaceFieldCatalog> & WorkspaceFieldCatalog;
|
|
4
4
|
type Property<T, K extends string> = T extends null | undefined ? never : T extends readonly (infer Item)[] ? K extends `${number}` ? K extends keyof T ? T[K] : Item : unknown : T extends object ? K extends keyof T ? T[K] : unknown : unknown;
|
|
@@ -27,7 +27,7 @@ export declare const workspace: {
|
|
|
27
27
|
key: K;
|
|
28
28
|
value?: WriteValue<NoInfer<K>>;
|
|
29
29
|
}) => Promise<WriteValue<K>>;
|
|
30
|
-
values: (input?:
|
|
30
|
+
values: (input?: WorkspaceValuesInput) => Promise<WorkspaceValues>;
|
|
31
31
|
setValues: <V extends Record<string, unknown> = Record<never, never>>(input: {
|
|
32
32
|
values?: V & WrittenValues<NoInfer<V>>;
|
|
33
33
|
}) => Promise<WrittenValues<V>>;
|
package/package.json
CHANGED