@opencode-ai/schema 0.0.0-next-14761 → 0.0.0-next-14771
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/event-manifest.d.ts +116 -164
- package/dist/form.d.ts +221 -281
- package/dist/form.js +16 -6
- package/package.json +1 -1
package/dist/form.js
CHANGED
|
@@ -3,7 +3,6 @@ import { Schema } from "effect";
|
|
|
3
3
|
import { define, inventory } from "./event.js";
|
|
4
4
|
import { ascending } from "./identifier.js";
|
|
5
5
|
import { NonNegativeInt, optional, statics } from "./schema.js";
|
|
6
|
-
import { SessionID } from "./session-id.js";
|
|
7
6
|
const IDSchema = Schema.String.check(Schema.isStartsWith("frm_")).pipe(Schema.brand("Form.ID"));
|
|
8
7
|
export const ID = IDSchema.pipe(statics((schema) => ({ create: (id) => schema.make(id ?? "frm_" + ascending()) })));
|
|
9
8
|
export const Metadata = Schema.Record(Schema.String, Schema.Unknown).annotate({ identifier: "Form.Metadata" });
|
|
@@ -12,17 +11,24 @@ export const Option = Schema.Struct({
|
|
|
12
11
|
label: Schema.String,
|
|
13
12
|
description: Schema.String.pipe(optional),
|
|
14
13
|
}).annotate({ identifier: "Form.Option" });
|
|
14
|
+
// One visibility condition on a field. A field's `when` is a list of conditions that must all
|
|
15
|
+
// hold (AND) against the current answers for the field to be active. Semantics:
|
|
16
|
+
// - `value` must match the referenced field's type; against a multiselect answer, `eq` means
|
|
17
|
+
// "selection includes value" and `neq` means "selection does not include value".
|
|
18
|
+
// - An unanswered referenced field makes the condition false for both ops.
|
|
19
|
+
// - `key` must reference a field defined earlier in the form's field list.
|
|
20
|
+
// Inactive fields are neither required nor answerable.
|
|
15
21
|
export const When = Schema.Struct({
|
|
16
22
|
key: Schema.String,
|
|
17
23
|
op: Schema.Literals(["eq", "neq"]),
|
|
18
|
-
value: Schema.String,
|
|
24
|
+
value: Schema.Union([Schema.String, Schema.Number, Schema.Boolean]),
|
|
19
25
|
}).annotate({ identifier: "Form.When" });
|
|
20
26
|
const FieldBase = {
|
|
21
27
|
key: Schema.String,
|
|
22
28
|
title: Schema.String.pipe(optional),
|
|
23
29
|
description: Schema.String.pipe(optional),
|
|
24
30
|
required: Schema.Boolean.pipe(optional),
|
|
25
|
-
when: When.pipe(optional),
|
|
31
|
+
when: Schema.Array(When).pipe(optional),
|
|
26
32
|
};
|
|
27
33
|
export const StringField = Schema.Struct({
|
|
28
34
|
...FieldBase,
|
|
@@ -67,7 +73,11 @@ export const MultiselectField = Schema.Struct({
|
|
|
67
73
|
export const Field = Schema.Union([StringField, NumberField, IntegerField, BooleanField, MultiselectField]).pipe(Schema.toTaggedUnion("type"));
|
|
68
74
|
const InfoBase = {
|
|
69
75
|
id: ID,
|
|
70
|
-
|
|
76
|
+
// This should be typed as SessionID. It is a plain string only because MCP elicitation
|
|
77
|
+
// temporarily needs the `"global"` sentinel owner, which is not a real session. Once
|
|
78
|
+
// elicitations can be attributed to real sessions, revert this to SessionID. Do not rely
|
|
79
|
+
// on non-session owners anywhere else.
|
|
80
|
+
sessionID: Schema.String,
|
|
71
81
|
title: Schema.String.pipe(optional),
|
|
72
82
|
metadata: Metadata.pipe(optional),
|
|
73
83
|
};
|
|
@@ -97,6 +107,6 @@ export const Reply = Schema.Struct({
|
|
|
97
107
|
answer: Answer,
|
|
98
108
|
}).annotate({ identifier: "Form.Reply" });
|
|
99
109
|
const Created = define({ type: "form.created", schema: { form: Info } });
|
|
100
|
-
const Replied = define({ type: "form.replied", schema: { id: ID, sessionID:
|
|
101
|
-
const Cancelled = define({ type: "form.cancelled", schema: { id: ID, sessionID:
|
|
110
|
+
const Replied = define({ type: "form.replied", schema: { id: ID, sessionID: Schema.String, answer: Answer } });
|
|
111
|
+
const Cancelled = define({ type: "form.cancelled", schema: { id: ID, sessionID: Schema.String } });
|
|
102
112
|
export const Event = { Created, Replied, Cancelled, Definitions: inventory(Created, Replied, Cancelled) };
|