···11+amends "../../schema/lexicon.pkl"
22+33+lexicon = 1
44+id = "io.pocketenv.sandbox.createBackup"
55+defs = new Mapping<String, Procedure> {
66+ ["main"] {
77+ type = "procedure"
88+ description = "Create a backup of a sandbox by id"
99+ parameters {
1010+ type = "params"
1111+ required = List("id")
1212+ properties {
1313+ ["id"] = new StringType {
1414+ type = "string"
1515+ description = "The sandbox ID."
1616+ }
1717+ }
1818+ }
1919+ input {
2020+ encoding = "application/json"
2121+ schema = new ObjectType {
2222+ type = "object"
2323+ required = List("directory")
2424+ properties {
2525+ ["directory"] = new StringType {
2626+ type = "string"
2727+ description = "The directory to backup."
2828+ }
2929+ ["description"] = new StringType {
3030+ type = "string"
3131+ description = "An optional description for the backup."
3232+ }
3333+ ["ttl"] = new IntegerType {
3434+ type = "integer"
3535+ description =
3636+ "The time-to-live (TTL) for the backup in seconds. After this time, the backup will be automatically deleted. If not provided, the backup will expire after 3 days."
3737+ }
3838+ }
3939+ }
4040+ }
4141+ output {
4242+ encoding = "application/json"
4343+ schema = new Ref {
4444+ type = "ref"
4545+ ref = "io.pocketenv.sandbox.defs#backupViewBasic"
4646+ }
4747+ }
4848+ }
4949+}
+26
apps/api/pkl/defs/sandbox/defs.pkl
···442442 description = "An integration connected to the sandbox"
443443 }
444444 }
445445+ ["backupViewBasic"] = new ObjectType {
446446+ type = "object"
447447+ properties {
448448+ ["id"] = new StringType {
449449+ type = "string"
450450+ description = "Unique identifier of the backup."
451451+ }
452452+ ["directory"] = new StringType {
453453+ type = "string"
454454+ description = "The directory that was backed up."
455455+ }
456456+ ["description"] = new StringType {
457457+ type = "string"
458458+ description = "An optional description for the backup."
459459+ }
460460+ ["expiresAt"] = new IntegerType {
461461+ type = "integer"
462462+ description = "Datetime when the backup will expire and be automatically deleted."
463463+ }
464464+ ["createdAt"] = new StringType {
465465+ type = "string"
466466+ description = "datetime when the backup was created."
467467+ format = "datetime"
468468+ }
469469+ }
470470+ }
445471}
+34
apps/api/pkl/defs/sandbox/getBackups.pkl
···11+amends "../../schema/lexicon.pkl"
22+33+lexicon = 1
44+id = "io.pocketenv.sandbox.getBackups"
55+defs = new Mapping<String, Query> {
66+ ["main"] {
77+ type = "query"
88+ description = "Get the list of backups for a sandbox."
99+ parameters {
1010+ type = "params"
1111+ required = List("id")
1212+ properties {
1313+ ["id"] = new StringType {
1414+ type = "string"
1515+ description = "The sandbox ID."
1616+ }
1717+ }
1818+ }
1919+ output {
2020+ encoding = "application/json"
2121+ schema = new ObjectType {
2222+ type = "object"
2323+ properties {
2424+ ["backups"] = new Array {
2525+ type = "array"
2626+ items = new Ref {
2727+ ref = "io.pocketenv.port.defs#backupViewBasic"
2828+ }
2929+ }
3030+ }
3131+ }
3232+ }
3333+ }
3434+}
+33
apps/api/pkl/defs/sandbox/restoreBackup.pkl
···11+amends "../../schema/lexicon.pkl"
22+33+lexicon = 1
44+id = "io.pocketenv.sandbox.restoreBackup"
55+defs = new Mapping<String, Procedure> {
66+ ["main"] {
77+ type = "procedure"
88+ description = "Restore a backup of a sandbox"
99+ parameters {
1010+ type = "params"
1111+ required = List("id")
1212+ properties {
1313+ ["id"] = new StringType {
1414+ type = "string"
1515+ description = "The sandbox ID."
1616+ }
1717+ }
1818+ }
1919+ input {
2020+ encoding = "application/json"
2121+ schema {
2222+ type = "object"
2323+ required = List("backupId")
2424+ properties {
2525+ ["backupId"] = new StringType {
2626+ type = "string"
2727+ description = "The backup ID to restore."
2828+ }
2929+ }
3030+ }
3131+ }
3232+ }
3333+}
+6-3
apps/api/src/__tests__/xrpc/helpers.ts
···2323 {
2424 get(_t, key: string | symbol) {
2525 if (key === "execute") return () => Promise.resolve(results[idx++]);
2626- if (key === "transaction") return (fn: (tx: any) => any) => fn(chain());
2626+ if (key === "transaction")
2727+ return (fn: (tx: any) => any) => fn(chain());
2728 if (
2829 key === "then" ||
2930 key === "catch" ||
···116117 },
117118 };
118119 register(server, ctx);
119119- if (!capturedHandler) throw new Error(`Handler for ${method} was not registered`);
120120+ if (!capturedHandler)
121121+ throw new Error(`Handler for ${method} was not registered`);
120122 return capturedHandler;
121123}
122124···138140 },
139141 };
140142 register(server, ctx);
141141- if (!capturedHandler) throw new Error(`Handler for ${method} was not registered`);
143143+ if (!capturedHandler)
144144+ throw new Error(`Handler for ${method} was not registered`);
142145 return capturedHandler;
143146}
144147
···1818import type * as IoPocketenvFileGetFiles from "./types/io/pocketenv/file/getFiles";
1919import type * as IoPocketenvFileUpdateFile from "./types/io/pocketenv/file/updateFile";
2020import type * as IoPocketenvSandboxClaimSandbox from "./types/io/pocketenv/sandbox/claimSandbox";
2121+import type * as IoPocketenvSandboxCreateBackup from "./types/io/pocketenv/sandbox/createBackup";
2122import type * as IoPocketenvSandboxCreateIntegration from "./types/io/pocketenv/sandbox/createIntegration";
2223import type * as IoPocketenvSandboxCreateSandbox from "./types/io/pocketenv/sandbox/createSandbox";
2324import type * as IoPocketenvSandboxDeleteSandbox from "./types/io/pocketenv/sandbox/deleteSandbox";
2425import type * as IoPocketenvSandboxExec from "./types/io/pocketenv/sandbox/exec";
2526import type * as IoPocketenvSandboxExposePort from "./types/io/pocketenv/sandbox/exposePort";
2627import type * as IoPocketenvSandboxExposeVscode from "./types/io/pocketenv/sandbox/exposeVscode";
2828+import type * as IoPocketenvSandboxGetBackups from "./types/io/pocketenv/sandbox/getBackups";
2729import type * as IoPocketenvSandboxGetExposedPorts from "./types/io/pocketenv/sandbox/getExposedPorts";
2830import type * as IoPocketenvSandboxGetIntegrations from "./types/io/pocketenv/sandbox/getIntegrations";
2931import type * as IoPocketenvSandboxGetPreferences from "./types/io/pocketenv/sandbox/getPreferences";
···3840import type * as IoPocketenvSandboxPutSshKeys from "./types/io/pocketenv/sandbox/putSshKeys";
3941import type * as IoPocketenvSandboxPutTailscaleAuthKey from "./types/io/pocketenv/sandbox/putTailscaleAuthKey";
4042import type * as IoPocketenvSandboxPutTailscaleToken from "./types/io/pocketenv/sandbox/putTailscaleToken";
4343+import type * as IoPocketenvSandboxRestoreBackup from "./types/io/pocketenv/sandbox/restoreBackup";
4144import type * as IoPocketenvSandboxStartSandbox from "./types/io/pocketenv/sandbox/startSandbox";
4245import type * as IoPocketenvSandboxStopSandbox from "./types/io/pocketenv/sandbox/stopSandbox";
4346import type * as IoPocketenvSandboxUnexposePort from "./types/io/pocketenv/sandbox/unexposePort";
···237240 return this._server.xrpc.method(nsid, cfg);
238241 }
239242243243+ createBackup<AV extends AuthVerifier>(
244244+ cfg: ConfigOf<
245245+ AV,
246246+ IoPocketenvSandboxCreateBackup.Handler<ExtractAuth<AV>>,
247247+ IoPocketenvSandboxCreateBackup.HandlerReqCtx<ExtractAuth<AV>>
248248+ >,
249249+ ) {
250250+ const nsid = "io.pocketenv.sandbox.createBackup"; // @ts-ignore
251251+ return this._server.xrpc.method(nsid, cfg);
252252+ }
253253+240254 createIntegration<AV extends AuthVerifier>(
241255 cfg: ConfigOf<
242256 AV,
···303317 return this._server.xrpc.method(nsid, cfg);
304318 }
305319320320+ getBackups<AV extends AuthVerifier>(
321321+ cfg: ConfigOf<
322322+ AV,
323323+ IoPocketenvSandboxGetBackups.Handler<ExtractAuth<AV>>,
324324+ IoPocketenvSandboxGetBackups.HandlerReqCtx<ExtractAuth<AV>>
325325+ >,
326326+ ) {
327327+ const nsid = "io.pocketenv.sandbox.getBackups"; // @ts-ignore
328328+ return this._server.xrpc.method(nsid, cfg);
329329+ }
330330+306331 getExposedPorts<AV extends AuthVerifier>(
307332 cfg: ConfigOf<
308333 AV,
···454479 >,
455480 ) {
456481 const nsid = "io.pocketenv.sandbox.putTailscaleToken"; // @ts-ignore
482482+ return this._server.xrpc.method(nsid, cfg);
483483+ }
484484+485485+ restoreBackup<AV extends AuthVerifier>(
486486+ cfg: ConfigOf<
487487+ AV,
488488+ IoPocketenvSandboxRestoreBackup.Handler<ExtractAuth<AV>>,
489489+ IoPocketenvSandboxRestoreBackup.HandlerReqCtx<ExtractAuth<AV>>
490490+ >,
491491+ ) {
492492+ const nsid = "io.pocketenv.sandbox.restoreBackup"; // @ts-ignore
457493 return this._server.xrpc.method(nsid, cfg);
458494 }
459495
···333333}
334334335335export type IntegrationsView = IntegrationView[];
336336+337337+export interface BackupViewBasic {
338338+ /** Unique identifier of the backup. */
339339+ id?: string;
340340+ /** The directory that was backed up. */
341341+ directory?: string;
342342+ /** The time-to-live (TTL) for the backup in seconds. After this time, the backup will be automatically deleted. */
343343+ ttl?: number;
344344+ /** datetime when the backup was created. */
345345+ createdAt?: string;
346346+ [k: string]: unknown;
347347+}
348348+349349+export function isBackupViewBasic(v: unknown): v is BackupViewBasic {
350350+ return (
351351+ isObj(v) &&
352352+ hasProp(v, "$type") &&
353353+ v.$type === "io.pocketenv.sandbox.defs#backupViewBasic"
354354+ );
355355+}
356356+357357+export function validateBackupViewBasic(v: unknown): ValidationResult {
358358+ return lexicons.validate("io.pocketenv.sandbox.defs#backupViewBasic", v);
359359+}