Refactor runtime app architecture (#1878)
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -17,13 +17,34 @@ const NoteShowParams = NoteScopedParams.extend({
|
||||
const NoteCreateParams = NoteScopedParams.extend({
|
||||
title: requiredString('Missing note title'),
|
||||
bodyMarkdown: OptionalString,
|
||||
makeActive: z.boolean().optional()
|
||||
makeActive: z.boolean().optional(),
|
||||
createdBySessionId: z.string().nullable().optional()
|
||||
})
|
||||
|
||||
const NoteSaveParams = NoteScopedParams.extend({
|
||||
note: requiredString('Missing note selector'),
|
||||
title: OptionalString,
|
||||
bodyMarkdown: requiredString('Missing note body'),
|
||||
revision: OptionalFiniteNumber,
|
||||
makeActive: z.boolean().optional(),
|
||||
updatedBySessionId: z.string().nullable().optional()
|
||||
})
|
||||
|
||||
const NoteRenameParams = NoteScopedParams.extend({
|
||||
note: requiredString('Missing note selector'),
|
||||
title: requiredString('Missing note title'),
|
||||
updatedBySessionId: z.string().nullable().optional()
|
||||
})
|
||||
|
||||
const NoteDeleteParams = NoteScopedParams.extend({
|
||||
note: requiredString('Missing note selector')
|
||||
})
|
||||
|
||||
const NoteAppendParams = NoteScopedParams.extend({
|
||||
note: requiredString('Missing note selector'),
|
||||
bodyMarkdown: requiredString('Missing note body'),
|
||||
makeActive: z.boolean().optional()
|
||||
makeActive: z.boolean().optional(),
|
||||
updatedBySessionId: z.string().nullable().optional()
|
||||
})
|
||||
|
||||
const NoteSearchParams = NoteScopedParams.extend({
|
||||
@@ -31,6 +52,11 @@ const NoteSearchParams = NoteScopedParams.extend({
|
||||
limit: OptionalFiniteNumber
|
||||
})
|
||||
|
||||
const NoteLinkParams = NoteScopedParams.extend({
|
||||
note: requiredString('Missing note selector'),
|
||||
kind: z.enum(['active', 'referenced'])
|
||||
})
|
||||
|
||||
export const NOTE_METHODS: readonly RpcAnyMethod[] = [
|
||||
defineMethod({
|
||||
name: 'note.list',
|
||||
@@ -58,7 +84,42 @@ export const NOTE_METHODS: readonly RpcAnyMethod[] = [
|
||||
worktreeSelector: params.worktree,
|
||||
title: params.title,
|
||||
bodyMarkdown: params.bodyMarkdown,
|
||||
makeActive: params.makeActive
|
||||
makeActive: params.makeActive,
|
||||
createdBySessionId: params.createdBySessionId
|
||||
})
|
||||
}),
|
||||
defineMethod({
|
||||
name: 'note.save',
|
||||
params: NoteSaveParams,
|
||||
handler: async (params, { runtime }) =>
|
||||
await runtime.saveNote({
|
||||
worktreeSelector: params.worktree,
|
||||
note: params.note,
|
||||
title: params.title,
|
||||
bodyMarkdown: params.bodyMarkdown,
|
||||
revision: params.revision,
|
||||
makeActive: params.makeActive,
|
||||
updatedBySessionId: params.updatedBySessionId
|
||||
})
|
||||
}),
|
||||
defineMethod({
|
||||
name: 'note.rename',
|
||||
params: NoteRenameParams,
|
||||
handler: async (params, { runtime }) =>
|
||||
await runtime.renameNote({
|
||||
worktreeSelector: params.worktree,
|
||||
note: params.note,
|
||||
title: params.title,
|
||||
updatedBySessionId: params.updatedBySessionId
|
||||
})
|
||||
}),
|
||||
defineMethod({
|
||||
name: 'note.delete',
|
||||
params: NoteDeleteParams,
|
||||
handler: async (params, { runtime }) =>
|
||||
await runtime.deleteNote({
|
||||
worktreeSelector: params.worktree,
|
||||
note: params.note
|
||||
})
|
||||
}),
|
||||
defineMethod({
|
||||
@@ -69,7 +130,8 @@ export const NOTE_METHODS: readonly RpcAnyMethod[] = [
|
||||
worktreeSelector: params.worktree,
|
||||
note: params.note,
|
||||
bodyMarkdown: params.bodyMarkdown,
|
||||
makeActive: params.makeActive
|
||||
makeActive: params.makeActive,
|
||||
updatedBySessionId: params.updatedBySessionId
|
||||
})
|
||||
}),
|
||||
defineMethod({
|
||||
@@ -81,5 +143,23 @@ export const NOTE_METHODS: readonly RpcAnyMethod[] = [
|
||||
query: params.query,
|
||||
limit: params.limit
|
||||
})
|
||||
}),
|
||||
defineMethod({
|
||||
name: 'note.link',
|
||||
params: NoteLinkParams,
|
||||
handler: async (params, { runtime }) =>
|
||||
await runtime.linkNote({
|
||||
worktreeSelector: params.worktree,
|
||||
note: params.note,
|
||||
kind: params.kind
|
||||
})
|
||||
}),
|
||||
defineMethod({
|
||||
name: 'note.panelState',
|
||||
params: NoteScopedParams,
|
||||
handler: async (params, { runtime }) =>
|
||||
await runtime.resolveNotesPanelOpenStateForWorktree({
|
||||
worktreeSelector: params.worktree
|
||||
})
|
||||
})
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user