@regressionproof/client 0.0.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/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ lts/*
@@ -0,0 +1,58 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "type": "node",
6
+ "request": "attach",
7
+ "name": "attach.tests",
8
+ "port": 5200,
9
+ "restart": true,
10
+ "timeout": 10000
11
+ },
12
+ {
13
+ "type": "node",
14
+ "request": "launch",
15
+ "name": "test.file",
16
+ "runtimeExecutable": "node",
17
+ "runtimeArgs": [
18
+ "--inspect-brk",
19
+ "--trace-warnings",
20
+ "${workspaceFolder}/node_modules/.bin/jest",
21
+ "${fileBasenameNoExtension}",
22
+ "--detectOpenHandles"
23
+ ],
24
+ "cwd": "${workspaceFolder}",
25
+ "console": "integratedTerminal",
26
+ "internalConsoleOptions": "neverOpen"
27
+ },
28
+ {
29
+ "type": "node",
30
+ "request": "launch",
31
+ "name": "test.all",
32
+ "runtimeExecutable": "node",
33
+ "runtimeArgs": [
34
+ "--inspect-brk",
35
+ "--trace-warnings",
36
+ "${workspaceFolder}/node_modules/.bin/jest"
37
+ ],
38
+ "cwd": "${workspaceFolder}",
39
+ "console": "integratedTerminal",
40
+ "internalConsoleOptions": "neverOpen"
41
+ },
42
+ {
43
+ "type": "node",
44
+ "request": "launch",
45
+ "name": "boot",
46
+ "runtimeExecutable": "yarn",
47
+ "runtimeArgs": [
48
+ "run",
49
+ "--inspect-brk",
50
+ "--trace-warnings",
51
+ "boot"
52
+ ],
53
+ "cwd": "${workspaceFolder}",
54
+ "console": "integratedTerminal",
55
+ "internalConsoleOptions": "neverOpen"
56
+ }
57
+ ]
58
+ }
@@ -0,0 +1,67 @@
1
+ {
2
+ "debug.node.autoAttach": "on",
3
+ "git.ignoreLimitWarning": true,
4
+ "javascript.validate.enable": false,
5
+ "files.watcherExclude": {
6
+ "**/.git/objects/**": true,
7
+ "**/.git/subtree-cache/**": true,
8
+ "**/build/**": true,
9
+ "**/node_modules/**": true,
10
+ },
11
+ "search.exclude": {
12
+ "**/build/**": true,
13
+ "**/node_modules/**": true,
14
+ "**/.next/**": true
15
+ },
16
+ "editor.maxTokenizationLineLength": 20000000,
17
+ "[javascript]": {
18
+ "editor.formatOnSave": false
19
+ },
20
+ "[javascriptreact]": {
21
+ "editor.formatOnSave": false
22
+ },
23
+ "[typescript]": {
24
+ "editor.formatOnSave": false
25
+ },
26
+ "[typescriptreact]": {
27
+ "editor.formatOnSave": false
28
+ },
29
+ "[handlebars]": {
30
+ "editor.formatOnSave": false
31
+ },
32
+ "typescript.tsdk": "node_modules/typescript/lib",
33
+ "cSpell.ignorePaths": [
34
+ "**/package-lock.json",
35
+ "**/node_modules/**",
36
+ "**/build/**",
37
+ "**/vscode-extension/**",
38
+ "**/.git/objects/**",
39
+ ".vscode",
40
+ ".spruce"
41
+ ],
42
+ "cSpell.words": [
43
+ "arkit",
44
+ "autogenerated",
45
+ "scrollable",
46
+ "serializable"
47
+ ],
48
+ "debug.javascript.unmapMissingSources": true,
49
+ "javascript.preferences.importModuleSpecifier": "relative",
50
+ "typescript.preferences.importModuleSpecifier": "relative",
51
+ "eslint.useFlatConfig": true,
52
+ "eslint.enable": true,
53
+ "eslint.validate": [
54
+ "javascript",
55
+ "javascriptreact",
56
+ "typescript",
57
+ "typescriptreact"
58
+ ],
59
+ "eslint.workingDirectories": [
60
+ "./"
61
+ ],
62
+ "typescript.validate.enable": true,
63
+ "editor.formatOnSave": false,
64
+ "editor.codeActionsOnSave": {
65
+ "source.fixAll.eslint": "always"
66
+ }
67
+ }
@@ -0,0 +1,112 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "tasks": [
4
+ {
5
+ "type": "npm",
6
+ "script": "watch.build.dev",
7
+ "group": "build",
8
+ "label": "watch.build.dev & problem.watcher",
9
+ "isBackground": true,
10
+ "runOptions": {
11
+ "runOn": "folderOpen"
12
+ },
13
+ "promptOnClose": false,
14
+ "presentation": {
15
+ "focus": false,
16
+ "reveal": "never"
17
+ },
18
+ "problemMatcher": {
19
+ "base": "$tsc-watch",
20
+ "applyTo": "allDocuments"
21
+ }
22
+ },
23
+ {
24
+ "label": "test.file",
25
+ "command": "spruce",
26
+ "args": [
27
+ "test",
28
+ "--inspect",
29
+ "5200",
30
+ "--pattern",
31
+ "${fileBasenameNoExtension}",
32
+ "--watchMode",
33
+ "standard"
34
+ ],
35
+ "promptOnClose": false,
36
+ "group": {
37
+ "kind": "test",
38
+ "isDefault": true
39
+ },
40
+ "presentation": {
41
+ "reveal": "always",
42
+ "panel": "dedicated",
43
+ },
44
+ "problemMatcher": []
45
+ },
46
+ {
47
+ "label": "test.reporter",
48
+ "command": "spruce",
49
+ "args": [
50
+ "test",
51
+ "--shouldHoldAtStart",
52
+ "true",
53
+ "--watchMode",
54
+ "smart"
55
+ ],
56
+ "promptOnClose": false,
57
+ "group": "test",
58
+ "runOptions": {
59
+ "runOn": "folderOpen"
60
+ },
61
+ "presentation": {
62
+ "panel": "shared",
63
+ "focus": true,
64
+ "reveal": "always"
65
+ }
66
+ },
67
+ {
68
+ "label": "spruce",
69
+ "type": "shell",
70
+ "command": "spruce ${input:spruceCommand}",
71
+ "problemMatcher": [],
72
+ "presentation": {
73
+ "reveal": "always",
74
+ "focus": true,
75
+ "panel": "new",
76
+ "clear": false
77
+ }
78
+ },
79
+ {
80
+ "label": "shell",
81
+ "type": "shell",
82
+ "command": "${input:command} ${input:optionsCommand}",
83
+ "problemMatcher": [],
84
+ "presentation": {
85
+ "reveal": "always",
86
+ "focus": true,
87
+ "panel": "new",
88
+ "clear": false
89
+ }
90
+ }
91
+ ],
92
+ "inputs": [
93
+ {
94
+ "id": "spruceCommand",
95
+ "description": "spruce command",
96
+ "default": "create.test",
97
+ "type": "promptString"
98
+ },
99
+ {
100
+ "id": "command",
101
+ "description": "command",
102
+ "default": "yarn",
103
+ "type": "promptString"
104
+ },
105
+ {
106
+ "id": "optionsCommand",
107
+ "description": "optionsCommand",
108
+ "default": "add",
109
+ "type": "promptString"
110
+ }
111
+ ]
112
+ }
@@ -0,0 +1,3 @@
1
+ import eslintConfigSpruce from 'eslint-config-spruce'
2
+
3
+ export default eslintConfigSpruce
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@regressionproof/client",
3
+ "version": "0.0.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "main": "./build/index.js",
8
+ "types": "./build/index.d.ts",
9
+ "module": "./build/esm/index.js",
10
+ "sideEffects": false,
11
+ "exports": {
12
+ ".": {
13
+ "import": {
14
+ "types": "./build/index.d.ts",
15
+ "default": "./build/index.js"
16
+ },
17
+ "require": {
18
+ "types": "./build/index.d.ts",
19
+ "default": "./build/index.js"
20
+ }
21
+ }
22
+ },
23
+ "scripts": {
24
+ "build.ci": "yarn run build.tsc && yarn run build.resolve-paths && yarn run lint",
25
+ "build.dev": "yarn run build.tsc --sourceMap ; yarn run resolve-paths.lint",
26
+ "build.copy-files": "mkdir -p build && rsync -avzq --exclude='*.ts' ./src/ ./build/",
27
+ "build.resolve-paths": "resolve-path-aliases --target build --patterns '**/*.js,**/*.d.ts'",
28
+ "build.tsc": "yarn run build.copy-files && tsc",
29
+ "build.dist": "tsc --project tsconfig.dist.json && yarn build.resolve-paths && mv build esm && yarn build.esm-postbuild && yarn build.tsc && yarn build.resolve-paths && mv esm build/",
30
+ "build.esm-postbuild": "esm-postbuild --target esm --patterns '**/*.js'",
31
+ "clean": "yarn run clean.build",
32
+ "clean.all": "yarn run clean.dependencies && yarn run clean.build",
33
+ "clean.build": "rm -rf build/",
34
+ "clean.dependencies": "rm -rf node_modules/ package-lock.json yarn.lock",
35
+ "fix.lint": "eslint --fix --cache '**/*.ts'",
36
+ "lint": "eslint --cache '**/*.ts'",
37
+ "lint.tsc": "tsc -p . --noEmit",
38
+ "post.watch.build": "yarn run build.copy-files && yarn run build.resolve-paths",
39
+ "rebuild": "yarn run clean.all && yarn install && yarn run build.dev",
40
+ "update.dependencies": "yarn run clean.dependencies && yarn",
41
+ "resolve-paths.lint": "yarn run build.resolve-paths ; yarn run lint",
42
+ "test": "jest --passWithNoTests",
43
+ "watch.build.dev": "tsc-watch --sourceMap --onCompilationComplete 'yarn run post.watch.build'",
44
+ "watch.rebuild": "yarn run clean.all && yarn install && yarn run watch.build.dev",
45
+ "watch.tsc": "tsc -w"
46
+ },
47
+ "dependencies": {
48
+ "@regressionproof/api": "^0.0.1"
49
+ },
50
+ "devDependencies": {
51
+ "@sprucelabs/esm-postbuild": "^9.0.13",
52
+ "@sprucelabs/resolve-path-aliases": "^4.0.12",
53
+ "@types/node": "^25.0.3",
54
+ "chokidar-cli": "^3.0.0",
55
+ "eslint": "^9.39.2",
56
+ "eslint-config-spruce": "^11.2.26",
57
+ "prettier": "^3.7.4",
58
+ "ts-node": "^10.9.2",
59
+ "tsc-watch": "^7.2.0",
60
+ "typescript": "^5.9.3"
61
+ },
62
+ "description": "connect to the regression proof api to store snapshots",
63
+ "skill": {
64
+ "namespace": "regressionproof-client"
65
+ }
66
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "scriptUpdater": {
3
+ "skipped": []
4
+ },
5
+ "writer": {
6
+ "skipped": [
7
+ "tsconfig.json"
8
+ ]
9
+ }
10
+ }
@@ -0,0 +1,78 @@
1
+ import { SpruceError } from '@regressionproof/api'
2
+
3
+ export default class RegressionProofClient {
4
+ private baseUrl: string
5
+
6
+ public constructor(baseUrl: string) {
7
+ this.baseUrl = baseUrl
8
+ }
9
+
10
+ public async checkNameAvailability(name: string): Promise<boolean> {
11
+ const response = await fetch(`${this.baseUrl}/check-name/${name}`)
12
+ const { available } = (await response.json()) as { available: boolean }
13
+ return available
14
+ }
15
+
16
+ public async registerProject(
17
+ options: RegisterProjectOptions
18
+ ): Promise<ProjectCredentials> {
19
+ const response = await fetch(`${this.baseUrl}/register`, {
20
+ method: 'POST',
21
+ headers: {
22
+ 'Content-Type': 'application/json',
23
+ },
24
+ body: JSON.stringify(options),
25
+ })
26
+
27
+ if (!response.ok) {
28
+ throw await this.parseErrorResponse(response)
29
+ }
30
+
31
+ return response.json()
32
+ }
33
+
34
+ public async refreshCredentials(
35
+ options: RegisterProjectOptions
36
+ ): Promise<ProjectCredentials> {
37
+ const response = await fetch(`${this.baseUrl}/refresh`, {
38
+ method: 'POST',
39
+ headers: {
40
+ 'Content-Type': 'application/json',
41
+ },
42
+ body: JSON.stringify(options),
43
+ })
44
+
45
+ if (!response.ok) {
46
+ throw await this.parseErrorResponse(response)
47
+ }
48
+
49
+ return response.json()
50
+ }
51
+
52
+ private async parseErrorResponse(response: Response): Promise<SpruceError> {
53
+ try {
54
+ const body = await response.json()
55
+ if (body.error?.code) {
56
+ return new SpruceError(body.error)
57
+ }
58
+ return new SpruceError({
59
+ code: 'GIT_SERVER_ERROR',
60
+ message: `Request failed: ${response.statusText}`,
61
+ })
62
+ } catch {
63
+ return new SpruceError({
64
+ code: 'GIT_SERVER_ERROR',
65
+ message: `Request failed: ${response.statusText}`,
66
+ })
67
+ }
68
+ }
69
+ }
70
+
71
+ export interface RegisterProjectOptions {
72
+ name: string
73
+ }
74
+
75
+ export interface ProjectCredentials {
76
+ url: string
77
+ token: string
78
+ }
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export {
2
+ default as RegressionProofClient,
3
+ RegisterProjectOptions,
4
+ ProjectCredentials,
5
+ } from './RegressionProofClient.js'
6
+ export { default } from './RegressionProofClient.js'
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ES2020",
4
+ "target": "ES6",
5
+ "lib": ["ES2020", "DOM"],
6
+ "skipLibCheck": true,
7
+ "esModuleInterop": true,
8
+ "moduleResolution": "node",
9
+ "declaration": true,
10
+ "noImplicitAny": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "noImplicitReturns": true,
13
+ "strict": true,
14
+ "noUnusedLocals": true,
15
+ "resolveJsonModule": true,
16
+ "sourceMap": false,
17
+ "outDir": "./build",
18
+ "baseUrl": "src",
19
+ "experimentalDecorators": true,
20
+ "paths": {
21
+ "#spruce/*": [".spruce/*"]
22
+ }
23
+ },
24
+ "include": ["./src/*.ts", "./src/**/*.ts"],
25
+ "exclude": ["**/node_modules/*", "build/*", "esm/*"]
26
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "skipLibCheck": true,
4
+ "module": "CommonJS",
5
+ "esModuleInterop": true,
6
+ "target": "ES2020",
7
+ "lib": ["DOM", "ES2022"],
8
+ "declaration": true,
9
+ "noImplicitAny": true,
10
+ "allowJs": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "noImplicitReturns": true,
13
+ "strict": true,
14
+ "noUnusedLocals": true,
15
+ "resolveJsonModule": true,
16
+ "moduleResolution": "node",
17
+ "sourceMap": false,
18
+ "outDir": "build",
19
+ "baseUrl": "src",
20
+ "experimentalDecorators": true,
21
+ "paths": {
22
+ "#spruce/*": [".spruce/*"]
23
+ }
24
+ },
25
+ "include": ["./src/*.ts", "./src/**/*.ts", "./src/.spruce/**/*"],
26
+ "exclude": ["build", "esm"]
27
+ }