@frockbot/plugin-routines 0.0.0 → 0.1.1

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/src/testing.ts ADDED
@@ -0,0 +1,55 @@
1
+ // An in-memory `RoutineStorageV1`, for tests and for the gateway's fake
2
+ // authority. It is the Durable Object's storage contract and nothing more: a
3
+ // sorted key space, exact-key reads, and a transaction that rolls back.
4
+ import type { RoutineStorageV1, RoutineStorageWritesV1 } from "./store.js";
5
+
6
+ export interface MemoryRoutineStorageV1 extends RoutineStorageV1 {
7
+ /** Every key currently held, sorted. Useful for asserting trimming. */
8
+ keys(): string[];
9
+ }
10
+
11
+ function reads(map: Map<string, unknown>): RoutineStorageWritesV1 {
12
+ return {
13
+ get<T>(key: string): Promise<T | undefined> {
14
+ return Promise.resolve(map.get(key) as T | undefined);
15
+ },
16
+ list<T>(options: {
17
+ prefix: string;
18
+ limit?: number;
19
+ }): Promise<Map<string, T>> {
20
+ const entries = [...map.entries()]
21
+ .filter(([key]) => key.startsWith(options.prefix))
22
+ .sort(([left], [right]) => left.localeCompare(right))
23
+ .slice(0, options.limit ?? Number.POSITIVE_INFINITY);
24
+ return Promise.resolve(new Map(entries as Array<[string, T]>));
25
+ },
26
+ put(key: string, value: unknown): Promise<void> {
27
+ map.set(key, structuredClone(value));
28
+ return Promise.resolve();
29
+ },
30
+ delete(key: string): Promise<boolean> {
31
+ return Promise.resolve(map.delete(key));
32
+ },
33
+ };
34
+ }
35
+
36
+ export function createMemoryRoutineStorageV1(): MemoryRoutineStorageV1 {
37
+ const map = new Map<string, unknown>();
38
+ const base = reads(map);
39
+ return {
40
+ ...base,
41
+ keys: () => [...map.keys()].sort(),
42
+ async transaction<T>(
43
+ closure: (transaction: RoutineStorageWritesV1) => Promise<T>,
44
+ ): Promise<T> {
45
+ const snapshot = new Map(map);
46
+ try {
47
+ return await closure(base);
48
+ } catch (error) {
49
+ map.clear();
50
+ for (const [key, value] of snapshot) map.set(key, value);
51
+ throw error;
52
+ }
53
+ },
54
+ };
55
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2023",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "allowImportingTsExtensions": true,
7
+ "resolveJsonModule": true,
8
+ "strict": true,
9
+ "noEmit": true,
10
+ "skipLibCheck": true,
11
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
12
+ "types": ["bun", "vite/client"]
13
+ },
14
+ "include": ["src/**/*.ts", "src/**/*.vue", "vite.config.ts"]
15
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import vue from "@vitejs/plugin-vue";
3
+ import { defineConfig } from "vite";
4
+
5
+ export default defineConfig({
6
+ plugins: [vue()],
7
+ build: {
8
+ outDir: fileURLToPath(new URL("./dist", import.meta.url)),
9
+ emptyOutDir: true,
10
+ manifest: "manifest.json",
11
+ cssCodeSplit: false,
12
+ assetsInlineLimit: Number.POSITIVE_INFINITY,
13
+ lib: {
14
+ entry: fileURLToPath(new URL("./src/client/index.ts", import.meta.url)),
15
+ formats: ["es"],
16
+ },
17
+ rollupOptions: {
18
+ external: [
19
+ "vue",
20
+ "@frockbot/client-core",
21
+ "@frockbot/client-ui",
22
+ "@frockbot/plugin-shell/shared",
23
+ ],
24
+ output: {
25
+ entryFileNames: "assets/routines-[hash].js",
26
+ chunkFileNames: "assets/chunk-[hash].js",
27
+ assetFileNames: "assets/[name]-[hash][extname]",
28
+ },
29
+ },
30
+ },
31
+ });
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # @frockbot/plugin-routines
2
-
3
- Placeholder reserving this name. See https://github.com/timoconnellaus/frockbot.