@cueloop/daemon 0.1.0-alpha.15 → 0.1.0-alpha.17
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/package.json +2 -2
- package/src/api.test.ts +58 -44
- package/src/api.ts +62 -48
- package/src/client.ts +26 -23
- package/src/protocol.ts +7 -7
- package/src/review.test.ts +29 -12
- package/src/review.ts +62 -28
- package/src/server.test.ts +22 -22
- package/src/server.ts +51 -47
- package/src/single-instance.test.ts +11 -11
- package/src/store.ts +5 -5
- package/src/validate.test.ts +23 -12
- package/src/validate.ts +6 -4
package/src/validate.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Runtime validation of the wire boundary
|
|
2
|
+
* Runtime validation of the wire boundary. Everything arriving over the
|
|
3
3
|
* socket is untrusted JSON: adapters, the CLI, extensions, and any script a
|
|
4
4
|
* user writes all speak this protocol. Validating here means DaemonCore only
|
|
5
5
|
* ever sees well-formed input, and a malformed request gets a precise error
|
|
@@ -67,7 +67,7 @@ export const AnchorSchema = v.object({
|
|
|
67
67
|
/** Wire annotations arrive without createdAt - the daemon stamps it. */
|
|
68
68
|
export const AnnotationSchema = v.object({
|
|
69
69
|
id: NonEmpty,
|
|
70
|
-
/** Open kind set
|
|
70
|
+
/** Open kind set: built-ins are comment and suggestion. */
|
|
71
71
|
kind: NonEmpty,
|
|
72
72
|
anchor: AnchorSchema,
|
|
73
73
|
body: v.string(),
|
|
@@ -95,6 +95,7 @@ export const Params = {
|
|
|
95
95
|
"session.annotate": v.object({ id: SessionId, annotation: AnnotationSchema }),
|
|
96
96
|
"session.removeAnnotation": v.object({ id: SessionId, annotationId: NonEmpty }),
|
|
97
97
|
"session.setWorkingCopy": v.object({ id: SessionId, workingCopy: v.optional(v.string()) }),
|
|
98
|
+
"session.setViewed": v.object({ id: SessionId, viewedPaths: v.array(v.string()) }),
|
|
98
99
|
"session.resolve": v.object({
|
|
99
100
|
id: SessionId,
|
|
100
101
|
verdictKind: v.picklist(["comment", "approve", "request_changes"]),
|
|
@@ -117,7 +118,7 @@ export function parseParams<M extends MethodName>(method: M, params: unknown): v
|
|
|
117
118
|
const result = v.safeParse(Params[method], params ?? {});
|
|
118
119
|
if (!result.success) {
|
|
119
120
|
const issue = result.issues[0]!;
|
|
120
|
-
const path = issue.path?.map((
|
|
121
|
+
const path = issue.path?.map((pathSegment) => String(pathSegment.key)).join(".") ?? "";
|
|
121
122
|
throw new DaemonError("invalid_params", `${method}: ${path ? path + " - " : ""}${issue.message}`);
|
|
122
123
|
}
|
|
123
124
|
return result.output;
|
|
@@ -145,6 +146,7 @@ export const SessionRecordSchema = v.object({
|
|
|
145
146
|
revisions: v.array(RevisionSchema),
|
|
146
147
|
annotations: v.array(v.object({ ...AnnotationSchema.entries, createdAt: v.string() } satisfies EntriesOf<Annotation>)),
|
|
147
148
|
workingCopy: v.optional(v.string()),
|
|
149
|
+
viewedPaths: v.optional(v.array(v.string())),
|
|
148
150
|
verdict: v.nullable(VerdictSchema),
|
|
149
151
|
status: v.picklist(["pending", "resolved"]),
|
|
150
152
|
createdAt: v.string(),
|
|
@@ -154,6 +156,6 @@ export function validateSessionRecord(raw: unknown): { ok: true; value: v.InferO
|
|
|
154
156
|
const result = v.safeParse(SessionRecordSchema, raw);
|
|
155
157
|
if (result.success) return { ok: true, value: result.output };
|
|
156
158
|
const issue = result.issues[0]!;
|
|
157
|
-
const path = issue.path?.map((
|
|
159
|
+
const path = issue.path?.map((pathSegment) => String(pathSegment.key)).join(".") ?? "";
|
|
158
160
|
return { ok: false, error: `${path ? path + ": " : ""}${issue.message}` };
|
|
159
161
|
}
|