@diagonal-hq/workflows 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ Copyright (c) 2026 Diagonal Software Corp. All rights reserved.
2
+
3
+ This software is the proprietary property of Diagonal Software Corp. ("Diagonal"). It is
4
+ licensed, not sold.
5
+
6
+ Diagonal grants you a limited, non-exclusive, non-transferable, revocable
7
+ license to install and use this software only to develop, check, build, and
8
+ deploy workspaces for the Diagonal platform, in accordance with your agreement
9
+ with Diagonal.
10
+
11
+ You may not:
12
+
13
+ - modify, adapt, translate, or create derivative works of this software;
14
+ - copy, distribute, sublicense, sell, or otherwise make this software available
15
+ to any third party, except as an unmodified dependency of a Diagonal
16
+ workspace;
17
+ - use this software with any service other than the Diagonal platform;
18
+ - remove or change this notice.
19
+
20
+ This license ends automatically when you stop using the Diagonal platform or
21
+ when you breach its terms.
22
+
23
+ THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
25
+ FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL DIAGONAL BE
26
+ LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27
+ CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE
28
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
1
+ # `@diagonal-hq/workflows`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ This package is the authoring API of Diagonal managed workflows. A workflow module imports it to declare its handler and to call the host capabilities. The package is ESM JavaScript with declarations. It has no dependencies. It does not depend on `@diagonal-hq/pages`, `@diagonal-hq/cli`, or React.
4
+
5
+ ## Entry points
6
+
7
+ | Entry point | Used by | Exports |
8
+ | --------------------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9
+ | `@diagonal-hq/workflows` | Workflows | `defineWorkflow`, `respond`, `redirect`, `fail`, `validationError`, the input schema builder `v`, `transaction`, `data`, `mail`, `notification`, `sms`, and the generated capability wrappers |
10
+ | `@diagonal-hq/workflows/test` | E2E setup and assert scripts | The helpers that call no host capability: `fail`, `validationError`, `HostError`, `WorkflowFailure`, and `v` |
11
+ | `@diagonal-hq/workflows/migration` | Data migration scripts | The same helpers as `/test` |
12
+ | `@diagonal-hq/workflows/testing` | Local workflow tests in Node | `MockTransport`, `runWorkflow`, and `fake` |
13
+ | `@diagonal-hq/workflows/http` | Local runs against a real workspace | `HttpTransport` |
14
+
15
+ A profile entry point (`/test` or `/migration`) exports a capability only when its profile allows that capability. The capability sets of the profiles are not decided yet, so both entry points export only the helpers above. The compiler and the script host do not enforce the profiles yet.
16
+
17
+ Only `/testing` imports Node built-in modules (`node:async_hooks` and `node:crypto`). The other entry points need no Node API.
18
+
19
+ ## Run a workflow in a test
20
+
21
+ ```ts
22
+ import { MockTransport, runWorkflow } from '@diagonal-hq/workflows/testing';
23
+
24
+ import welcomeMember from './welcome-member';
25
+
26
+ const transport = new MockTransport({ 'mail.send': () => ({ success: true }) });
27
+ const output = await runWorkflow(welcomeMember, {}, { transport });
28
+ ```
29
+
30
+ `runWorkflow` sends each capability call to the transport of its own run. Overlapping and nested runs do not share transports. A call with no mock handler fails with `capability_denied`.
31
+
32
+ ## Source in the platform repository
33
+
34
+ `src/` is the same SDK source that the workflow script compiler embeds and that the QuickJS runtime bundles. Existing workspace modules import it as `@diagonal/workflow`. `php artisan workflows:script-sdk:build` regenerates `generated/capabilities.json` and `src/generated/capabilities.ts`. Do not hand-edit them.
35
+
36
+ `bin/diagonal-workflow.mjs` runs only from a platform checkout, so the package does not publish it. See `app/workflows/README.md`.
37
+
38
+ ## Build the package
39
+
40
+ `npm run build:workflows-package` (`scripts/build-workflows-package.mjs`) writes `dist/` and packs `scripts/dist/npm/diagonal-hq-workflows-<version>.tgz`. esbuild writes one ESM file for each entry point, and the entry points share chunks, so the root entry and `/testing` use one transport slot. TypeScript writes the declarations next to them. `npm run generate-typescript` runs the script.
41
+
42
+ `node scripts/smoke-workflows-package.mjs [tarball]` installs the packed tarball in a consumer outside the repository. It checks the packed file list and the manifest, imports each entry point in Node, runs a workflow through `/testing`, and runs `tsc` against the packed declarations. The `generated-assets` job of PR CI runs it.
43
+
44
+ ## Publish the package
45
+
46
+ The `Publish npm package` workflow (`.github/workflows/publish-npm-package.yml`) publishes the package to npm. It runs only from `main`.
47
+
48
+ 1. Set `version` in `package.json` to a version that npm does not have. A version with a prerelease part, such as `0.2.0-next.1`, gets the `next` tag. Other versions get `latest`.
49
+ 2. Merge the change to `main`.
50
+ 3. Run the workflow from the Actions tab and select `workflows`.
51
+
52
+ npm must list `Diagonal-HQ/diagonal`, the `publish-npm-package.yml` workflow, and the `npm-publish` environment as the trusted publisher of `@diagonal-hq/workflows`.
@@ -0,0 +1,94 @@
1
+ import {
2
+ coerceInput
3
+ } from "./chunk-RTCHH3JG.js";
4
+ import {
5
+ validationError
6
+ } from "./chunk-OF5QITP7.js";
7
+
8
+ // packages/workflows/src/transport.ts
9
+ var active = null;
10
+ function setTransport(transport) {
11
+ active = transport;
12
+ }
13
+ function invoke(name, input) {
14
+ if (active === null) {
15
+ return Promise.reject(
16
+ new Error(
17
+ "No Diagonal host transport is set. In tests, call setTransport(new MockTransport(...))."
18
+ )
19
+ );
20
+ }
21
+ return active.call(name, input);
22
+ }
23
+
24
+ // packages/workflows/src/workflow.ts
25
+ function parseWorkflowInput(workflow, input) {
26
+ return workflow.input === void 0 ? input : coerceInput(workflow.input, input);
27
+ }
28
+ async function validateWorkflowInput(validator, input, ctx) {
29
+ const reported = await validator(input, ctx);
30
+ if (reported === void 0 || reported === null) {
31
+ return;
32
+ }
33
+ if (typeof reported !== "object" || Array.isArray(reported)) {
34
+ throw new TypeError(
35
+ "validateInput must return an object of errors keyed by field, or nothing."
36
+ );
37
+ }
38
+ const errors = {};
39
+ for (const [field, messages] of Object.entries(reported)) {
40
+ const list = (Array.isArray(messages) ? messages : [messages]).filter(
41
+ (message) => typeof message === "string" && message !== ""
42
+ );
43
+ if (list.length > 0) {
44
+ errors[field] = list;
45
+ }
46
+ }
47
+ if (Object.keys(errors).length > 0) {
48
+ validationError(errors);
49
+ }
50
+ }
51
+ function defineWorkflow(inputOrHandler, maybeHandler) {
52
+ if (typeof inputOrHandler === "function") {
53
+ return { $diagonal: "workflow", run: async (input, ctx) => inputOrHandler(input, ctx) };
54
+ }
55
+ const spec = inputOrHandler.$spec;
56
+ const handler = maybeHandler;
57
+ if (handler === void 0) {
58
+ throw new TypeError("defineWorkflow(input, handler) needs a handler after the input schema.");
59
+ }
60
+ return {
61
+ $diagonal: "workflow",
62
+ input: spec,
63
+ run: async (input, ctx) => handler(input, ctx)
64
+ };
65
+ }
66
+ function respond(body, options = {}) {
67
+ return {
68
+ $response_status: options.status ?? 200,
69
+ $response_body: body,
70
+ $response_content_type: options.contentType ?? "application/json"
71
+ };
72
+ }
73
+ function redirect(url, options = {}) {
74
+ const type = options.type ?? (/^\/(?![/\\])/.test(url) ? "internal" : "external");
75
+ const output = {
76
+ redirect_url: url,
77
+ redirect_type: type,
78
+ permanent: type !== "back" && options.permanent === true
79
+ };
80
+ if (options.success !== void 0) {
81
+ output.success = options.success;
82
+ }
83
+ return output;
84
+ }
85
+
86
+ export {
87
+ setTransport,
88
+ invoke,
89
+ parseWorkflowInput,
90
+ validateWorkflowInput,
91
+ defineWorkflow,
92
+ respond,
93
+ redirect
94
+ };
File without changes
@@ -0,0 +1,42 @@
1
+ // packages/workflows/src/errors.ts
2
+ var HostError = class extends Error {
3
+ /**
4
+ * @param failureId The host's ID for the failure of the call. When the error ends the run, the
5
+ * host records that failure, so a run records the failure of the call that it rethrows.
6
+ */
7
+ constructor(message, code, status, details, failureId = null) {
8
+ super(message);
9
+ this.code = code;
10
+ this.status = status;
11
+ this.details = details;
12
+ this.failureId = failureId;
13
+ this.name = "HostError";
14
+ }
15
+ code;
16
+ status;
17
+ details;
18
+ failureId;
19
+ };
20
+ var WorkflowFailure = class extends Error {
21
+ constructor(message, status, details = null) {
22
+ super(message);
23
+ this.status = status;
24
+ this.details = details;
25
+ this.name = "WorkflowFailure";
26
+ }
27
+ status;
28
+ details;
29
+ };
30
+ function fail(message, options = {}) {
31
+ throw new WorkflowFailure(message, options.status ?? 400, options.details ?? null);
32
+ }
33
+ function validationError(errors, options = {}) {
34
+ throw new WorkflowFailure(options.message ?? "The given data was invalid.", 422, { errors });
35
+ }
36
+
37
+ export {
38
+ HostError,
39
+ WorkflowFailure,
40
+ fail,
41
+ validationError
42
+ };
@@ -0,0 +1,150 @@
1
+ // packages/workflows/src/input.ts
2
+ var InputField = class _InputField {
3
+ constructor($spec) {
4
+ this.$spec = $spec;
5
+ }
6
+ $spec;
7
+ /** The key may be absent. */
8
+ optional() {
9
+ return new _InputField({ ...this.$spec, optional: true });
10
+ }
11
+ /** The value may be `null`. */
12
+ nullable() {
13
+ return new _InputField({ ...this.$spec, nullable: true });
14
+ }
15
+ /** At least `value`: a number's value, a text's length, or a list's item count. */
16
+ min(value) {
17
+ return this.rule(`min:${value}`);
18
+ }
19
+ /** At most `value`: a number's value, a text's length, or a list's item count. */
20
+ max(value) {
21
+ return this.rule(`max:${value}`);
22
+ }
23
+ /** Between `min` and `max`, inclusive, measured as for `min` and `max`. */
24
+ between(min, max) {
25
+ return this.rule(`between:${min},${max}`);
26
+ }
27
+ /** Exactly `value`, measured as for `min` and `max`. */
28
+ size(value) {
29
+ return this.rule(`size:${value}`);
30
+ }
31
+ /** The text matches the pattern. */
32
+ regex(pattern) {
33
+ return this.rule(`regex:/${pattern.source}/${pattern.flags}`);
34
+ }
35
+ /** Any other platform validation rule, such as `starts_with:INV-` or `after:today`. */
36
+ rule(rule) {
37
+ return new _InputField({ ...this.$spec, rules: [...this.$spec.rules, rule] });
38
+ }
39
+ label(label) {
40
+ return new _InputField({ ...this.$spec, label });
41
+ }
42
+ description(description) {
43
+ return new _InputField({ ...this.$spec, description });
44
+ }
45
+ };
46
+ var InputSchema = class extends InputField {
47
+ constructor(shape) {
48
+ super(objectSpec(shape));
49
+ this.shape = shape;
50
+ }
51
+ shape;
52
+ };
53
+ function objectSpec(shape) {
54
+ return {
55
+ kind: "object",
56
+ optional: false,
57
+ nullable: false,
58
+ rules: [],
59
+ fields: Object.fromEntries(Object.entries(shape).map(([key, field2]) => [key, field2.$spec]))
60
+ };
61
+ }
62
+ var field = (kind, extra = {}) => new InputField({ kind, optional: false, nullable: false, rules: [], ...extra });
63
+ var v = {
64
+ text: () => field("text"),
65
+ email: () => field("email"),
66
+ url: () => field("url"),
67
+ uuid: () => field("uuid"),
68
+ phone: () => field("phone"),
69
+ /** A calendar date, `YYYY-MM-DD`. */
70
+ date: () => field("date"),
71
+ /** A date and time, ISO 8601. */
72
+ datetime: () => field("datetime"),
73
+ /** A time of day, `HH:MM`. */
74
+ time: () => field("time"),
75
+ timezone: () => field("timezone"),
76
+ color: () => field("color"),
77
+ number: () => field("number"),
78
+ integer: () => field("integer"),
79
+ /** An amount of money: `amount` in the currency's minor units, such as cents, and the lowercase ISO 4217 `currency`. */
80
+ money: () => field("money"),
81
+ boolean: () => field("boolean"),
82
+ /** One of `options`. */
83
+ select: (options) => field("select", { options }),
84
+ /** A list whose items each satisfy `items`. */
85
+ list: (items) => field("list", { items: items.$spec }),
86
+ /** An object with the given fields. */
87
+ object: (shape) => new InputSchema(shape),
88
+ /**
89
+ * The field values of a record of `resource`, checked against that resource's field
90
+ * definitions: types, required fields, and each field's own rules.
91
+ */
92
+ record: (resource) => field("record", { resource }),
93
+ /** The ID of an existing record of `resource`, in `scope`. */
94
+ recordReference: (resource, options = {}) => field("recordReference", { resource, ...options }),
95
+ /** The ID of an existing role. */
96
+ roleReference: () => field("roleReference"),
97
+ /**
98
+ * A file: the ID of an existing file, or the temporary path of an upload. A data call that
99
+ * writes the value to a file field of a record finalizes the upload.
100
+ */
101
+ file: (options = {}) => field("file", options),
102
+ /** A rich text document with the formatting that `options` allows. */
103
+ content: (options = {}) => field("content", Object.keys(options).length === 0 ? {} : { content: options })
104
+ };
105
+ var NUMERIC = /^-?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i;
106
+ function coerceNumber(value) {
107
+ return typeof value === "string" && NUMERIC.test(value.trim()) ? Number(value) : value;
108
+ }
109
+ function coerceInput(spec, value) {
110
+ if (value === null || value === void 0) {
111
+ return value;
112
+ }
113
+ switch (spec.kind) {
114
+ case "number":
115
+ case "integer":
116
+ return coerceNumber(value);
117
+ case "money":
118
+ return typeof value === "object" && !Array.isArray(value) && "amount" in value ? { ...value, amount: coerceNumber(value.amount) } : value;
119
+ case "boolean":
120
+ if (value === "true" || value === "1" || value === 1) {
121
+ return true;
122
+ }
123
+ return value === "false" || value === "0" || value === 0 ? false : value;
124
+ case "select":
125
+ return typeof value === "string" && !spec.options?.includes(value) && spec.options?.includes(Number(value)) ? Number(value) : value;
126
+ case "list":
127
+ return Array.isArray(value) && spec.items ? value.map((item) => coerceInput(spec.items, item)) : value;
128
+ case "object": {
129
+ if (typeof value !== "object" || Array.isArray(value) || !spec.fields) {
130
+ return value;
131
+ }
132
+ const result = { ...value };
133
+ for (const [key, fieldSpec] of Object.entries(spec.fields)) {
134
+ if (key in result) {
135
+ result[key] = coerceInput(fieldSpec, result[key]);
136
+ }
137
+ }
138
+ return result;
139
+ }
140
+ default:
141
+ return value;
142
+ }
143
+ }
144
+
145
+ export {
146
+ InputField,
147
+ InputSchema,
148
+ v,
149
+ coerceInput
150
+ };
@@ -0,0 +1,10 @@
1
+ declare global {
2
+ interface Console {
3
+ log(...values: unknown[]): void;
4
+ info(...values: unknown[]): void;
5
+ warn(...values: unknown[]): void;
6
+ error(...values: unknown[]): void;
7
+ }
8
+ var console: Console;
9
+ }
10
+ export {};
package/dist/data.d.ts ADDED
@@ -0,0 +1,114 @@
1
+ import { type DataCountInput, type DataCreateInput, type DataCreateManyInput, type DataDeleteInput, type DataDeleteManyInput, type DataDeleteManyOutput, type DataFindInput, type DataFindOrCreateInput, type DataRestoreInput, type DataSearchInput, type DataSearchOutput, type DataUpdateInput, type DataUpdateOrCreateInput } from './generated/capabilities';
2
+ import type { WorkspaceResources } from './index';
3
+ type Entry = WorkspaceResources[keyof WorkspaceResources];
4
+ export type ResourceKey = [keyof WorkspaceResources] extends [never] ? string : Entry extends {
5
+ id: infer I;
6
+ } ? I : never;
7
+ type EntryFor<R> = Extract<Entry, {
8
+ id: R;
9
+ }>;
10
+ export type InputOf<R> = [EntryFor<R>] extends [never] ? Record<string, unknown> : EntryFor<R> extends {
11
+ input: infer I;
12
+ } ? I : never;
13
+ export type RecordOf<R> = [EntryFor<R>] extends [never] ? {
14
+ id: string;
15
+ } & Record<string, unknown> : EntryFor<R> extends {
16
+ record: infer T;
17
+ } ? T : never;
18
+ /** The declared keys of `T`. `keyof` on a type with an index signature returns only `string | number`. */
19
+ type DeclaredKey<T> = keyof {
20
+ [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
21
+ };
22
+ /**
23
+ * `DataSearchOutput` with `data` narrowed to the resource's record shape and `cursor` narrowed to
24
+ * the cursor text. `pagination` stays as generated.
25
+ */
26
+ type SearchOutput<R> = Pick<DataSearchOutput, Exclude<DeclaredKey<DataSearchOutput>, 'data' | 'cursor'>> & {
27
+ data?: Array<RecordOf<R>>;
28
+ /** With `paging: 'cursor'`, the `after` value for the next page. Null when no records are left. */
29
+ cursor?: string | null;
30
+ [key: string]: unknown;
31
+ };
32
+ type EachInput<R> = Omit<DataSearchInput, 'resource' | 'page' | 'pageSize' | 'paging' | 'after'> & {
33
+ resource: R;
34
+ /** Stop after this many records. Leave it out to visit every match. */
35
+ maxRecords?: number;
36
+ };
37
+ /**
38
+ * Visit every record that the search matches, one record at a time, with cursor paging. The
39
+ * query is copied when `each` is called, so a change to the input object during the walk does
40
+ * not change the pages.
41
+ *
42
+ * Each page continues after the last record of the page before it. A record that the loop body
43
+ * updates so that it no longer matches, or deletes, does not move a later page. A body that
44
+ * changes the value of a `sort` field can move a visited record after the cursor, and the walk
45
+ * then visits it again. Sort on a field that the body does not change, or leave `sort` empty.
46
+ */
47
+ declare function each<R extends ResourceKey>(input: EachInput<R>): AsyncGenerator<RecordOf<R>, void, undefined>;
48
+ export declare const data: {
49
+ create: <R extends ResourceKey>(input: Omit<DataCreateInput, "resource" | "data"> & {
50
+ resource: R;
51
+ data: InputOf<R>;
52
+ }) => Promise<{
53
+ id: string;
54
+ } & Record<string, unknown>>;
55
+ find: <R extends ResourceKey>(input: Omit<DataFindInput, "resource"> & {
56
+ resource: R;
57
+ }) => Promise<{
58
+ id: string;
59
+ } & Record<string, unknown>>;
60
+ update: <R extends ResourceKey>(input: Omit<DataUpdateInput, "resource" | "data"> & {
61
+ resource: R;
62
+ data: InputOf<R>;
63
+ }) => Promise<{
64
+ id: string;
65
+ } & Record<string, unknown>>;
66
+ search: <R extends ResourceKey>(input: Omit<DataSearchInput, "resource"> & {
67
+ resource: R;
68
+ }) => Promise<SearchOutput<R>>;
69
+ each: typeof each;
70
+ delete: <R extends ResourceKey>(input: Omit<DataDeleteInput, "resource"> & {
71
+ resource: R;
72
+ }) => Promise<{
73
+ id: string;
74
+ } & Record<string, unknown>>;
75
+ restore: <R extends ResourceKey>(input: Omit<DataRestoreInput, "resource"> & {
76
+ resource: R;
77
+ }) => Promise<{
78
+ id: string;
79
+ } & Record<string, unknown>>;
80
+ count: <R extends ResourceKey>(input: Omit<DataCountInput, "resource"> & {
81
+ resource: R;
82
+ }) => Promise<number>;
83
+ findOrCreate: <R extends ResourceKey>(input: Omit<DataFindOrCreateInput, "resource"> & {
84
+ resource: R;
85
+ }) => Promise<{
86
+ id: string;
87
+ } & Record<string, unknown>>;
88
+ updateOrCreate: <R extends ResourceKey>(input: Omit<DataUpdateOrCreateInput, "resource"> & {
89
+ resource: R;
90
+ }) => Promise<{
91
+ id: string;
92
+ } & Record<string, unknown>>;
93
+ createMany: <R extends ResourceKey>(input: Omit<DataCreateManyInput, "resource" | "records"> & {
94
+ resource: R;
95
+ records: Array<InputOf<R>>;
96
+ }) => Promise<({
97
+ id: string;
98
+ } & Record<string, unknown>)[]>;
99
+ deleteMany: <R extends ResourceKey>(input: Omit<DataDeleteManyInput, "resource"> & {
100
+ resource: R;
101
+ }) => Promise<DataDeleteManyOutput>;
102
+ aggregateMetrics: (input: import("./index").DataAggregateMetricsInput) => Promise<import("./index").DataAggregateMetricsOutput>;
103
+ relation: {
104
+ attach: (input: import("./index").DataRelationAttachInput) => Promise<import("./index").DataRelationAttachOutput>;
105
+ attachMany: (input: import("./index").DataRelationAttachManyInput) => Promise<import("./index").DataRelationAttachManyOutput>;
106
+ detach: (input: import("./index").DataRelationDetachInput) => Promise<import("./index").DataRelationDetachOutput>;
107
+ detachMany: (input: import("./index").DataRelationDetachManyInput) => Promise<import("./index").DataRelationDetachManyOutput>;
108
+ sync: (input: import("./index").DataRelationSyncInput) => Promise<import("./index").DataRelationSyncOutput>;
109
+ };
110
+ semanticSearch: (input: import("./index").DataSemanticSearchInput) => Promise<import("./index").DataSemanticSearchOutput>;
111
+ sum: (input: import("./index").DataSumInput) => Promise<import("./index").DataSumOutput>;
112
+ validate: (input: import("./index").DataValidateInput) => Promise<import("./index").DataValidateOutput>;
113
+ };
114
+ export {};
@@ -0,0 +1,23 @@
1
+ export declare class HostError extends Error {
2
+ readonly code: string;
3
+ readonly status: number;
4
+ readonly details: unknown;
5
+ readonly failureId: number | null;
6
+ /**
7
+ * @param failureId The host's ID for the failure of the call. When the error ends the run, the
8
+ * host records that failure, so a run records the failure of the call that it rethrows.
9
+ */
10
+ constructor(message: string, code: string, status: number, details: unknown, failureId?: number | null);
11
+ }
12
+ export declare class WorkflowFailure extends Error {
13
+ readonly status: number;
14
+ readonly details: unknown;
15
+ constructor(message: string, status: number, details?: unknown);
16
+ }
17
+ export declare function fail(message: string, options?: {
18
+ status?: number;
19
+ details?: unknown;
20
+ }): never;
21
+ export declare function validationError(errors: Record<string, string[]>, options?: {
22
+ message?: string;
23
+ }): never;