@insta-dev01/insta-plugin-openclaw 1.0.0

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.
@@ -0,0 +1,53 @@
1
+ import { mkdtemp, rm } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { describe, it, expect, afterEach, beforeEach } from "vitest";
5
+ import { readSession, writeSession } from "../src/utils/session.js";
6
+
7
+ let workDir: string;
8
+
9
+ beforeEach(async () => {
10
+ workDir = await mkdtemp(join(tmpdir(), "session-test-"));
11
+ });
12
+
13
+ afterEach(async () => {
14
+ await rm(workDir, { recursive: true, force: true });
15
+ });
16
+
17
+ describe("readSession", () => {
18
+ it("returns null when file does not exist", async () => {
19
+ const result = await readSession(workDir);
20
+ expect(result).toBeNull();
21
+ });
22
+
23
+ it("returns session id after write", async () => {
24
+ await writeSession(workDir, "sess_abc123");
25
+ const result = await readSession(workDir);
26
+ expect(result).toBe("sess_abc123");
27
+ });
28
+ });
29
+
30
+ describe("writeSession", () => {
31
+ it("creates directory and writes file", async () => {
32
+ await writeSession(workDir, "sess_abc123");
33
+ const result = await readSession(workDir);
34
+ expect(result).toBe("sess_abc123");
35
+ });
36
+
37
+ it("overwrites existing session", async () => {
38
+ await writeSession(workDir, "sess_old");
39
+ await writeSession(workDir, "sess_new");
40
+ const result = await readSession(workDir);
41
+ expect(result).toBe("sess_new");
42
+ });
43
+
44
+ it("handles concurrent writes without corruption", async () => {
45
+ const writes = Array.from({ length: 20 }, (_, i) =>
46
+ writeSession(workDir, `sess_${i}`),
47
+ );
48
+ await Promise.all(writes);
49
+ const result = await readSession(workDir);
50
+ expect(result).not.toBeNull();
51
+ expect(result!.startsWith("sess_")).toBe(true);
52
+ });
53
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2022"],
5
+ "module": "ES2022",
6
+ "moduleResolution": "bundler",
7
+
8
+ "strict": true,
9
+ "noImplicitAny": true,
10
+ "strictNullChecks": true,
11
+ "strictFunctionTypes": true,
12
+ "strictBindCallApply": true,
13
+ "strictPropertyInitialization": true,
14
+ "noImplicitThis": true,
15
+ "alwaysStrict": true,
16
+
17
+ "noUnusedLocals": false,
18
+ "noUnusedParameters": false,
19
+ "noImplicitReturns": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+ "noUncheckedIndexedAccess": true,
22
+ "noImplicitOverride": true,
23
+ "noPropertyAccessFromIndexSignature": true,
24
+
25
+ "esModuleInterop": true,
26
+ "allowSyntheticDefaultImports": true,
27
+ "resolveJsonModule": true,
28
+ "isolatedModules": true,
29
+
30
+ "declaration": false,
31
+ "sourceMap": true,
32
+ "outDir": "./dist",
33
+ "removeComments": false,
34
+ "noEmit": true,
35
+
36
+ "forceConsistentCasingInFileNames": true,
37
+ "skipLibCheck": true
38
+ },
39
+ "include": [
40
+ "*.ts",
41
+ "src/**/*.ts",
42
+ "tests/**/*.ts"
43
+ ],
44
+ "exclude": [
45
+ "node_modules",
46
+ "dist",
47
+ "coverage"
48
+ ]
49
+ }
@@ -0,0 +1,26 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'node',
7
+ coverage: {
8
+ provider: 'v8',
9
+ reporter: ['text', 'json', 'html'],
10
+ exclude: [
11
+ 'node_modules/',
12
+ 'tests/',
13
+ '*.config.ts',
14
+ 'dist/',
15
+ ],
16
+ thresholds: {
17
+ lines: 80,
18
+ functions: 85,
19
+ branches: 75,
20
+ statements: 80,
21
+ },
22
+ },
23
+ include: ['tests/**/*.test.ts'],
24
+ exclude: ['node_modules/', 'dist/'],
25
+ },
26
+ });