@lifi/compose-spec 0.0.1-alpha
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 +201 -0
- package/README.md +51 -0
- package/dist/index.cjs +413 -0
- package/dist/index.d.cts +878 -0
- package/dist/index.d.ts +878 -0
- package/dist/index.js +327 -0
- package/package.json +52 -0
- package/src/compile.ts +97 -0
- package/src/constructors.ts +105 -0
- package/src/flow.ts +101 -0
- package/src/flowSchema.ts +105 -0
- package/src/index.ts +133 -0
- package/src/manifest.ts +9 -0
- package/src/materialiserMetadata.ts +24 -0
- package/src/ref.ts +60 -0
- package/src/resource.ts +48 -0
- package/src/zodSchemas.ts +137 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
export const SolTypeSchema = Schema.Literal(
|
|
4
|
+
"uint8",
|
|
5
|
+
"uint16",
|
|
6
|
+
"uint32",
|
|
7
|
+
"uint64",
|
|
8
|
+
"uint128",
|
|
9
|
+
"uint256",
|
|
10
|
+
"int128",
|
|
11
|
+
"int256",
|
|
12
|
+
"address",
|
|
13
|
+
"bool",
|
|
14
|
+
"bytes",
|
|
15
|
+
"bytes4",
|
|
16
|
+
"bytes32",
|
|
17
|
+
"string"
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const ChainIdSchema = Schema.Number.pipe(Schema.int(), Schema.positive());
|
|
21
|
+
|
|
22
|
+
export const ResourceSchema = Schema.Union(
|
|
23
|
+
Schema.Struct({ kind: Schema.Literal("native"), chainId: ChainIdSchema }),
|
|
24
|
+
Schema.Struct({
|
|
25
|
+
kind: Schema.Literal("erc20"),
|
|
26
|
+
token: Schema.String,
|
|
27
|
+
chainId: ChainIdSchema,
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const ResourceInputSchema = Schema.Struct({
|
|
32
|
+
name: Schema.String,
|
|
33
|
+
resource: ResourceSchema,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const HandleInputSchema = Schema.Struct({
|
|
37
|
+
name: Schema.String,
|
|
38
|
+
type: SolTypeSchema,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const FlowInputSchema = Schema.Union(
|
|
42
|
+
ResourceInputSchema,
|
|
43
|
+
HandleInputSchema
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const RefSchema = Schema.Struct({
|
|
47
|
+
$ref: Schema.String.pipe(
|
|
48
|
+
Schema.filter((s) => s.indexOf(".") > 0, {
|
|
49
|
+
message: () =>
|
|
50
|
+
'$ref must be a dotpath like "input.name" or "nodeId.port"',
|
|
51
|
+
})
|
|
52
|
+
),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const LiteralBindingSchema = Schema.Struct({
|
|
56
|
+
kind: SolTypeSchema,
|
|
57
|
+
value: Schema.String,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export const BindValueSchema = Schema.Union(RefSchema, LiteralBindingSchema);
|
|
61
|
+
|
|
62
|
+
export const AppliedGuardSchema = Schema.Struct(
|
|
63
|
+
{ kind: Schema.String },
|
|
64
|
+
{ key: Schema.String, value: Schema.Unknown }
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export const CallSchema = Schema.Struct({
|
|
68
|
+
id: Schema.String,
|
|
69
|
+
op: Schema.String,
|
|
70
|
+
bind: Schema.optionalWith(
|
|
71
|
+
Schema.Record({ key: Schema.String, value: BindValueSchema }),
|
|
72
|
+
{ default: () => ({}) }
|
|
73
|
+
),
|
|
74
|
+
config: Schema.optionalWith(
|
|
75
|
+
Schema.Record({ key: Schema.String, value: Schema.Unknown }),
|
|
76
|
+
{ default: () => ({}) }
|
|
77
|
+
),
|
|
78
|
+
guards: Schema.optional(Schema.Array(AppliedGuardSchema)),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const ContinuationSchema = Schema.Struct({
|
|
82
|
+
awaits: Schema.String,
|
|
83
|
+
flowId: Schema.String,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
export const FlowSchema = Schema.Struct({
|
|
87
|
+
version: Schema.Literal(1),
|
|
88
|
+
id: Schema.String,
|
|
89
|
+
chainId: ChainIdSchema,
|
|
90
|
+
inputs: Schema.Array(FlowInputSchema),
|
|
91
|
+
nodes: Schema.Array(CallSchema),
|
|
92
|
+
continuation: Schema.optional(ContinuationSchema),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export type SolType = typeof SolTypeSchema.Type;
|
|
96
|
+
export type ResourceInput = typeof ResourceInputSchema.Type;
|
|
97
|
+
export type HandleInput = typeof HandleInputSchema.Type;
|
|
98
|
+
export type FlowInput = typeof FlowInputSchema.Type;
|
|
99
|
+
export type Ref = typeof RefSchema.Type;
|
|
100
|
+
export type LiteralBinding = typeof LiteralBindingSchema.Type;
|
|
101
|
+
export type BindValue = typeof BindValueSchema.Type;
|
|
102
|
+
export type AppliedGuard = typeof AppliedGuardSchema.Type;
|
|
103
|
+
export type Call = typeof CallSchema.Type;
|
|
104
|
+
export type Continuation = typeof ContinuationSchema.Type;
|
|
105
|
+
export type Flow = typeof FlowSchema.Type;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
SolType,
|
|
3
|
+
ResourceInput,
|
|
4
|
+
HandleInput,
|
|
5
|
+
FlowInput,
|
|
6
|
+
Ref,
|
|
7
|
+
LiteralBinding,
|
|
8
|
+
BindValue,
|
|
9
|
+
AppliedGuard,
|
|
10
|
+
Call,
|
|
11
|
+
Continuation,
|
|
12
|
+
Flow,
|
|
13
|
+
} from "./flowSchema.js";
|
|
14
|
+
export {
|
|
15
|
+
FlowSchema,
|
|
16
|
+
ResourceSchema,
|
|
17
|
+
SolTypeSchema,
|
|
18
|
+
ResourceInputSchema,
|
|
19
|
+
HandleInputSchema,
|
|
20
|
+
FlowInputSchema,
|
|
21
|
+
RefSchema,
|
|
22
|
+
LiteralBindingSchema,
|
|
23
|
+
BindValueSchema,
|
|
24
|
+
AppliedGuardSchema,
|
|
25
|
+
CallSchema,
|
|
26
|
+
ContinuationSchema,
|
|
27
|
+
} from "./flowSchema.js";
|
|
28
|
+
|
|
29
|
+
export type {
|
|
30
|
+
Port,
|
|
31
|
+
ResourcePort,
|
|
32
|
+
HandlePort,
|
|
33
|
+
OpInputPort,
|
|
34
|
+
ResourceOutputPort,
|
|
35
|
+
OpOutputPort,
|
|
36
|
+
ComposeError,
|
|
37
|
+
ComposeErrorKind,
|
|
38
|
+
MaterialiserInputBase,
|
|
39
|
+
MaterialiserInput,
|
|
40
|
+
MaterialiserInputOf,
|
|
41
|
+
MaterialiserConfigOf,
|
|
42
|
+
InputSpec,
|
|
43
|
+
PreconditionBase,
|
|
44
|
+
Precondition,
|
|
45
|
+
PreconditionOf,
|
|
46
|
+
PreconditionConfigOf,
|
|
47
|
+
} from "./flow.js";
|
|
48
|
+
export {
|
|
49
|
+
isResourceInput,
|
|
50
|
+
flowInputType,
|
|
51
|
+
flowInputMode,
|
|
52
|
+
flowInputResource,
|
|
53
|
+
isResourcePort,
|
|
54
|
+
isHandlePort,
|
|
55
|
+
isResourceOutputPort,
|
|
56
|
+
isMaterialiserInput,
|
|
57
|
+
} from "./flow.js";
|
|
58
|
+
|
|
59
|
+
export type {
|
|
60
|
+
Availability,
|
|
61
|
+
OutputAmount,
|
|
62
|
+
Resource,
|
|
63
|
+
ProducedResource,
|
|
64
|
+
SimulatedAmounts,
|
|
65
|
+
} from "./resource.js";
|
|
66
|
+
export { erc20Token, foldResource, resourceKey } from "./resource.js";
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
linear,
|
|
70
|
+
copy,
|
|
71
|
+
handle,
|
|
72
|
+
native,
|
|
73
|
+
erc20,
|
|
74
|
+
resource,
|
|
75
|
+
readResource,
|
|
76
|
+
opHandle,
|
|
77
|
+
resourceOutput,
|
|
78
|
+
} from "./constructors.js";
|
|
79
|
+
|
|
80
|
+
export type { ParsedRef, RefScope, ContextKey } from "./ref.js";
|
|
81
|
+
export {
|
|
82
|
+
parseRef,
|
|
83
|
+
foldRef,
|
|
84
|
+
refKey,
|
|
85
|
+
isContextKey,
|
|
86
|
+
RESERVED_REF_SCOPES,
|
|
87
|
+
} from "./ref.js";
|
|
88
|
+
|
|
89
|
+
export type {
|
|
90
|
+
ComposeManifest,
|
|
91
|
+
ManifestOperation,
|
|
92
|
+
ManifestGuard,
|
|
93
|
+
ManifestMaterialiser,
|
|
94
|
+
ManifestPrecondition,
|
|
95
|
+
GuardSelector,
|
|
96
|
+
GuardCompatibility,
|
|
97
|
+
} from "./manifest.js";
|
|
98
|
+
|
|
99
|
+
export type {
|
|
100
|
+
SweepTo,
|
|
101
|
+
ComposeRun,
|
|
102
|
+
ComposeCompileRequest,
|
|
103
|
+
ComposeCompileSuccessData,
|
|
104
|
+
ComposeContinuation,
|
|
105
|
+
PriceImpact,
|
|
106
|
+
SimulationPolicy,
|
|
107
|
+
ApprovalEntry,
|
|
108
|
+
SimulationRevert,
|
|
109
|
+
ComposeTransactionRequest,
|
|
110
|
+
ComposeCompilePartialData,
|
|
111
|
+
ComposeCompileResult,
|
|
112
|
+
} from "./compile.js";
|
|
113
|
+
|
|
114
|
+
export type {
|
|
115
|
+
MaterialiserMetadata,
|
|
116
|
+
MaterialiserResolution,
|
|
117
|
+
} from "./materialiserMetadata.js";
|
|
118
|
+
export { foldMaterialiserMetadata } from "./materialiserMetadata.js";
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
ResourcePortZod,
|
|
122
|
+
HandlePortZod,
|
|
123
|
+
InputPortZod,
|
|
124
|
+
ResourceOutputPortZod,
|
|
125
|
+
OutputPortZod,
|
|
126
|
+
ManifestOperationZod,
|
|
127
|
+
ManifestGuardZod,
|
|
128
|
+
ManifestMaterialiserZod,
|
|
129
|
+
ManifestPreconditionZod,
|
|
130
|
+
ComposeManifestZod,
|
|
131
|
+
GuardSelectorZod,
|
|
132
|
+
GuardCompatibilityZod,
|
|
133
|
+
} from "./zodSchemas.js";
|
package/src/manifest.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Precondition } from './flow.js';
|
|
2
|
+
|
|
3
|
+
export type MaterialiserMetadata =
|
|
4
|
+
| { readonly kind: 'exact'; readonly amount: bigint }
|
|
5
|
+
| { readonly kind: 'exact-native'; readonly amount: bigint }
|
|
6
|
+
| { readonly kind: 'runtime' };
|
|
7
|
+
|
|
8
|
+
export interface MaterialiserResolution {
|
|
9
|
+
readonly meta: MaterialiserMetadata;
|
|
10
|
+
readonly preconditions: readonly Precondition[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const foldMaterialiserMetadata = <R>(
|
|
14
|
+
meta: MaterialiserMetadata,
|
|
15
|
+
cases: {
|
|
16
|
+
readonly exact: (amount: bigint) => R;
|
|
17
|
+
readonly exactNative: (amount: bigint) => R;
|
|
18
|
+
readonly runtime: () => R;
|
|
19
|
+
}
|
|
20
|
+
): R => {
|
|
21
|
+
if (meta.kind === 'exact') return cases.exact(meta.amount);
|
|
22
|
+
if (meta.kind === 'exact-native') return cases.exactNative(meta.amount);
|
|
23
|
+
return cases.runtime();
|
|
24
|
+
};
|
package/src/ref.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Ref } from "./flowSchema.js";
|
|
2
|
+
|
|
3
|
+
export type ParsedRef =
|
|
4
|
+
| { readonly scope: "input"; readonly port: string }
|
|
5
|
+
| { readonly scope: "output"; readonly node: string; readonly port: string }
|
|
6
|
+
| { readonly scope: "context"; readonly key: ContextKey };
|
|
7
|
+
|
|
8
|
+
export type RefScope = ParsedRef["scope"];
|
|
9
|
+
|
|
10
|
+
export type ContextKey = "sender" | "executionAddress";
|
|
11
|
+
|
|
12
|
+
export const isContextKey = (key: string): key is ContextKey =>
|
|
13
|
+
key === "sender" || key === "executionAddress";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Ref prefixes that parseRef intercepts before the fallback `output` scope.
|
|
17
|
+
* A node whose id matches one of these would produce ambiguous refs
|
|
18
|
+
* (e.g. `context.sender` could be a context ref or node-output ref).
|
|
19
|
+
* Validation must reject these as node ids.
|
|
20
|
+
*/
|
|
21
|
+
export const RESERVED_REF_SCOPES: ReadonlySet<string> = new Set([
|
|
22
|
+
"input",
|
|
23
|
+
"context",
|
|
24
|
+
"literal",
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
export const parseRef = (ref: Ref): ParsedRef => {
|
|
28
|
+
const dot = ref.$ref.indexOf(".");
|
|
29
|
+
if (dot === -1)
|
|
30
|
+
throw new Error(`Invalid ref: "${ref.$ref}" (must contain a dot)`);
|
|
31
|
+
const prefix = ref.$ref.slice(0, dot);
|
|
32
|
+
const suffix = ref.$ref.slice(dot + 1);
|
|
33
|
+
if (prefix === "input") return { scope: "input", port: suffix };
|
|
34
|
+
if (prefix === "context") {
|
|
35
|
+
if (!isContextKey(suffix))
|
|
36
|
+
throw new Error(`Unknown context key: "${suffix}"`);
|
|
37
|
+
return { scope: "context", key: suffix };
|
|
38
|
+
}
|
|
39
|
+
return { scope: "output", node: prefix, port: suffix };
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const foldRef = <R>(
|
|
43
|
+
ref: ParsedRef,
|
|
44
|
+
cases: {
|
|
45
|
+
readonly input: (port: string) => R;
|
|
46
|
+
readonly context: (key: ContextKey) => R;
|
|
47
|
+
readonly output: (node: string, port: string) => R;
|
|
48
|
+
}
|
|
49
|
+
): R => {
|
|
50
|
+
if (ref.scope === "input") return cases.input(ref.port);
|
|
51
|
+
if (ref.scope === "context") return cases.context(ref.key);
|
|
52
|
+
return cases.output(ref.node, ref.port);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const refKey = (ref: Ref): string =>
|
|
56
|
+
foldRef(parseRef(ref), {
|
|
57
|
+
input: (port) => `input:${port}`,
|
|
58
|
+
context: (key) => `context:${key}`,
|
|
59
|
+
output: (node, port) => `output:${node}:${port}`,
|
|
60
|
+
});
|
package/src/resource.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type Availability = "now" | "future";
|
|
2
|
+
|
|
3
|
+
export interface OutputAmount {
|
|
4
|
+
readonly expected: bigint;
|
|
5
|
+
readonly min?: bigint;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type Resource =
|
|
9
|
+
| { readonly kind: "native"; readonly chainId: number }
|
|
10
|
+
| {
|
|
11
|
+
readonly kind: "erc20";
|
|
12
|
+
readonly token: string;
|
|
13
|
+
readonly chainId: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type SimulatedAmounts = {
|
|
17
|
+
readonly amountOut: bigint;
|
|
18
|
+
readonly amountOutMin: bigint;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type ProducedResource = Resource & {
|
|
22
|
+
readonly availability: Availability;
|
|
23
|
+
readonly simulated?: SimulatedAmounts;
|
|
24
|
+
readonly owner: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const foldResource = <R>(
|
|
28
|
+
r: Resource,
|
|
29
|
+
cases: {
|
|
30
|
+
readonly native: (chainId: number) => R;
|
|
31
|
+
readonly erc20: (token: string, chainId: number) => R;
|
|
32
|
+
}
|
|
33
|
+
): R =>
|
|
34
|
+
r.kind === "native"
|
|
35
|
+
? cases.native(r.chainId)
|
|
36
|
+
: cases.erc20(r.token, r.chainId);
|
|
37
|
+
|
|
38
|
+
export const resourceKey = (r: Resource): string =>
|
|
39
|
+
foldResource(r, {
|
|
40
|
+
native: (chainId) => `native:${chainId}`,
|
|
41
|
+
erc20: (token, chainId) => `erc20:${token.toLowerCase()}:${chainId}`,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const erc20Token = (r: Resource): string => {
|
|
45
|
+
if (r.kind !== "erc20")
|
|
46
|
+
throw new Error(`Expected erc20 resource, got ${r.kind}`);
|
|
47
|
+
return r.token;
|
|
48
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
const SolTypeZod = z.enum([
|
|
4
|
+
"uint8",
|
|
5
|
+
"uint16",
|
|
6
|
+
"uint32",
|
|
7
|
+
"uint64",
|
|
8
|
+
"uint128",
|
|
9
|
+
"uint256",
|
|
10
|
+
"int128",
|
|
11
|
+
"int256",
|
|
12
|
+
"address",
|
|
13
|
+
"bool",
|
|
14
|
+
"bytes",
|
|
15
|
+
"bytes4",
|
|
16
|
+
"bytes32",
|
|
17
|
+
"string",
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export const ResourcePortZod = z.object({
|
|
21
|
+
kind: z.literal("resource"),
|
|
22
|
+
name: z.string(),
|
|
23
|
+
accepts: z.enum(["erc20", "native", "any"]),
|
|
24
|
+
mode: z.enum(["linear", "copy"]),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const HandlePortZod = z.object({
|
|
28
|
+
kind: z.literal("handle"),
|
|
29
|
+
name: z.string(),
|
|
30
|
+
type: SolTypeZod,
|
|
31
|
+
mode: z.enum(["linear", "copy"]),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const InputPortZod = z.discriminatedUnion("kind", [
|
|
35
|
+
ResourcePortZod,
|
|
36
|
+
HandlePortZod,
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
export const ResourceOutputPortZod = z.object({
|
|
40
|
+
kind: z.literal("resource_output"),
|
|
41
|
+
name: z.string(),
|
|
42
|
+
mode: z.enum(["linear", "copy"]),
|
|
43
|
+
availability: z.enum(["now", "future"]).optional(),
|
|
44
|
+
providesMinimum: z.boolean().optional(),
|
|
45
|
+
omitIfZero: z.boolean().optional(),
|
|
46
|
+
deliveryAddressInput: z.string().optional(),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const OutputPortZod = z.discriminatedUnion("kind", [
|
|
50
|
+
ResourceOutputPortZod,
|
|
51
|
+
HandlePortZod,
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
export const ManifestOperationZod = z.object({
|
|
55
|
+
id: z.string(),
|
|
56
|
+
description: z.string().optional(),
|
|
57
|
+
inputs: z.array(InputPortZod),
|
|
58
|
+
outputs: z.array(OutputPortZod),
|
|
59
|
+
configSchema: z.unknown().optional(),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const PortKindEnum = z.enum(["resource", "resource_output", "handle"]);
|
|
63
|
+
|
|
64
|
+
const SelectorMatchZod = z.object({
|
|
65
|
+
kind: z.union([PortKindEnum, z.array(PortKindEnum)]),
|
|
66
|
+
mode: z.enum(["linear", "copy"]).optional(),
|
|
67
|
+
type: z.enum(["erc20", "native", "any"]).optional(),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const ConfigSelectionZod = z.object({
|
|
71
|
+
kind: z.literal("config"),
|
|
72
|
+
configKey: z.string(),
|
|
73
|
+
cardinality: z.enum(["one", "many"]),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const AllMatchingSelectionZod = z.object({
|
|
77
|
+
kind: z.literal("all_matching"),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const SelectorSelectionZod = z.discriminatedUnion("kind", [
|
|
81
|
+
ConfigSelectionZod,
|
|
82
|
+
AllMatchingSelectionZod,
|
|
83
|
+
]);
|
|
84
|
+
|
|
85
|
+
export const GuardSelectorZod = z.object({
|
|
86
|
+
binding: z.string(),
|
|
87
|
+
source: z.enum(["inputs", "outputs"]),
|
|
88
|
+
match: SelectorMatchZod,
|
|
89
|
+
selection: SelectorSelectionZod,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export const GuardCompatibilityZod = z.object({
|
|
93
|
+
selectors: z.array(GuardSelectorZod),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const ManifestGuardZod = z.object({
|
|
97
|
+
kind: z.string(),
|
|
98
|
+
description: z.string().optional(),
|
|
99
|
+
configSchema: z.unknown().optional(),
|
|
100
|
+
compatibility: GuardCompatibilityZod.optional(),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export const ManifestMaterialiserZod = z.object({
|
|
104
|
+
kind: z.string(),
|
|
105
|
+
description: z.string().optional(),
|
|
106
|
+
accepts: z.enum(["resource", "handle", "any"]),
|
|
107
|
+
configSchema: z.unknown().optional(),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const ManifestPreconditionZod = z.object({
|
|
111
|
+
type: z.string(),
|
|
112
|
+
description: z.string().optional(),
|
|
113
|
+
configSchema: z.unknown().optional(),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
export const ComposeManifestZod = z.object({
|
|
117
|
+
manifestVersion: z.number(),
|
|
118
|
+
manifestHash: z.string(),
|
|
119
|
+
flowSchema: z.object({}).passthrough(),
|
|
120
|
+
operations: z.array(ManifestOperationZod),
|
|
121
|
+
guards: z.array(ManifestGuardZod),
|
|
122
|
+
materialisers: z.array(ManifestMaterialiserZod),
|
|
123
|
+
preconditions: z.array(ManifestPreconditionZod).optional(),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
export type ResourcePort = z.infer<typeof ResourcePortZod>;
|
|
127
|
+
export type HandlePort = z.infer<typeof HandlePortZod>;
|
|
128
|
+
export type OpInputPort = z.infer<typeof InputPortZod>;
|
|
129
|
+
export type ResourceOutputPort = z.infer<typeof ResourceOutputPortZod>;
|
|
130
|
+
export type OpOutputPort = z.infer<typeof OutputPortZod>;
|
|
131
|
+
export type ManifestOperation = z.infer<typeof ManifestOperationZod>;
|
|
132
|
+
export type GuardSelector = z.infer<typeof GuardSelectorZod>;
|
|
133
|
+
export type GuardCompatibility = z.infer<typeof GuardCompatibilityZod>;
|
|
134
|
+
export type ManifestGuard = z.infer<typeof ManifestGuardZod>;
|
|
135
|
+
export type ManifestMaterialiser = z.infer<typeof ManifestMaterialiserZod>;
|
|
136
|
+
export type ManifestPrecondition = z.infer<typeof ManifestPreconditionZod>;
|
|
137
|
+
export type ComposeManifest = z.infer<typeof ComposeManifestZod>;
|