@opencode/schema 0.0.0-dev-21086 → 0.0.0-dev-21091
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/session.d.ts +102 -1
- package/dist/session.js +55 -2
- package/package.json +1 -1
package/dist/session.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * as Session from "./session.js";
|
|
2
|
-
import { Schema } from "effect";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
3
|
import { SessionEvent } from "./session-event.js";
|
|
4
4
|
import { SessionID } from "./session-id.js";
|
|
5
5
|
import { SessionMetadata } from "./session-metadata.js";
|
|
@@ -224,3 +224,104 @@ export declare const ListAnchor: Schema.Struct<{
|
|
|
224
224
|
}>;
|
|
225
225
|
export interface ListAnchor extends Schema.Schema.Type<typeof ListAnchor> {
|
|
226
226
|
}
|
|
227
|
+
export declare const ListFilter: Schema.Struct<{
|
|
228
|
+
readonly directory: Schema.optional<Schema.brand<Schema.String, "AbsolutePath">>;
|
|
229
|
+
readonly project: Schema.optional<Schema.brand<Schema.String, "Project.ID"> & {
|
|
230
|
+
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
231
|
+
}>;
|
|
232
|
+
readonly subpath: Schema.optional<Schema.brand<Schema.String, "RelativePath">>;
|
|
233
|
+
readonly order: Schema.optional<Schema.Literals<readonly ["asc", "desc"]>>;
|
|
234
|
+
readonly search: Schema.optional<Schema.String>;
|
|
235
|
+
readonly parentID: Schema.optional<Schema.Union<readonly [Schema.brand<Schema.String, "SessionID"> & {
|
|
236
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
237
|
+
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
238
|
+
}, Schema.decodeTo<Schema.Null, Schema.Literal<"null">, never, never>]>>;
|
|
239
|
+
}>;
|
|
240
|
+
export interface ListFilter extends Schema.Schema.Type<typeof ListFilter> {
|
|
241
|
+
}
|
|
242
|
+
declare const ListCursorInput: Schema.Union<readonly [Schema.Struct<{
|
|
243
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
244
|
+
readonly anchor: Schema.Struct<{
|
|
245
|
+
readonly id: Schema.brand<Schema.String, "SessionID"> & {
|
|
246
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
247
|
+
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
248
|
+
};
|
|
249
|
+
readonly time: Schema.Finite;
|
|
250
|
+
readonly direction: Schema.Literals<readonly ["previous", "next"]>;
|
|
251
|
+
}>;
|
|
252
|
+
readonly order: Schema.optional<Schema.Literals<readonly ["asc", "desc"]>>;
|
|
253
|
+
readonly search: Schema.optional<Schema.String>;
|
|
254
|
+
readonly parentID: Schema.optional<Schema.Union<readonly [Schema.brand<Schema.String, "SessionID"> & {
|
|
255
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
256
|
+
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
257
|
+
}, Schema.decodeTo<Schema.Null, Schema.Literal<"null">, never, never>]>>;
|
|
258
|
+
}>, Schema.Struct<{
|
|
259
|
+
readonly project: Schema.brand<Schema.String, "Project.ID"> & {
|
|
260
|
+
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
261
|
+
};
|
|
262
|
+
readonly subpath: Schema.optional<Schema.brand<Schema.String, "RelativePath">>;
|
|
263
|
+
readonly anchor: Schema.Struct<{
|
|
264
|
+
readonly id: Schema.brand<Schema.String, "SessionID"> & {
|
|
265
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
266
|
+
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
267
|
+
};
|
|
268
|
+
readonly time: Schema.Finite;
|
|
269
|
+
readonly direction: Schema.Literals<readonly ["previous", "next"]>;
|
|
270
|
+
}>;
|
|
271
|
+
readonly order: Schema.optional<Schema.Literals<readonly ["asc", "desc"]>>;
|
|
272
|
+
readonly search: Schema.optional<Schema.String>;
|
|
273
|
+
readonly parentID: Schema.optional<Schema.Union<readonly [Schema.brand<Schema.String, "SessionID"> & {
|
|
274
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
275
|
+
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
276
|
+
}, Schema.decodeTo<Schema.Null, Schema.Literal<"null">, never, never>]>>;
|
|
277
|
+
}>, Schema.Struct<{
|
|
278
|
+
readonly anchor: Schema.Struct<{
|
|
279
|
+
readonly id: Schema.brand<Schema.String, "SessionID"> & {
|
|
280
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
281
|
+
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
282
|
+
};
|
|
283
|
+
readonly time: Schema.Finite;
|
|
284
|
+
readonly direction: Schema.Literals<readonly ["previous", "next"]>;
|
|
285
|
+
}>;
|
|
286
|
+
readonly order: Schema.optional<Schema.Literals<readonly ["asc", "desc"]>>;
|
|
287
|
+
readonly search: Schema.optional<Schema.String>;
|
|
288
|
+
readonly parentID: Schema.optional<Schema.Union<readonly [Schema.brand<Schema.String, "SessionID"> & {
|
|
289
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
290
|
+
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
291
|
+
}, Schema.decodeTo<Schema.Null, Schema.Literal<"null">, never, never>]>>;
|
|
292
|
+
}>]>;
|
|
293
|
+
export declare const ListCursor: Schema.brand<Schema.String, "SessionsCursor"> & {
|
|
294
|
+
make: (input: typeof ListCursorInput.Type) => string & import("effect/Brand").Brand<"SessionsCursor">;
|
|
295
|
+
parse: (input: string) => Effect.Effect<{
|
|
296
|
+
readonly directory: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
297
|
+
readonly anchor: {
|
|
298
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
299
|
+
readonly time: number;
|
|
300
|
+
readonly direction: "previous" | "next";
|
|
301
|
+
};
|
|
302
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
303
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
304
|
+
readonly search?: string | undefined;
|
|
305
|
+
} | {
|
|
306
|
+
readonly project: string & import("effect/Brand").Brand<"Project.ID">;
|
|
307
|
+
readonly anchor: {
|
|
308
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
309
|
+
readonly time: number;
|
|
310
|
+
readonly direction: "previous" | "next";
|
|
311
|
+
};
|
|
312
|
+
readonly subpath?: (string & import("effect/Brand").Brand<"RelativePath">) | undefined;
|
|
313
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
314
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
315
|
+
readonly search?: string | undefined;
|
|
316
|
+
} | {
|
|
317
|
+
readonly anchor: {
|
|
318
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
319
|
+
readonly time: number;
|
|
320
|
+
readonly direction: "previous" | "next";
|
|
321
|
+
};
|
|
322
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
323
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
324
|
+
readonly search?: string | undefined;
|
|
325
|
+
}, "Invalid cursor", never>;
|
|
326
|
+
};
|
|
327
|
+
export type ListCursor = typeof ListCursor.Type;
|
package/dist/session.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export * as Session from "./session.js";
|
|
2
|
-
import { Schema } from "effect";
|
|
2
|
+
import { Effect, Result, Schema, SchemaGetter, SchemaParser } from "effect";
|
|
3
|
+
import { Base64Url } from "effect/encoding";
|
|
3
4
|
import { Agent } from "./agent.js";
|
|
4
5
|
import { Location } from "./location.js";
|
|
5
6
|
import { Model } from "./model.js";
|
|
6
7
|
import { Project } from "./project.js";
|
|
7
|
-
import { DateTimeUtcFromMillis, optional, RelativePath } from "./schema.js";
|
|
8
|
+
import { AbsolutePath, DateTimeUtcFromMillis, optional, RelativePath, statics } from "./schema.js";
|
|
8
9
|
import { SessionEvent } from "./session-event.js";
|
|
9
10
|
import { SessionID } from "./session-id.js";
|
|
10
11
|
import { SessionMetadata } from "./session-metadata.js";
|
|
@@ -52,3 +53,55 @@ export const ListAnchor = Schema.Struct({
|
|
|
52
53
|
time: Schema.Finite,
|
|
53
54
|
direction: Schema.Literals(["previous", "next"]),
|
|
54
55
|
}).annotate({ identifier: "Session.ListAnchor" });
|
|
56
|
+
// These fields are also the session.list HTTP query parameters. Raw Schema.optional keeps that
|
|
57
|
+
// endpoint's OpenAPI parameters unchanged.
|
|
58
|
+
const ListFilterFields = {
|
|
59
|
+
order: Schema.Literals(["asc", "desc"]).pipe(Schema.optional).annotate({
|
|
60
|
+
description: "Session order for the first page. Use desc for newest first or asc for oldest first.",
|
|
61
|
+
}),
|
|
62
|
+
search: Schema.String.pipe(Schema.optional),
|
|
63
|
+
parentID: Schema.Union([
|
|
64
|
+
ID,
|
|
65
|
+
Schema.Null.pipe(Schema.encodeTo(Schema.Literal("null"), {
|
|
66
|
+
decode: SchemaGetter.transform(() => null),
|
|
67
|
+
encode: SchemaGetter.transform(() => "null"),
|
|
68
|
+
})),
|
|
69
|
+
])
|
|
70
|
+
.annotate({ description: "Filter by parent session. Use null to return only root sessions." })
|
|
71
|
+
.pipe(Schema.optional),
|
|
72
|
+
};
|
|
73
|
+
export const ListFilter = Schema.Struct({
|
|
74
|
+
...ListFilterFields,
|
|
75
|
+
directory: AbsolutePath.pipe(Schema.optional),
|
|
76
|
+
project: Project.ID.pipe(Schema.optional),
|
|
77
|
+
subpath: RelativePath.pipe(Schema.optional),
|
|
78
|
+
}).annotate({ identifier: "Session.ListFilter" });
|
|
79
|
+
const ListCursorInput = Schema.Union([
|
|
80
|
+
Schema.Struct({ ...ListFilterFields, directory: AbsolutePath, anchor: ListAnchor }),
|
|
81
|
+
Schema.Struct({
|
|
82
|
+
...ListFilterFields,
|
|
83
|
+
project: Project.ID,
|
|
84
|
+
subpath: RelativePath.pipe(Schema.optional),
|
|
85
|
+
anchor: ListAnchor,
|
|
86
|
+
}),
|
|
87
|
+
Schema.Struct({ ...ListFilterFields, anchor: ListAnchor }),
|
|
88
|
+
]);
|
|
89
|
+
const ListCursorJson = Schema.fromJsonString(ListCursorInput);
|
|
90
|
+
const encodeListCursor = Schema.encodeSync(ListCursorJson);
|
|
91
|
+
const decodeListCursor = Schema.decodeUnknownEffect(ListCursorJson);
|
|
92
|
+
export const ListCursor = Schema.String.pipe(Schema.brand("SessionsCursor"), Schema.annotate({
|
|
93
|
+
identifier: "SessionsCursor",
|
|
94
|
+
description: "Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.",
|
|
95
|
+
}), statics((schema) => {
|
|
96
|
+
// Read the default constructor without caching it on the schema, so `make` can be replaced.
|
|
97
|
+
const make = SchemaParser.make(schema);
|
|
98
|
+
return {
|
|
99
|
+
make: (input) => make(Base64Url.encode(encodeListCursor(input))),
|
|
100
|
+
parse: (input) => Effect.suspend(() => {
|
|
101
|
+
const result = Base64Url.decodeString(input);
|
|
102
|
+
return Result.isFailure(result)
|
|
103
|
+
? Effect.fail("Invalid cursor")
|
|
104
|
+
: decodeListCursor(result.success).pipe(Effect.mapError(() => "Invalid cursor"));
|
|
105
|
+
}),
|
|
106
|
+
};
|
|
107
|
+
}));
|