@opencode-ai/schema 0.0.0-next-14758 → 0.0.0-next-14759
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 +852 -0
- package/dist/event-manifest.js +2 -1
- package/dist/form.d.ts +1399 -0
- package/dist/form.js +102 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/form.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export * as Form from "./form.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { define, inventory } from "./event.js";
|
|
4
|
+
import { ascending } from "./identifier.js";
|
|
5
|
+
import { NonNegativeInt, optional, statics } from "./schema.js";
|
|
6
|
+
import { SessionID } from "./session-id.js";
|
|
7
|
+
const IDSchema = Schema.String.check(Schema.isStartsWith("frm_")).pipe(Schema.brand("Form.ID"));
|
|
8
|
+
export const ID = IDSchema.pipe(statics((schema) => ({ create: (id) => schema.make(id ?? "frm_" + ascending()) })));
|
|
9
|
+
export const Metadata = Schema.Record(Schema.String, Schema.Unknown).annotate({ identifier: "Form.Metadata" });
|
|
10
|
+
export const Option = Schema.Struct({
|
|
11
|
+
value: Schema.String,
|
|
12
|
+
label: Schema.String,
|
|
13
|
+
description: Schema.String.pipe(optional),
|
|
14
|
+
}).annotate({ identifier: "Form.Option" });
|
|
15
|
+
export const When = Schema.Struct({
|
|
16
|
+
key: Schema.String,
|
|
17
|
+
op: Schema.Literals(["eq", "neq"]),
|
|
18
|
+
value: Schema.String,
|
|
19
|
+
}).annotate({ identifier: "Form.When" });
|
|
20
|
+
const FieldBase = {
|
|
21
|
+
key: Schema.String,
|
|
22
|
+
title: Schema.String.pipe(optional),
|
|
23
|
+
description: Schema.String.pipe(optional),
|
|
24
|
+
required: Schema.Boolean.pipe(optional),
|
|
25
|
+
when: When.pipe(optional),
|
|
26
|
+
};
|
|
27
|
+
export const StringField = Schema.Struct({
|
|
28
|
+
...FieldBase,
|
|
29
|
+
type: Schema.Literal("string"),
|
|
30
|
+
format: Schema.Literals(["email", "uri", "date", "date-time"]).pipe(optional),
|
|
31
|
+
minLength: NonNegativeInt.pipe(optional),
|
|
32
|
+
maxLength: NonNegativeInt.pipe(optional),
|
|
33
|
+
pattern: Schema.String.pipe(optional),
|
|
34
|
+
placeholder: Schema.String.pipe(optional),
|
|
35
|
+
default: Schema.String.pipe(optional),
|
|
36
|
+
options: Schema.Array(Option).pipe(optional),
|
|
37
|
+
custom: Schema.Boolean.pipe(optional),
|
|
38
|
+
}).annotate({ identifier: "Form.StringField" });
|
|
39
|
+
export const NumberField = Schema.Struct({
|
|
40
|
+
...FieldBase,
|
|
41
|
+
type: Schema.Literal("number"),
|
|
42
|
+
minimum: Schema.Number.pipe(optional),
|
|
43
|
+
maximum: Schema.Number.pipe(optional),
|
|
44
|
+
default: Schema.Number.pipe(optional),
|
|
45
|
+
}).annotate({ identifier: "Form.NumberField" });
|
|
46
|
+
export const IntegerField = Schema.Struct({
|
|
47
|
+
...FieldBase,
|
|
48
|
+
type: Schema.Literal("integer"),
|
|
49
|
+
minimum: Schema.Number.pipe(optional),
|
|
50
|
+
maximum: Schema.Number.pipe(optional),
|
|
51
|
+
default: Schema.Number.pipe(optional),
|
|
52
|
+
}).annotate({ identifier: "Form.IntegerField" });
|
|
53
|
+
export const BooleanField = Schema.Struct({
|
|
54
|
+
...FieldBase,
|
|
55
|
+
type: Schema.Literal("boolean"),
|
|
56
|
+
default: Schema.Boolean.pipe(optional),
|
|
57
|
+
}).annotate({ identifier: "Form.BooleanField" });
|
|
58
|
+
export const MultiselectField = Schema.Struct({
|
|
59
|
+
...FieldBase,
|
|
60
|
+
type: Schema.Literal("multiselect"),
|
|
61
|
+
options: Schema.Array(Option),
|
|
62
|
+
minItems: NonNegativeInt.pipe(optional),
|
|
63
|
+
maxItems: NonNegativeInt.pipe(optional),
|
|
64
|
+
custom: Schema.Boolean.pipe(optional),
|
|
65
|
+
default: Schema.Array(Schema.String).pipe(optional),
|
|
66
|
+
}).annotate({ identifier: "Form.MultiselectField" });
|
|
67
|
+
export const Field = Schema.Union([StringField, NumberField, IntegerField, BooleanField, MultiselectField]).pipe(Schema.toTaggedUnion("type"));
|
|
68
|
+
const InfoBase = {
|
|
69
|
+
id: ID,
|
|
70
|
+
sessionID: SessionID,
|
|
71
|
+
title: Schema.String.pipe(optional),
|
|
72
|
+
metadata: Metadata.pipe(optional),
|
|
73
|
+
};
|
|
74
|
+
export const FormInfo = Schema.Struct({
|
|
75
|
+
...InfoBase,
|
|
76
|
+
mode: Schema.Literal("form"),
|
|
77
|
+
fields: Schema.Array(Field),
|
|
78
|
+
}).annotate({ identifier: "Form.FormInfo" });
|
|
79
|
+
export const UrlInfo = Schema.Struct({
|
|
80
|
+
...InfoBase,
|
|
81
|
+
mode: Schema.Literal("url"),
|
|
82
|
+
url: Schema.String,
|
|
83
|
+
}).annotate({ identifier: "Form.UrlInfo" });
|
|
84
|
+
export const Info = Schema.Union([FormInfo, UrlInfo]).pipe(Schema.toTaggedUnion("mode"));
|
|
85
|
+
export const Value = Schema.Union([Schema.String, Schema.Number, Schema.Boolean, Schema.Array(Schema.String)]).annotate({
|
|
86
|
+
identifier: "Form.Value",
|
|
87
|
+
});
|
|
88
|
+
export const Answer = Schema.Record(Schema.String, Value).annotate({ identifier: "Form.Answer" });
|
|
89
|
+
export const State = Schema.Union([
|
|
90
|
+
Schema.Struct({ status: Schema.Literal("pending") }),
|
|
91
|
+
Schema.Struct({ status: Schema.Literal("answered"), answer: Answer }),
|
|
92
|
+
Schema.Struct({ status: Schema.Literal("cancelled") }),
|
|
93
|
+
])
|
|
94
|
+
.pipe(Schema.toTaggedUnion("status"))
|
|
95
|
+
.annotate({ identifier: "Form.State" });
|
|
96
|
+
export const Reply = Schema.Struct({
|
|
97
|
+
answer: Answer,
|
|
98
|
+
}).annotate({ identifier: "Form.Reply" });
|
|
99
|
+
const Created = define({ type: "form.created", schema: { form: Info } });
|
|
100
|
+
const Replied = define({ type: "form.replied", schema: { id: ID, sessionID: SessionID, answer: Answer } });
|
|
101
|
+
const Cancelled = define({ type: "form.cancelled", schema: { id: ID, sessionID: SessionID } });
|
|
102
|
+
export const Event = { Created, Replied, Cancelled, Definitions: inventory(Created, Replied, Cancelled) };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { Connection } from "./connection.js";
|
|
|
4
4
|
export { Credential } from "./credential.js";
|
|
5
5
|
export { Event } from "./event.js";
|
|
6
6
|
export { FileSystem } from "./filesystem.js";
|
|
7
|
+
export { Form } from "./form.js";
|
|
7
8
|
export { Integration } from "./integration.js";
|
|
8
9
|
export { LLM } from "./llm.js";
|
|
9
10
|
export { Location } from "./location.js";
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { Connection } from "./connection.js";
|
|
|
4
4
|
export { Credential } from "./credential.js";
|
|
5
5
|
export { Event } from "./event.js";
|
|
6
6
|
export { FileSystem } from "./filesystem.js";
|
|
7
|
+
export { Form } from "./form.js";
|
|
7
8
|
export { Integration } from "./integration.js";
|
|
8
9
|
export { LLM } from "./llm.js";
|
|
9
10
|
export { Location } from "./location.js";
|