@opencode/schema 0.0.0-dev-1360 → 0.0.0-dev-1362
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/config/experimental.d.ts +0 -1
- package/dist/config/flag.d.ts +0 -1
- package/dist/config/flag.js +0 -1
- package/dist/model.d.ts +5 -2
- package/dist/model.js +1 -1
- package/dist/space.d.ts +337 -0
- package/dist/space.js +60 -0
- package/package.json +1 -1
|
@@ -108,7 +108,6 @@ declare const Info_base: Schema.Class<Info, Schema.Struct<{
|
|
|
108
108
|
readonly machines: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
109
109
|
readonly mcp_skills: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
110
110
|
readonly media_blob: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
111
|
-
readonly model_speeds: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
112
111
|
readonly opencode_api: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
113
112
|
readonly project_overlay: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
114
113
|
readonly recommended_api: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
package/dist/config/flag.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export declare const registry: {
|
|
|
11
11
|
readonly artifacts: "Enable experimental artifacts backed by pluggable providers.";
|
|
12
12
|
readonly console_watches: "Watch Slack threads, GitHub pull requests, issues, commits and Actions runs, and the workspace's MCP servers' events through OpenCode Console, and wake sessions when they change.";
|
|
13
13
|
readonly recommended_api: "Use each model's recommended API from models.dev instead of the first API it lists.";
|
|
14
|
-
readonly model_speeds: "Offer a model's faster and slower service tiers (fast, flex…) as speeds of that model: one entry in the model picker with a speed selector, instead of a separate entry per tier such as gpt-5.5-fast.";
|
|
15
14
|
readonly full_codemode: "Enable the full Code Mode work in progress.";
|
|
16
15
|
readonly codemode_agents: "Let Code Mode scripts start subagents with agent() and make single model calls with llm(), each optionally returning a value checked against a schema, so one script can fan work out, verify it and combine the results.";
|
|
17
16
|
readonly machines: "Let a tool path name a machine, as in gpu:/work/train.py, and act on that machine's files and processes.";
|
package/dist/config/flag.js
CHANGED
|
@@ -11,7 +11,6 @@ export const registry = {
|
|
|
11
11
|
artifacts: "Enable experimental artifacts backed by pluggable providers.",
|
|
12
12
|
console_watches: "Watch Slack threads, GitHub pull requests, issues, commits and Actions runs, and the workspace's MCP servers' events through OpenCode Console, and wake sessions when they change.",
|
|
13
13
|
recommended_api: "Use each model's recommended API from models.dev instead of the first API it lists.",
|
|
14
|
-
model_speeds: "Offer a model's faster and slower service tiers (fast, flex…) as speeds of that model: one entry in the model picker with a speed selector, instead of a separate entry per tier such as gpt-5.5-fast.",
|
|
15
14
|
full_codemode: "Enable the full Code Mode work in progress.",
|
|
16
15
|
codemode_agents: "Let Code Mode scripts start subagents with agent() and make single model calls with llm(), each optionally returning a value checked against a schema, so one script can fan work out, verify it and combine the results.",
|
|
17
16
|
machines: "Let a tool path name a machine, as in gpu:/work/train.py, and act on that machine's files and processes.",
|
package/dist/model.d.ts
CHANGED
|
@@ -103,8 +103,11 @@ export interface Ref extends Schema.Schema.Type<typeof Ref> {
|
|
|
103
103
|
export { Compatibility, MaxTokensField, MediaInput, ReasoningField };
|
|
104
104
|
export declare const Family: Schema.brand<Schema.String, "Model.Family">;
|
|
105
105
|
export type Family = typeof Family.Type;
|
|
106
|
-
/**
|
|
107
|
-
|
|
106
|
+
/**
|
|
107
|
+
* What a model produces, from models.dev. Open-ended: new types keep being added. Only chat models are offered for
|
|
108
|
+
* sessions; an unset type means chat. Realtime models that answer in speech are offered as voice models.
|
|
109
|
+
*/
|
|
110
|
+
export type Type = "chat" | "decision" | "image" | "video" | "realtime" | "embedding" | "transcription" | (string & {});
|
|
108
111
|
export declare const Type: Schema.Codec<Type>;
|
|
109
112
|
export declare const Settings: Schema.StructWithRest<Schema.Struct<{
|
|
110
113
|
readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
|
package/dist/model.js
CHANGED
|
@@ -37,7 +37,7 @@ export const Ref = Schema.Struct({
|
|
|
37
37
|
export { Compatibility, MaxTokensField, MediaInput, ReasoningField };
|
|
38
38
|
export const Family = Schema.String.pipe(Schema.brand("Model.Family"));
|
|
39
39
|
export const Type = Schema.Union([
|
|
40
|
-
Schema.Literals(["chat", "decision", "image", "video"]),
|
|
40
|
+
Schema.Literals(["chat", "decision", "image", "video", "realtime", "embedding", "transcription"]),
|
|
41
41
|
Schema.String,
|
|
42
42
|
]).annotate({ identifier: "Model.Type" });
|
|
43
43
|
export const Settings = Schema.StructWithRest(Schema.Struct(Struct.pick(Provider.Settings.schema.fields, ["compaction", "cache", "encoding"])),
|
package/dist/space.d.ts
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
export * as Space from "./space.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
export declare const Name: Schema.String;
|
|
4
|
+
export type Name = typeof Name.Type;
|
|
5
|
+
export declare const Key: Schema.String;
|
|
6
|
+
export type Key = typeof Key.Type;
|
|
7
|
+
/** An opaque string the server stores and sends back unchanged; its format, such as JSON text, is up to the client. */
|
|
8
|
+
export declare const Value: Schema.String;
|
|
9
|
+
export type Value = typeof Value.Type;
|
|
10
|
+
/** A value always goes out as one event, so a write's values are capped at 1 MiB of UTF-8 in total. */
|
|
11
|
+
export declare const MaxValueBytes: number;
|
|
12
|
+
export interface Entry extends Schema.Schema.Type<typeof Entry> {
|
|
13
|
+
}
|
|
14
|
+
export declare const Entry: Schema.Struct<{
|
|
15
|
+
readonly key: Schema.String;
|
|
16
|
+
readonly value: Schema.String;
|
|
17
|
+
}>;
|
|
18
|
+
/** One change of a write: a value sets the space's key, `null` deletes it. */
|
|
19
|
+
export interface Change extends Schema.Schema.Type<typeof Change> {
|
|
20
|
+
}
|
|
21
|
+
export declare const Change: Schema.Struct<{
|
|
22
|
+
readonly space: Schema.String;
|
|
23
|
+
readonly key: Schema.String;
|
|
24
|
+
readonly value: Schema.NullOr<Schema.String>;
|
|
25
|
+
}>;
|
|
26
|
+
/** Changes one write commits at most, across all its spaces. */
|
|
27
|
+
export declare const MaxChanges = 1024;
|
|
28
|
+
/** Spaces one sync, subscribe or unsubscribe names at most. */
|
|
29
|
+
export declare const MaxSpaces = 100;
|
|
30
|
+
/** Server-issued, per space: every write in a space gets the next revision, and revisions are never reused. */
|
|
31
|
+
export declare const Revision: Schema.Int;
|
|
32
|
+
export type Revision = typeof Revision.Type;
|
|
33
|
+
/** Identifies the database that issued a space's revisions; a revision is only usable with the same epoch. */
|
|
34
|
+
export declare const Epoch: Schema.String;
|
|
35
|
+
/** An opaque position in a space, issued by the server. Clients save a page's `cursor` and pass back `next` as is. */
|
|
36
|
+
export declare const Cursor: Schema.String;
|
|
37
|
+
/**
|
|
38
|
+
* A page of a snapshot, which replaces everything the client held for the space: its entries apply at once, and keys
|
|
39
|
+
* none of the snapshot's pages held are removed after its last one.
|
|
40
|
+
*/
|
|
41
|
+
export interface Snapshot extends Schema.Schema.Type<typeof Snapshot> {
|
|
42
|
+
}
|
|
43
|
+
export declare const Snapshot: Schema.Struct<{
|
|
44
|
+
readonly space: Schema.String;
|
|
45
|
+
readonly epoch: Schema.String;
|
|
46
|
+
readonly revision: Schema.Int;
|
|
47
|
+
readonly entries: Schema.$Array<Schema.Struct<{
|
|
48
|
+
readonly key: Schema.String;
|
|
49
|
+
readonly value: Schema.String;
|
|
50
|
+
}>>;
|
|
51
|
+
readonly cursor: Schema.String;
|
|
52
|
+
readonly next: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
53
|
+
readonly type: Schema.tag<"snapshot">;
|
|
54
|
+
}>;
|
|
55
|
+
/** A sync page with the final values of the keys changed after the previous page, and the keys deleted since. */
|
|
56
|
+
export interface Delta extends Schema.Schema.Type<typeof Delta> {
|
|
57
|
+
}
|
|
58
|
+
export declare const Delta: Schema.Struct<{
|
|
59
|
+
readonly space: Schema.String;
|
|
60
|
+
readonly epoch: Schema.String;
|
|
61
|
+
readonly revision: Schema.Int;
|
|
62
|
+
readonly entries: Schema.$Array<Schema.Struct<{
|
|
63
|
+
readonly key: Schema.String;
|
|
64
|
+
readonly value: Schema.String;
|
|
65
|
+
}>>;
|
|
66
|
+
readonly cursor: Schema.String;
|
|
67
|
+
readonly next: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
68
|
+
readonly type: Schema.tag<"delta">;
|
|
69
|
+
readonly deleted: Schema.$Array<Schema.String>;
|
|
70
|
+
}>;
|
|
71
|
+
export declare const Page: Schema.Union<readonly [Schema.Struct<{
|
|
72
|
+
readonly space: Schema.String;
|
|
73
|
+
readonly epoch: Schema.String;
|
|
74
|
+
readonly revision: Schema.Int;
|
|
75
|
+
readonly entries: Schema.$Array<Schema.Struct<{
|
|
76
|
+
readonly key: Schema.String;
|
|
77
|
+
readonly value: Schema.String;
|
|
78
|
+
}>>;
|
|
79
|
+
readonly cursor: Schema.String;
|
|
80
|
+
readonly next: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
81
|
+
readonly type: Schema.tag<"snapshot">;
|
|
82
|
+
}>, Schema.Struct<{
|
|
83
|
+
readonly space: Schema.String;
|
|
84
|
+
readonly epoch: Schema.String;
|
|
85
|
+
readonly revision: Schema.Int;
|
|
86
|
+
readonly entries: Schema.$Array<Schema.Struct<{
|
|
87
|
+
readonly key: Schema.String;
|
|
88
|
+
readonly value: Schema.String;
|
|
89
|
+
}>>;
|
|
90
|
+
readonly cursor: Schema.String;
|
|
91
|
+
readonly next: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
92
|
+
readonly type: Schema.tag<"delta">;
|
|
93
|
+
readonly deleted: Schema.$Array<Schema.String>;
|
|
94
|
+
}>]>;
|
|
95
|
+
export type Page = typeof Page.Type;
|
|
96
|
+
export declare const Event: {
|
|
97
|
+
Resync: Schema.Struct<{
|
|
98
|
+
readonly id: Schema.brand<Schema.String, "Event.ID"> & {
|
|
99
|
+
create: () => string & import("effect/Brand").Brand<"Event.ID">;
|
|
100
|
+
};
|
|
101
|
+
readonly created: Schema.Finite;
|
|
102
|
+
readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
103
|
+
readonly type: Schema.Literal<"experimental.space.resync">;
|
|
104
|
+
readonly location: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
105
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
106
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
107
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
108
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
109
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
110
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
111
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
112
|
+
}>, never, never>;
|
|
113
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
114
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
115
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
116
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
117
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
118
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
119
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
120
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
121
|
+
}>, never, never>;
|
|
122
|
+
}>>, never, never>;
|
|
123
|
+
readonly data: Schema.Struct<{
|
|
124
|
+
readonly space: Schema.String;
|
|
125
|
+
}>;
|
|
126
|
+
}> & {
|
|
127
|
+
type: "experimental.space.resync";
|
|
128
|
+
durability: "ephemeral";
|
|
129
|
+
durable: undefined;
|
|
130
|
+
data: Schema.Struct<{
|
|
131
|
+
readonly space: Schema.String;
|
|
132
|
+
}>;
|
|
133
|
+
};
|
|
134
|
+
Updated: Schema.Struct<{
|
|
135
|
+
readonly id: Schema.brand<Schema.String, "Event.ID"> & {
|
|
136
|
+
create: () => string & import("effect/Brand").Brand<"Event.ID">;
|
|
137
|
+
};
|
|
138
|
+
readonly created: Schema.Finite;
|
|
139
|
+
readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
140
|
+
readonly type: Schema.Literal<"experimental.space.updated">;
|
|
141
|
+
readonly location: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
142
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
143
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
144
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
145
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
146
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
147
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
148
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
149
|
+
}>, never, never>;
|
|
150
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
151
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
152
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
153
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
154
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
155
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
156
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
157
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
158
|
+
}>, never, never>;
|
|
159
|
+
}>>, never, never>;
|
|
160
|
+
readonly data: Schema.Struct<{
|
|
161
|
+
readonly space: Schema.String;
|
|
162
|
+
readonly key: Schema.String;
|
|
163
|
+
readonly value: Schema.String;
|
|
164
|
+
readonly revision: Schema.Int;
|
|
165
|
+
}>;
|
|
166
|
+
}> & {
|
|
167
|
+
type: "experimental.space.updated";
|
|
168
|
+
durability: "ephemeral";
|
|
169
|
+
durable: undefined;
|
|
170
|
+
data: Schema.Struct<{
|
|
171
|
+
readonly space: Schema.String;
|
|
172
|
+
readonly key: Schema.String;
|
|
173
|
+
readonly value: Schema.String;
|
|
174
|
+
readonly revision: Schema.Int;
|
|
175
|
+
}>;
|
|
176
|
+
};
|
|
177
|
+
Deleted: Schema.Struct<{
|
|
178
|
+
readonly id: Schema.brand<Schema.String, "Event.ID"> & {
|
|
179
|
+
create: () => string & import("effect/Brand").Brand<"Event.ID">;
|
|
180
|
+
};
|
|
181
|
+
readonly created: Schema.Finite;
|
|
182
|
+
readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
183
|
+
readonly type: Schema.Literal<"experimental.space.deleted">;
|
|
184
|
+
readonly location: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
185
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
186
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
187
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
188
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
189
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
190
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
191
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
192
|
+
}>, never, never>;
|
|
193
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
194
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
195
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
196
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
197
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
198
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
199
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
200
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
201
|
+
}>, never, never>;
|
|
202
|
+
}>>, never, never>;
|
|
203
|
+
readonly data: Schema.Struct<{
|
|
204
|
+
readonly space: Schema.String;
|
|
205
|
+
readonly key: Schema.String;
|
|
206
|
+
readonly revision: Schema.Int;
|
|
207
|
+
}>;
|
|
208
|
+
}> & {
|
|
209
|
+
type: "experimental.space.deleted";
|
|
210
|
+
durability: "ephemeral";
|
|
211
|
+
durable: undefined;
|
|
212
|
+
data: Schema.Struct<{
|
|
213
|
+
readonly space: Schema.String;
|
|
214
|
+
readonly key: Schema.String;
|
|
215
|
+
readonly revision: Schema.Int;
|
|
216
|
+
}>;
|
|
217
|
+
};
|
|
218
|
+
Definitions: readonly [Schema.Struct<{
|
|
219
|
+
readonly id: Schema.brand<Schema.String, "Event.ID"> & {
|
|
220
|
+
create: () => string & import("effect/Brand").Brand<"Event.ID">;
|
|
221
|
+
};
|
|
222
|
+
readonly created: Schema.Finite;
|
|
223
|
+
readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
224
|
+
readonly type: Schema.Literal<"experimental.space.resync">;
|
|
225
|
+
readonly location: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
226
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
227
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
228
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
229
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
230
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
231
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
232
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
233
|
+
}>, never, never>;
|
|
234
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
235
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
236
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
237
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
238
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
239
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
240
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
241
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
242
|
+
}>, never, never>;
|
|
243
|
+
}>>, never, never>;
|
|
244
|
+
readonly data: Schema.Struct<{
|
|
245
|
+
readonly space: Schema.String;
|
|
246
|
+
}>;
|
|
247
|
+
}> & {
|
|
248
|
+
type: "experimental.space.resync";
|
|
249
|
+
durability: "ephemeral";
|
|
250
|
+
durable: undefined;
|
|
251
|
+
data: Schema.Struct<{
|
|
252
|
+
readonly space: Schema.String;
|
|
253
|
+
}>;
|
|
254
|
+
}, Schema.Struct<{
|
|
255
|
+
readonly id: Schema.brand<Schema.String, "Event.ID"> & {
|
|
256
|
+
create: () => string & import("effect/Brand").Brand<"Event.ID">;
|
|
257
|
+
};
|
|
258
|
+
readonly created: Schema.Finite;
|
|
259
|
+
readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
260
|
+
readonly type: Schema.Literal<"experimental.space.updated">;
|
|
261
|
+
readonly location: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
262
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
263
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
264
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
265
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
266
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
267
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
268
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
269
|
+
}>, never, never>;
|
|
270
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
271
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
272
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
273
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
274
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
275
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
276
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
277
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
278
|
+
}>, never, never>;
|
|
279
|
+
}>>, never, never>;
|
|
280
|
+
readonly data: Schema.Struct<{
|
|
281
|
+
readonly space: Schema.String;
|
|
282
|
+
readonly key: Schema.String;
|
|
283
|
+
readonly value: Schema.String;
|
|
284
|
+
readonly revision: Schema.Int;
|
|
285
|
+
}>;
|
|
286
|
+
}> & {
|
|
287
|
+
type: "experimental.space.updated";
|
|
288
|
+
durability: "ephemeral";
|
|
289
|
+
durable: undefined;
|
|
290
|
+
data: Schema.Struct<{
|
|
291
|
+
readonly space: Schema.String;
|
|
292
|
+
readonly key: Schema.String;
|
|
293
|
+
readonly value: Schema.String;
|
|
294
|
+
readonly revision: Schema.Int;
|
|
295
|
+
}>;
|
|
296
|
+
}, Schema.Struct<{
|
|
297
|
+
readonly id: Schema.brand<Schema.String, "Event.ID"> & {
|
|
298
|
+
create: () => string & import("effect/Brand").Brand<"Event.ID">;
|
|
299
|
+
};
|
|
300
|
+
readonly created: Schema.Finite;
|
|
301
|
+
readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
302
|
+
readonly type: Schema.Literal<"experimental.space.deleted">;
|
|
303
|
+
readonly location: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
304
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
305
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
306
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
307
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
308
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
309
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
310
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
311
|
+
}>, never, never>;
|
|
312
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
313
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
314
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
315
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
316
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
317
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
|
|
318
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
319
|
+
create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
|
|
320
|
+
}>, never, never>;
|
|
321
|
+
}>>, never, never>;
|
|
322
|
+
readonly data: Schema.Struct<{
|
|
323
|
+
readonly space: Schema.String;
|
|
324
|
+
readonly key: Schema.String;
|
|
325
|
+
readonly revision: Schema.Int;
|
|
326
|
+
}>;
|
|
327
|
+
}> & {
|
|
328
|
+
type: "experimental.space.deleted";
|
|
329
|
+
durability: "ephemeral";
|
|
330
|
+
durable: undefined;
|
|
331
|
+
data: Schema.Struct<{
|
|
332
|
+
readonly space: Schema.String;
|
|
333
|
+
readonly key: Schema.String;
|
|
334
|
+
readonly revision: Schema.Int;
|
|
335
|
+
}>;
|
|
336
|
+
}];
|
|
337
|
+
};
|
package/dist/space.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export * as Space from "./space.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { ephemeral, inventory } from "./event.js";
|
|
4
|
+
import { NonNegativeInt, optional } from "./schema.js";
|
|
5
|
+
export const Name = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9._-]{1,128}$/u)).annotate({
|
|
6
|
+
identifier: "Space.Name",
|
|
7
|
+
description: "Client-chosen namespace: 1-128 letters, digits, '.', '_' or '-'.",
|
|
8
|
+
});
|
|
9
|
+
export const Key = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(1024)).annotate({
|
|
10
|
+
identifier: "Space.Key",
|
|
11
|
+
});
|
|
12
|
+
/** An opaque string the server stores and sends back unchanged; its format, such as JSON text, is up to the client. */
|
|
13
|
+
export const Value = Schema.String.annotate({ identifier: "Space.Value" });
|
|
14
|
+
/** A value always goes out as one event, so a write's values are capped at 1 MiB of UTF-8 in total. */
|
|
15
|
+
export const MaxValueBytes = 1024 * 1024;
|
|
16
|
+
export const Entry = Schema.Struct({ key: Key, value: Value }).annotate({ identifier: "Space.Entry" });
|
|
17
|
+
export const Change = Schema.Struct({ space: Name, key: Key, value: Schema.NullOr(Value) }).annotate({
|
|
18
|
+
identifier: "Space.Change",
|
|
19
|
+
});
|
|
20
|
+
/** Changes one write commits at most, across all its spaces. */
|
|
21
|
+
export const MaxChanges = 1024;
|
|
22
|
+
/** Spaces one sync, subscribe or unsubscribe names at most. */
|
|
23
|
+
export const MaxSpaces = 100;
|
|
24
|
+
/** Server-issued, per space: every write in a space gets the next revision, and revisions are never reused. */
|
|
25
|
+
export const Revision = NonNegativeInt.annotate({ identifier: "Space.Revision" });
|
|
26
|
+
/** Identifies the database that issued a space's revisions; a revision is only usable with the same epoch. */
|
|
27
|
+
export const Epoch = Schema.String.annotate({ identifier: "Space.Epoch" });
|
|
28
|
+
/** An opaque position in a space, issued by the server. Clients save a page's `cursor` and pass back `next` as is. */
|
|
29
|
+
export const Cursor = Schema.String.annotate({ identifier: "Space.Cursor" });
|
|
30
|
+
const page = {
|
|
31
|
+
space: Name,
|
|
32
|
+
epoch: Epoch,
|
|
33
|
+
revision: Revision,
|
|
34
|
+
entries: Schema.Array(Entry),
|
|
35
|
+
cursor: Cursor.annotate({ description: "Covers every change up to this page; save it to subscribe or sync from." }),
|
|
36
|
+
next: optional(Cursor).annotate({ description: "Present while more pages remain: sync again with it as `cursor`." }),
|
|
37
|
+
};
|
|
38
|
+
export const Snapshot = Schema.Struct({ type: Schema.tag("snapshot"), ...page }).annotate({
|
|
39
|
+
identifier: "Space.Snapshot",
|
|
40
|
+
});
|
|
41
|
+
export const Delta = Schema.Struct({ type: Schema.tag("delta"), ...page, deleted: Schema.Array(Key) }).annotate({
|
|
42
|
+
identifier: "Space.Delta",
|
|
43
|
+
});
|
|
44
|
+
export const Page = Schema.Union([Snapshot, Delta]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "Space.Page" }));
|
|
45
|
+
/** Sent instead of the changes when they no longer fit one batch or the cursor is unusable: sync and subscribe again. */
|
|
46
|
+
const Resync = ephemeral({ type: "experimental.space.resync", schema: { space: Name } });
|
|
47
|
+
const Updated = ephemeral({
|
|
48
|
+
type: "experimental.space.updated",
|
|
49
|
+
schema: { space: Name, key: Key, value: Value, revision: Revision },
|
|
50
|
+
});
|
|
51
|
+
const Deleted = ephemeral({
|
|
52
|
+
type: "experimental.space.deleted",
|
|
53
|
+
schema: { space: Name, key: Key, revision: Revision },
|
|
54
|
+
});
|
|
55
|
+
export const Event = {
|
|
56
|
+
Resync,
|
|
57
|
+
Updated,
|
|
58
|
+
Deleted,
|
|
59
|
+
Definitions: inventory(Resync, Updated, Deleted),
|
|
60
|
+
};
|