Initial commit: file-browser-picker Paseo plugin
This commit is contained in:
commit
069e1d2082
15 files changed
+5599
No files matched your search
@@ -0,0 +1,90 @@
|
||||
import { defineRpc } from "@getpaseo/plugin";
|
||||
import { z } from "zod";
|
||||
|
||||
const pickInput = z.object({
|
||||
// Folder the file browser starts in. Falls back to the start folder in
|
||||
// plugin settings, then the home folder on the host.
|
||||
initialDir: z.string().optional(),
|
||||
});
|
||||
|
||||
export const openOutput = z.discriminatedUnion("status", [
|
||||
z.object({
|
||||
status: z.literal("opened"),
|
||||
path: z.string(),
|
||||
name: z.string(),
|
||||
workspaceId: z.string(),
|
||||
projectId: z.string().nullable(),
|
||||
picker: z.string(),
|
||||
}),
|
||||
z.object({ status: z.literal("cancelled"), picker: z.string() }),
|
||||
z.object({ status: z.literal("error"), message: z.string() }),
|
||||
]);
|
||||
|
||||
export const pickAndOpenRpc = defineRpc({
|
||||
name: "picker.pick_and_open",
|
||||
input: pickInput,
|
||||
output: openOutput,
|
||||
});
|
||||
|
||||
export const openFolderRpc = defineRpc({
|
||||
name: "picker.open_folder",
|
||||
input: z.object({ path: z.string() }),
|
||||
output: openOutput,
|
||||
});
|
||||
|
||||
export const pickRpc = defineRpc({
|
||||
name: "picker.pick",
|
||||
input: pickInput,
|
||||
output: z.discriminatedUnion("status", [
|
||||
z.object({ status: z.literal("picked"), path: z.string(), picker: z.string() }),
|
||||
z.object({ status: z.literal("cancelled"), picker: z.string() }),
|
||||
z.object({ status: z.literal("error"), message: z.string() }),
|
||||
]),
|
||||
});
|
||||
|
||||
export const detectRpc = defineRpc({
|
||||
name: "picker.detect",
|
||||
input: z.object({}),
|
||||
output: z.object({
|
||||
platform: z.string(),
|
||||
desktop: z.string().nullable(),
|
||||
pickers: z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
label: z.string(),
|
||||
available: z.boolean(),
|
||||
detail: z.string(),
|
||||
}),
|
||||
),
|
||||
recommended: z.string().nullable(),
|
||||
effectivePicker: z.string().nullable(),
|
||||
defaultStartDir: z.string(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const listDirRpc = defineRpc({
|
||||
name: "picker.list_dir",
|
||||
input: z.object({
|
||||
path: z.string().optional(),
|
||||
showHidden: z.boolean().optional(),
|
||||
}),
|
||||
output: z.discriminatedUnion("status", [
|
||||
z.object({
|
||||
status: z.literal("ok"),
|
||||
path: z.string(),
|
||||
parent: z.string().nullable(),
|
||||
home: z.string(),
|
||||
entries: z.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
path: z.string(),
|
||||
isGitRepo: z.boolean(),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
z.object({
|
||||
status: z.literal("error"),
|
||||
message: z.string(),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
Reference in new issue
Block a user