@hatua/sdk 0.0.0 → 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 +21 -0
- package/README.md +28 -2
- package/dist/expression.test.d.ts +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +22 -0
- package/dist/load.d.ts +22 -0
- package/package.json +25 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pedro Gomes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @hatua/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Hatua SDK for Node backends and workflow runners: the contract plus the
|
|
4
|
+
shared expression evaluator.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
A Host that runs Workflow Definitions written in `@hatua/react` needs to
|
|
7
|
+
parse and validate the same YAML, resolve the same `{{ … }}` Expressions
|
|
8
|
+
against a Run Context, and load Manifests the same way the designer does. This
|
|
9
|
+
package is that half of the contract, published so a runner never has to
|
|
10
|
+
reimplement the expression language against its own reading of the format —
|
|
11
|
+
a runner that evaluates an Expression differently from the builder produces a
|
|
12
|
+
workflow that looks correct in the editor and does the wrong thing in
|
|
13
|
+
production.
|
|
14
|
+
|
|
15
|
+
`@hatua/sdk` has no UI and no dependency on React. `@hatua/react` is the
|
|
16
|
+
designer a Host embeds in a browser; this package is what runs on the backend
|
|
17
|
+
that stores and executes what the designer produces.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install @hatua/sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## The other `@hatua/*` packages
|
|
26
|
+
|
|
27
|
+
`@hatua/document`, `@hatua/expressions`, `@hatua/layout`, `@hatua/log`,
|
|
28
|
+
`@hatua/model`, `@hatua/schema` and `@hatua/services` are also on npm, but
|
|
29
|
+
only because `@hatua/react`'s build treats them as externals rather than
|
|
30
|
+
bundling them. They are implementation details, not a supported API —
|
|
31
|
+
nobody installs `@hatua/model` directly and expects a contract.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Hatua SDK for Node backends and workflow runners.
|
|
3
|
+
*
|
|
4
|
+
* This exists mainly so no Host has to reimplement the expression language. A
|
|
5
|
+
* runner that evaluates `{{ … }}` differently from the builder produces the
|
|
6
|
+
* worst possible failure: a workflow that looks correct in the editor and does
|
|
7
|
+
* the wrong thing in production. One evaluator, shared, removes that.
|
|
8
|
+
*
|
|
9
|
+
* It re-exports the contract rather than duplicating it, so a runner validates
|
|
10
|
+
* with exactly the code the builder validated with — and the same is now true
|
|
11
|
+
* of evaluation: `@hatua/expressions` is the one implementation, and
|
|
12
|
+
* `hatua.dev/go/expressions` is its Go counterpart, kept honest by
|
|
13
|
+
* conformance/expression/.
|
|
14
|
+
*/
|
|
15
|
+
export { type CheckContext, coreFunctions, type Diagnostic, type DiagnosticCode, type EvaluationContext, ExpressionError, type FunctionImpl, type FunctionRegistry, hostFunctions, isReference, mergeRegistries, type OnMissing, parseTemplate, resolve, resolveAll, type ScopeEntry, type Severity, type Slot, sourceReference, type TypeNode, type Value, type ValueType, validate, } from '@hatua/expressions';
|
|
16
|
+
export { type Board, type BoardId, boardScope, boards, callSlots, cyclicBlocks, findStep, REPEAT_VERB, repeatSlot, returnSlots, SET_VAR_VERB, type StepRef, scopeFor, setVarSlot, slotsFor, stepKey, upstreamOf, variableOn, variableSlot, variableType, varsOn, walkDocument, walkSteps, whenSlot, } from '@hatua/model';
|
|
17
|
+
export * from '@hatua/schema';
|
|
18
|
+
export { loadDefinition, loadExecution, loadManifests, loadRunContext } from './load';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ExpressionError as e, coreFunctions as t, hostFunctions as n, isReference as r, mergeRegistries as i, parseTemplate as a, resolve as o, resolveAll as s, sourceReference as c, validate as l } from "@hatua/expressions";
|
|
2
|
+
import { REPEAT_VERB as u, SET_VAR_VERB as d, boardScope as f, boards as p, callSlots as m, cyclicBlocks as h, findStep as g, repeatSlot as _, returnSlots as v, scopeFor as y, setVarSlot as b, slotsFor as x, stepKey as S, upstreamOf as C, variableOn as w, variableSlot as T, variableType as E, varsOn as D, walkDocument as O, walkSteps as k, whenSlot as A } from "@hatua/model";
|
|
3
|
+
import { componentManifest as j, runContextManifest as M, workflowDefinition as N, workflowExecution as P } from "@hatua/schema";
|
|
4
|
+
import { parse as F } from "yaml";
|
|
5
|
+
export * from "@hatua/schema";
|
|
6
|
+
//#region src/load.ts
|
|
7
|
+
function I(e, t, n) {
|
|
8
|
+
let r = t.safeParse(F(e));
|
|
9
|
+
if (!r.success || r.data === void 0) {
|
|
10
|
+
let e = r.error?.issues[0], t = e?.path.length ? ` at ${e.path.join(".")}` : "";
|
|
11
|
+
throw Error(`Not a valid ${n}${t}: ${e?.message ?? "unknown error"}`);
|
|
12
|
+
}
|
|
13
|
+
return r.data;
|
|
14
|
+
}
|
|
15
|
+
var L = (e) => I(e, N, "Workflow Definition"), R = (e) => I(e, P, "Workflow Execution");
|
|
16
|
+
function z(e) {
|
|
17
|
+
let t = I(e, j, "Component Manifest");
|
|
18
|
+
return "components" in t ? t.components : [t];
|
|
19
|
+
}
|
|
20
|
+
var B = (e) => I(e, M, "Run Context Manifest");
|
|
21
|
+
//#endregion
|
|
22
|
+
export { e as ExpressionError, u as REPEAT_VERB, d as SET_VAR_VERB, f as boardScope, p as boards, m as callSlots, t as coreFunctions, h as cyclicBlocks, g as findStep, n as hostFunctions, r as isReference, L as loadDefinition, R as loadExecution, z as loadManifests, B as loadRunContext, i as mergeRegistries, a as parseTemplate, _ as repeatSlot, o as resolve, s as resolveAll, v as returnSlots, y as scopeFor, b as setVarSlot, x as slotsFor, c as sourceReference, S as stepKey, C as upstreamOf, l as validate, w as variableOn, T as variableSlot, E as variableType, D as varsOn, O as walkDocument, k as walkSteps, A as whenSlot };
|
package/dist/load.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Manifest, RunContextManifest, WorkflowDefinition, WorkflowExecution } from '@hatua/schema';
|
|
2
|
+
export declare const loadDefinition: (yaml: string) => WorkflowDefinition;
|
|
3
|
+
export declare const loadExecution: (yaml: string) => WorkflowExecution;
|
|
4
|
+
/**
|
|
5
|
+
* Accepts a single manifest or a `components:` catalogue, always returning a
|
|
6
|
+
* FLAT list. The return type is deliberately `Manifest[]` rather than the
|
|
7
|
+
* parse-time union: leaving the catalogue variant in the type forces every
|
|
8
|
+
* consumer to narrow, and a consumer that narrows by dropping — rather than
|
|
9
|
+
* flattening — silently loses every component in the catalogue.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadManifests(yaml: string): Manifest[];
|
|
12
|
+
/**
|
|
13
|
+
* Parse a Run Context Manifest: the ambient values the Host supplies to every
|
|
14
|
+
* execution, addressed as `run.<k>`.
|
|
15
|
+
*
|
|
16
|
+
* No catalogue variant to unwrap, unlike `loadManifests`. There is exactly one
|
|
17
|
+
* Run Context per execution, so the file declares keys directly and a second
|
|
18
|
+
* declaration is a mistake rather than a longer list — which is also what keeps
|
|
19
|
+
* this return type a single object instead of an array nobody would know how to
|
|
20
|
+
* merge.
|
|
21
|
+
*/
|
|
22
|
+
export declare const loadRunContext: (yaml: string) => RunContextManifest;
|
package/package.json
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatua/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Hatua SDK for Node backends and workflow runners — the contract plus the shared expression evaluator",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "git+https://github.com/pedromvgomes/hatua.git",
|
|
9
10
|
"directory": "source/sdk/js"
|
|
10
11
|
},
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
11
22
|
"publishConfig": {
|
|
12
23
|
"access": "public"
|
|
13
24
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"yaml": "^2.8.1",
|
|
27
|
+
"@hatua/model": "0.1.0",
|
|
28
|
+
"@hatua/expressions": "0.1.0",
|
|
29
|
+
"@hatua/schema": "0.1.0"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "vite build",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"test:coverage": "vitest run --coverage --coverage.reporter=text-summary --coverage.reporter=json-summary --coverage.reporter=lcovonly"
|
|
36
|
+
}
|
|
17
37
|
}
|