Refactoring
This commit is contained in:
@@ -5,10 +5,10 @@ import { readYamlPage } from "./yaml_page.ts";
|
||||
// of not decising this SECRETS page to other places
|
||||
export async function readSecrets(keys: string[]): Promise<any[]> {
|
||||
try {
|
||||
let allSecrets = await readYamlPage("SECRETS", ["yaml", "secrets"]);
|
||||
let collectedSecrets: any[] = [];
|
||||
for (let key of keys) {
|
||||
let secret = allSecrets[key];
|
||||
const allSecrets = await readYamlPage("SECRETS", ["yaml", "secrets"]);
|
||||
const collectedSecrets: any[] = [];
|
||||
for (const key of keys) {
|
||||
const secret = allSecrets[key];
|
||||
if (secret) {
|
||||
collectedSecrets.push(secret);
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { syscall } from "./syscall.ts";
|
||||
import type { AttachmentMeta, PageMeta } from "../../web/types.ts";
|
||||
import { FileMeta } from "$sb/types.ts";
|
||||
|
||||
export function listPages(unfiltered = false): Promise<PageMeta[]> {
|
||||
return syscall("space.listPages", unfiltered);
|
||||
@@ -27,7 +28,7 @@ export function listPlugs(): Promise<string[]> {
|
||||
return syscall("space.listPlugs");
|
||||
}
|
||||
|
||||
export function listAttachments(): Promise<PageMeta[]> {
|
||||
export function listAttachments(): Promise<AttachmentMeta[]> {
|
||||
return syscall("space.listAttachments");
|
||||
}
|
||||
|
||||
@@ -66,3 +67,27 @@ export function writeAttachment(
|
||||
export function deleteAttachment(name: string): Promise<void> {
|
||||
return syscall("space.deleteAttachment", name);
|
||||
}
|
||||
|
||||
// FS
|
||||
export function listFiles(): Promise<FileMeta[]> {
|
||||
return syscall("space.listFiles");
|
||||
}
|
||||
|
||||
export function readFile(name: string): Promise<Uint8Array> {
|
||||
return syscall("space.readFile", name);
|
||||
}
|
||||
|
||||
export function getFileMeta(name: string): Promise<FileMeta> {
|
||||
return syscall("space.getFileMeta", name);
|
||||
}
|
||||
|
||||
export function writeFile(
|
||||
name: string,
|
||||
data: Uint8Array,
|
||||
): Promise<FileMeta> {
|
||||
return syscall("space.writeFile", name, data);
|
||||
}
|
||||
|
||||
export function deleteFile(name: string): Promise<void> {
|
||||
return syscall("space.deleteFile", name);
|
||||
}
|
||||
|
||||
@@ -10,3 +10,12 @@ export type QueueStats = {
|
||||
processing: number;
|
||||
dlq: number;
|
||||
};
|
||||
|
||||
export type FileMeta = {
|
||||
name: string;
|
||||
lastModified: number;
|
||||
contentType: string;
|
||||
size: number;
|
||||
perm: "ro" | "rw";
|
||||
noSync?: boolean;
|
||||
} & Record<string, any>;
|
||||
|
||||
Reference in New Issue
Block a user