@socketsecurity/sdk 1.11.1 → 2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/sdk",
3
- "version": "1.11.1",
3
+ "version": "2.0.1",
4
4
  "license": "MIT",
5
5
  "description": "SDK for the Socket API client",
6
6
  "author": {
@@ -13,17 +13,17 @@
13
13
  "type": "git",
14
14
  "url": "git://github.com/SocketDev/socket-sdk-js.git"
15
15
  },
16
- "type": "commonjs",
17
- "main": "./dist/index.js",
18
- "types": "./dist/index.d.ts",
16
+ "type": "module",
17
+ "main": "./dist/index.mjs",
18
+ "types": "./dist/index.d.mts",
19
19
  "exports": {
20
20
  ".": {
21
- "types": "./dist/index.d.ts",
22
- "default": "./dist/index.js"
21
+ "types": "./dist/index.d.mts",
22
+ "default": "./dist/index.mjs"
23
23
  },
24
24
  "./testing": {
25
- "types": "./dist/testing.d.ts",
26
- "default": "./dist/testing.js"
25
+ "types": "./dist/testing.d.mts",
26
+ "default": "./dist/testing.mjs"
27
27
  },
28
28
  "./types/api-helpers": "./types/api-helpers.d.ts",
29
29
  "./types/api-helpers.d.ts": "./types/api-helpers.d.ts",
@@ -32,79 +32,43 @@
32
32
  "./package.json": "./package.json"
33
33
  },
34
34
  "scripts": {
35
- "build": "pnpm run build:dist",
36
- "build:dist": "pnpm run build:dist:src && pnpm run build:dist:types",
37
- "build:dist:src": "pnpm run clean:dist && rollup -c .config/rollup.dist.config.mjs",
38
- "build:dist:types": "pnpm run clean:dist:types && tsgo --project tsconfig.dts.json",
39
- "check": "run-p -c --aggregate-output check:*",
40
- "check:lint": "eslint --config .config/eslint.config.mjs --report-unused-disable-directives .",
41
- "check:lint:fix": "pnpm run check:lint -- --fix",
42
- "check:tsc": "tsgo --noEmit -p .config/tsconfig.check.json",
43
- "lint-ci": "pnpm run check:lint",
44
- "coverage": "run-s coverage:*",
45
- "coverage:test": "run-s pretest:unit test:unit:coverage",
46
- "coverage:type": "type-coverage",
47
- "coverage:type:verbose": "type-coverage --detail",
48
- "coverage:percent": "node scripts/get-coverage-percentage.mjs",
49
- "clean": "run-s -c clean:*",
50
- "clean:cache": "del-cli '**/.cache'",
51
- "clean:coverage": "del-cli '.type-coverage' 'coverage'",
52
- "clean:dist": "del-cli 'dist' '**/*.tsbuildinfo' '.config/*.tsbuildinfo'",
53
- "clean:dist:types": "del-cli 'dist/types'",
54
- "clean:declarations": "del-cli '*.d.ts' '!api*.d.ts'",
55
- "clean:node_modules": "del-cli '**/node_modules'",
56
- "fix": "run-s lint:fix",
57
- "generate-sdk": "run-s generate-sdk:*",
58
- "generate-sdk:01-prettify": "node scripts/prettify-base-json.mjs",
59
- "generate-sdk:02-generate": "node scripts/generate-types.mjs > types/api.d.ts",
60
- "generate-sdk:03-clean-api": "pnpm run fix && pnpm run fix",
61
- "knip:dependencies": "knip --dependencies",
62
- "knip:exports": "knip --include exports,duplicates",
63
- "lint": "oxlint -c=.config/.oxlintrc.json --ignore-path=.config/.oxlintignore --tsconfig=.config/tsconfig.json .",
64
- "lint:fix": "run-s -c lint:fix:*",
65
- "lint:fix:oxlint": "oxlint -c=.config/.oxlintrc.json --ignore-path=.config/.oxlintignore --tsconfig=.config/tsconfig.json --quiet --fix . | dev-null",
66
- "lint:fix:biome": "biome format --log-level=none --fix . | dev-null",
67
- "lint:fix:eslint": "eslint --config .config/eslint.config.mjs --report-unused-disable-directives --fix . | dev-null",
68
- "lint-staged": "lint-staged",
69
- "precommit": "lint-staged",
35
+ "build": "node scripts/build.mjs",
36
+ "bump": "bash scripts/node-with-loader.sh scripts/bump.mjs",
37
+ "check": "bash scripts/node-with-loader.sh scripts/check.mjs",
38
+ "check-ci": "pnpm run check --all",
39
+ "clean": "node scripts/clean.mjs",
40
+ "cover": "bash scripts/node-with-loader.sh scripts/cover.mjs",
41
+ "fix": "node scripts/lint.mjs --fix",
42
+ "generate-sdk": "bash scripts/node-with-loader.sh scripts/generate-sdk.mjs",
43
+ "lint": "node scripts/lint.mjs",
44
+ "lint-ci": "pnpm run lint --all",
45
+ "precommit": "pnpm run check --lint --staged",
70
46
  "prepare": "husky",
71
47
  "prepublishOnly": "echo 'ERROR: Use GitHub Actions workflow for publishing' && exit 1",
72
- "pretest:unit": "pnpm run build",
73
- "test": "run-s check test:*",
74
- "test:run": "node scripts/test.mjs",
75
- "test:unit": "dotenvx -q run -f .env.test -- vitest --run",
76
- "test:unit:update": "dotenvx -q run -f .env.test -- vitest --run --update",
77
- "test:unit:coverage": "dotenvx -q run -f .env.test -- vitest run --coverage",
78
- "test-ci": "dotenvx -q run -f .env.test -- vitest --run",
79
- "type-ci": "pnpm run check:tsc",
80
- "test-pre-commit": "dotenvx -q run -f .env.precommit -- pnpm test",
81
- "update": "run-p --aggregate-output update:*",
82
- "update:deps": "node scripts/taze.mjs",
83
- "update:socket": "pnpm -r update '@socketsecurity/*' --latest"
84
- },
85
- "dependencies": {
86
- "@socketsecurity/registry": "1.5.1"
48
+ "publish": "bash scripts/node-with-loader.sh scripts/publish.mjs",
49
+ "claude": "bash scripts/node-with-loader.sh scripts/claude.mjs",
50
+ "test": "node scripts/test.mjs",
51
+ "test-ci": "pnpm run test --all",
52
+ "type": "tsgo --noEmit -p .config/tsconfig.check.json",
53
+ "type-ci": "pnpm run type",
54
+ "update": "bash scripts/node-with-loader.sh scripts/update.mjs"
87
55
  },
88
56
  "devDependencies": {
89
- "@babel/core": "7.28.4",
90
- "@babel/plugin-transform-runtime": "7.28.3",
91
- "@babel/preset-typescript": "7.27.1",
92
- "@babel/runtime": "7.28.4",
57
+ "@babel/parser": "7.26.3",
58
+ "@babel/traverse": "7.26.4",
59
+ "@babel/types": "7.26.3",
93
60
  "@biomejs/biome": "2.2.4",
94
61
  "@dotenvx/dotenvx": "1.49.0",
95
62
  "@eslint/compat": "1.3.2",
96
63
  "@eslint/js": "9.35.0",
97
- "@rollup/plugin-babel": "6.0.4",
98
- "@rollup/plugin-commonjs": "28.0.6",
99
- "@rollup/plugin-json": "6.1.0",
100
- "@rollup/plugin-node-resolve": "16.0.1",
64
+ "@socketsecurity/lib": "1.0.4",
65
+ "@socketsecurity/registry": "1.5.3",
101
66
  "@types/node": "24.6.2",
102
- "@typescript-eslint/eslint-plugin": "8.44.1",
103
- "@typescript-eslint/parser": "8.44.1",
104
67
  "@typescript/native-preview": "7.0.0-dev.20250926.1",
105
68
  "@vitest/coverage-v8": "3.2.4",
106
- "del-cli": "6.0.0",
69
+ "del": "^8.0.1",
107
70
  "dev-null-cli": "2.0.0",
71
+ "esbuild": "0.25.10",
108
72
  "eslint": "9.35.0",
109
73
  "eslint-import-resolver-typescript": "4.4.4",
110
74
  "eslint-plugin-import-x": "4.16.1",
@@ -116,29 +80,25 @@
116
80
  "globals": "16.4.0",
117
81
  "http2-wrapper": "2.2.1",
118
82
  "husky": "9.1.7",
119
- "knip": "5.63.1",
120
- "lint-staged": "16.1.6",
83
+ "magic-string": "0.30.14",
121
84
  "nock": "14.0.10",
122
85
  "npm-run-all2": "8.0.4",
123
86
  "openapi-typescript": "6.7.6",
124
- "oxlint": "1.15.0",
125
- "rollup": "4.50.1",
87
+ "semver": "7.7.2",
126
88
  "taze": "19.6.0",
127
- "trash": "10.0.0",
128
89
  "type-coverage": "2.29.7",
129
90
  "typescript-eslint": "8.44.1",
130
91
  "vitest": "3.2.4",
131
- "yargs-parser": "22.0.0",
132
- "yoctocolors": "2.1.2"
92
+ "yoctocolors-cjs": "2.1.3"
133
93
  },
134
94
  "pnpm": {
135
- "overrides": {
136
- "vite": "7.1.5"
137
- },
138
95
  "ignoredBuiltDependencies": [
139
96
  "esbuild",
140
97
  "unrs-resolver"
141
- ]
98
+ ],
99
+ "overrides": {
100
+ "vite": "7.1.11"
101
+ }
142
102
  },
143
103
  "engines": {
144
104
  "node": ">=18",
@@ -147,18 +107,11 @@
147
107
  "files": [
148
108
  "dist/**",
149
109
  "types/**",
150
- "CHANGELOG.md",
151
- "requirements.json"
110
+ "CHANGELOG.md"
152
111
  ],
153
- "lint-staged": {
154
- "*.{cjs,js,json,md,mjs,mts,ts}": [
155
- "pnpm run lint:fix:oxlint",
156
- "pnpm run lint:fix:biome -- --no-errors-on-unmatched --files-ignore-unknown=true --colors=off"
157
- ]
158
- },
159
112
  "typeCoverage": {
160
113
  "cache": true,
161
- "atLeast": 99.6,
114
+ "atLeast": 99,
162
115
  "ignoreAsAssertion": true,
163
116
  "ignoreCatch": true,
164
117
  "ignoreEmptyType": true,
@@ -1,56 +1,69 @@
1
- declare type ValueOf<
2
- ObjectType,
3
- ValueType extends keyof ObjectType = keyof ObjectType,
4
- > = ObjectType[ValueType]
1
+ /**
2
+ * @fileoverview Helper types for working with generated OpenAPI types.
3
+ */
5
4
 
6
- // Based on openapi-typescript-fetch.
7
- // https://socket.dev/npm/package/openapi-typescript-fetch/overview/2.2.1
8
- // MIT License
9
- // Copyright 2021 Ajai Shankar
10
- declare type Coalesce<T, D> = [T] extends [never] ? D : T
11
-
12
- declare type OpResponseTypes<OP> = OP extends {
13
- responses: infer R
5
+ /**
6
+ * Extract the successful response type from an operation.
7
+ * Maps to the data property of the success result.
8
+ */
9
+ export type OpReturnType<T> = T extends {
10
+ responses: {
11
+ 200?: { content?: { 'application/json': infer U } }
12
+ }
14
13
  }
15
- ? {
16
- [S in keyof R]: R[S] extends {
17
- schema?: infer S
14
+ ? U
15
+ : T extends {
16
+ responses: {
17
+ 201?: { content?: { 'application/json': infer U } }
18
+ }
18
19
  }
19
- ? S
20
- : R[S] extends {
21
- content: {
22
- 'application/json': infer C
23
- }
24
- }
25
- ? C
26
- : S extends 'default'
27
- ? R[S]
28
- : unknown
29
- }
30
- : never
31
-
32
- declare type _OpReturnType<T> = 200 extends keyof T
33
- ? T[200]
34
- : 201 extends keyof T
35
- ? T[201]
36
- : 'default' extends keyof T
37
- ? T['default']
20
+ ? U
21
+ : T extends {
22
+ responses: {
23
+ 204?: unknown
24
+ }
25
+ }
26
+ ? undefined
38
27
  : unknown
39
28
 
40
- declare type _OpErrorType<T> = {
41
- [S in Exclude<keyof T, 200 | 201>]: T[S] & {
42
- success: false
43
- status: S extends 'default' ? never : S
44
- }
45
- }
46
-
47
- export declare type OpReturnType<OP> = {
48
- success: true
49
- status: 200
50
- data: _OpReturnType<OpResponseTypes<OP>>
29
+ /**
30
+ * Extract the error response type from an operation.
31
+ * Maps to the error structure of the error result.
32
+ */
33
+ export type OpErrorType<T> = T extends {
34
+ responses: infer R
51
35
  }
52
-
53
- type OpErrorType<OP> = Coalesce<
54
- ValueOf<_OpErrorType<OpResponseTypes<OP>>>,
55
- { success: false; status: number }
56
- >
36
+ ? R extends Record<string | number, unknown>
37
+ ? {
38
+ [K in keyof R as K extends
39
+ | 400
40
+ | 401
41
+ | 403
42
+ | 404
43
+ | 409
44
+ | 422
45
+ | 429
46
+ | 500
47
+ | 502
48
+ | 503
49
+ ? K
50
+ : never]: R[K]
51
+ }[keyof {
52
+ [K in keyof R as K extends
53
+ | 400
54
+ | 401
55
+ | 403
56
+ | 404
57
+ | 409
58
+ | 422
59
+ | 429
60
+ | 500
61
+ | 502
62
+ | 503
63
+ ? K
64
+ : never]: R[K]
65
+ }] extends { content?: { 'application/json': infer E } }
66
+ ? E
67
+ : { error?: string }
68
+ : { error?: string }
69
+ : { error?: string }