diff --git a/.codesandbox/ci.json b/.codesandbox/ci.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/.codesandbox/ci.json @@ -0,0 +1 @@ +{} diff --git a/esbuild.js b/esbuild.cjs similarity index 90% rename from esbuild.js rename to esbuild.cjs index 8f6b307..68e1bf9 100644 --- a/esbuild.js +++ b/esbuild.cjs @@ -57,6 +57,13 @@ Promise.all([ bundle: true, format: "esm", platform: "node", + banner: { + js: ` +import { fileURLToPath } from 'url'; +import { createRequire as topLevelCreateRequire } from 'module'; +const require = topLevelCreateRequire(import.meta.url); + `.trim(), + }, outdir: "dist/esm", plugins: [browserifyPlugin], }), diff --git a/openapi.json b/openapi.json index 6461013..5243ece 100644 --- a/openapi.json +++ b/openapi.json @@ -1586,6 +1586,6 @@ } }, "security": [], - "servers": [{ "url": "https://api.codesandbox.io", "variables": {} }], + "servers": [{ "url": "https://api.codesandbox.stream", "variables": {} }], "tags": [] } diff --git a/package-lock.json b/package-lock.json index 70fcff3..41d4d0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,11 +12,11 @@ "csb": "dist/bin/codesandbox.js" }, "devDependencies": { - "@codesandbox/pitcher-client": "0.360.2", + "@codesandbox/pitcher-client": "1.1.5", "@codesandbox/pitcher-common": "0.360.2", "@codesandbox/pitcher-protocol": "0.360.4", - "@hey-api/client-fetch": "^0.5.1", - "@hey-api/openapi-ts": "0.60.1", + "@hey-api/client-fetch": "^0.7.3", + "@hey-api/openapi-ts": "^0.63.2", "@types/blessed": "^0.1.25", "@types/yargs": "^17.0.33", "blessed": "^0.1.81", @@ -45,7 +45,6 @@ "resolved": "https://registry.npmjs.org/@absinthe/socket/-/socket-0.2.1.tgz", "integrity": "sha512-rCuMRG4WndooGR+QfU5v+xL6U8YKEXFyvjqYt0qTHupAh+k+tpD6a5dlxcLO0g38p/hb1I12OzKvl+0G1XYCkA==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "7.2.0", "@jumpn/utils-array": "0.3.4", @@ -58,46 +57,25 @@ "phoenix": "^1.4.0" } }, - "node_modules/@apidevtools/json-schema-ref-parser": { - "version": "11.7.3", - "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-11.7.3.tgz", - "integrity": "sha512-WApSdLdXEBb/1FUPca2lteASewEfpjEYJ8oXZP+0gExK5qSfsEKBKcA+WjY6Q4wvXwyv0+W6Kvc372pSceib9w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jsdevtools/ono": "^7.1.3", - "@types/json-schema": "^7.0.15", - "js-yaml": "^4.1.0" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/philsturgeon" - } - }, "node_modules/@babel/runtime": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.2.0.tgz", "integrity": "sha512-oouEibCbHMVdZSDlJBO6bZmID/zA/G/Qx3H1d3rSNPTD+L8UNKvCat7aKWSJ74zYbm5zWGh0GQN0hKj8zYFTCg==", "dev": true, - "license": "MIT", "dependencies": { "regenerator-runtime": "^0.12.0" } }, "node_modules/@codesandbox/api": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@codesandbox/api/-/api-0.1.0.tgz", - "integrity": "sha512-MCGIwWDjpMNlz1csJMnKAMplvmByNYlXC2C0R5P2RL1oZ2j6X4KJJEG06iz//izwBJzDgZJGiis1dq9siuJ8Rg==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@codesandbox/api/-/api-1.1.3.tgz", + "integrity": "sha512-GHrxd/tL4CHy/+42Qx0RC65EHUH6jjzuRm+JcBgAlRcMCJPvSTANpoNgI6fQKofvEJIVc4ghqR7X87j6emEZyg==", "dev": true, - "license": "MIT", "dependencies": { "@absinthe/socket": "^0.2.1", - "@codesandbox/create-gql-api": "0.1.0", + "@codesandbox/create-gql-api": "^1.0.1", "class-states": "1.0.15", "humps": "^2.0.1", - "node-fetch": "^2.6.1", "phoenix": "^1.6.6", "preact": "^10.22.0", "universal-cookie": "^4.0.4" @@ -107,15 +85,13 @@ "version": "1.0.15", "resolved": "https://registry.npmjs.org/class-states/-/class-states-1.0.15.tgz", "integrity": "sha512-ReR0LKl1C3tK+Wwe2zlAtXEjLavuR3+m+oFFNELdJmywEoh00iDYCWLxWJof83YSpqIBK/iegy0blUuktJ7+6A==", - "dev": true, - "license": "ISC" + "dev": true }, "node_modules/@codesandbox/create-gql-api": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@codesandbox/create-gql-api/-/create-gql-api-0.1.0.tgz", - "integrity": "sha512-opCFfhdrgeiM2ffGpfMdjdx5mB2kjY79sBuD82775OUvAUnmTH2csa/CxscCV/JY4F/Qd3e+omQlP4CiMjMB5Q==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@codesandbox/create-gql-api/-/create-gql-api-1.0.1.tgz", + "integrity": "sha512-k+C8OS2wYdakIoYEtHjW+pvwb7uq+emHQX5W1tqJQ9gDEYYy2dHItQNulY/8H0ymudhW3b6zcKTVNTMl9QgGWQ==", "dev": true, - "license": "ISC", "dependencies": { "get-graphql-schema": "^2.1.2", "graphql": "^16.8.1" @@ -136,16 +112,16 @@ } }, "node_modules/@codesandbox/pitcher-client": { - "version": "0.360.2", - "resolved": "https://registry.npmjs.org/@codesandbox/pitcher-client/-/pitcher-client-0.360.2.tgz", - "integrity": "sha512-rESLa3P2ohDbGMXQ5Jx0iUIhQkIuSDKocXDsIn2gOiCTQloxqXmX/d6rbk4MlQcjvcc4eBbrw1kIPxfyNFk/PQ==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@codesandbox/pitcher-client/-/pitcher-client-1.1.5.tgz", + "integrity": "sha512-YRDF7X1i2+P888N+P9DQkwatUDNEAPcaAHjojwvt8dYoshO8IL9iKeN6sdHp+dDi/NLnVzz1cDO6mcAvlXAC0Q==", "dev": true, "license": "GPL-3.0", "dependencies": { - "@codesandbox/api": "0.1.0", + "@codesandbox/api": "^1.1.3", "@codesandbox/nodebox": "^0.1.8", - "@codesandbox/pitcher-common": "0.360.2", - "@codesandbox/pitcher-protocol": "0.360.3", + "@codesandbox/pitcher-common": "^0.360.2", + "@codesandbox/pitcher-protocol": "^0.360.4", "@codesandbox/sandpack-client": "^2.18.0", "@types/ws": "^7.4.7", "class-states": "1.0.16", @@ -153,22 +129,11 @@ "isomorphic-ws": "^5.0.0", "js-untar": "^2.0.0", "jszip": "^3.10.1", - "minimatch": "9.0.3", + "minimatch": "^10.0.1", "semver": "^7.3.5", "vscode-jsonrpc": "^8.2.0" } }, - "node_modules/@codesandbox/pitcher-client/node_modules/@codesandbox/pitcher-protocol": { - "version": "0.360.3", - "resolved": "https://registry.npmjs.org/@codesandbox/pitcher-protocol/-/pitcher-protocol-0.360.3.tgz", - "integrity": "sha512-E1ksPxx1/RTKZDPHGLw4vh4mfPFphwHJMIOtQwXIUBsasMNLuSqh6E+Tr8f1DfxKDv81+HJ6y8PxiXn9JcpgyA==", - "dev": true, - "license": "GPL-3.0", - "dependencies": { - "@codesandbox/pitcher-common": "*", - "@msgpack/msgpack": "^2.7.1" - } - }, "node_modules/@codesandbox/pitcher-client/node_modules/semver": { "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", @@ -286,38 +251,56 @@ } }, "node_modules/@hey-api/client-fetch": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/@hey-api/client-fetch/-/client-fetch-0.5.2.tgz", - "integrity": "sha512-ix8MuuLTME5BWMQ8iCALqWflHtDyuoEwX0b77TQL+VgEXL89cYtjoHxE2bm2DYQQm8qDJXvTS6ju/D6wB6l6Hg==", + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@hey-api/client-fetch/-/client-fetch-0.7.3.tgz", + "integrity": "sha512-nysIXMag9nr5ENy+47G0AYsegdT7vT6S4KLfY7NVgM6HsyZ0DrhCZvz5nP70M16x9i860SrnXhjpcuHx0g5sDQ==", "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/hey-api" } }, + "node_modules/@hey-api/json-schema-ref-parser": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@hey-api/json-schema-ref-parser/-/json-schema-ref-parser-1.0.1.tgz", + "integrity": "sha512-dBt0A7op9kf4BcK++x6HBYDmvCvnJUZEGe5QytghPFHnMXPyKwDKomwL/v5e9ERk6E0e1GzL/e/y6pWUso9zrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.15", + "js-yaml": "^4.1.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/hey-api" + } + }, "node_modules/@hey-api/openapi-ts": { - "version": "0.60.1", - "resolved": "https://registry.npmjs.org/@hey-api/openapi-ts/-/openapi-ts-0.60.1.tgz", - "integrity": "sha512-W3fW6pjQ3rwRsmvp9+hDEStyedTWgNjd6PfdVOIegtPBKj3o4ThK3J14kXeqdH2tJXrudfLpXHRp43+ahi4QSg==", + "version": "0.63.2", + "resolved": "https://registry.npmjs.org/@hey-api/openapi-ts/-/openapi-ts-0.63.2.tgz", + "integrity": "sha512-HC5fR3+07P1AvDYrcZv0kbnhWogvMFot848PfpS3Gbncm47mDdO/uhNGIr2RF9CaRIvJNSJvAf1jL3XAQZ18RA==", "dev": true, "license": "MIT", "dependencies": { - "@apidevtools/json-schema-ref-parser": "11.7.3", + "@hey-api/json-schema-ref-parser": "1.0.1", "c12": "2.0.1", - "commander": "12.1.0", + "commander": "13.0.0", "handlebars": "4.7.8" }, "bin": { "openapi-ts": "bin/index.cjs" }, "engines": { - "node": "^18.0.0 || >=20.0.0" + "node": "^18.18.0 || ^20.9.0 || >=22.11.0" }, "funding": { "url": "https://github.com/sponsors/hey-api" }, "peerDependencies": { - "typescript": "^5.x" + "typescript": "^5.5.3" } }, "node_modules/@isaacs/cliui": { @@ -435,7 +418,6 @@ "resolved": "https://registry.npmjs.org/@jumpn/utils-array/-/utils-array-0.3.4.tgz", "integrity": "sha512-ExRwf0b0NMyMn6HLStMeqEEtmblV0BKVZ4YT3FhEJ5ErZSPN4Vv6xYUJQGNG0b7QGZJIN2KetxEoOm4MYmXygw==", "dev": true, - "license": "MIT", "dependencies": { "babel-polyfill": "6.26.0", "babel-runtime": "6.26.0", @@ -447,7 +429,6 @@ "resolved": "https://registry.npmjs.org/@jumpn/utils-composite/-/utils-composite-0.7.0.tgz", "integrity": "sha512-kamRVYJLNvjMrnKKeu2RSFQHLUO/IYFo05gLI7GQcCk063mJzsjCCfRycCievIBI+5Sg8C7A5gwRYxkBA5jY8w==", "dev": true, - "license": "MIT", "dependencies": { "@jumpn/utils-array": "0.3.4", "babel-polyfill": "6.26.0", @@ -460,15 +441,13 @@ "version": "0.2.8", "resolved": "https://registry.npmjs.org/flow-static-land/-/flow-static-land-0.2.8.tgz", "integrity": "sha512-pOZFExu2rbscCgcEo7nL7FNhBubMi18dn1Un4lm8LOmQkYhgsHLsrBGMWmuJXRWcYMrOC7I/bPsiqqVjdD3K1g==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/@jumpn/utils-graphql": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/@jumpn/utils-graphql/-/utils-graphql-0.6.0.tgz", "integrity": "sha512-I5OSEh8Ed4FdLIcUTYzWdpO9noQOoWptdgF8yOZ0xhDD7h7E9IgPYxfy36qbC6v9xlpGTwQMu3Wn8ulkinG/MQ==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "7.2.0", "core-js": "2.6.0", @@ -480,7 +459,6 @@ "resolved": "https://registry.npmjs.org/graphql/-/graphql-14.0.2.tgz", "integrity": "sha512-gUC4YYsaiSJT1h40krG3J+USGlwhzNTXSb4IOZljn9ag5Tj+RkoXrWp+Kh7WyE3t1NCfab5kzCuxBIvOMERMXw==", "dev": true, - "license": "MIT", "dependencies": { "iterall": "^1.2.2" }, @@ -526,8 +504,7 @@ "version": "0.3.3", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.3.3.tgz", "integrity": "sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/@types/json-schema": { "version": "7.0.15", @@ -707,7 +684,6 @@ "resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.26.0.tgz", "integrity": "sha512-F2rZGQnAdaHWQ8YAoeRbukc7HS9QgdgeyJ0rQDd485v9opwuPvjpPFcOOT/WmkKTdgy9ESgSPXDcTNpzrGr6iQ==", "dev": true, - "license": "MIT", "dependencies": { "babel-runtime": "^6.26.0", "core-js": "^2.5.0", @@ -718,15 +694,13 @@ "version": "0.10.5", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz", "integrity": "sha512-02YopEIhAgiBHWeoTiA8aitHDt8z6w+rQqNuIftlM+ZtvSl/brTouaU7DW6GO/cHtvxJvS4Hwv2ibKdxIRi24w==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/babel-runtime": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", "dev": true, - "license": "MIT", "dependencies": { "core-js": "^2.4.0", "regenerator-runtime": "^0.11.0" @@ -736,8 +710,7 @@ "version": "0.11.1", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/balanced-match": { "version": "1.0.2", @@ -1258,7 +1231,6 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, - "license": "MIT", "dependencies": { "color-name": "1.1.3" } @@ -1267,13 +1239,12 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/commander": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", - "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-13.0.0.tgz", + "integrity": "sha512-oPYleIY8wmTVzkvQq10AEok6YcTC4sRUBl8F9gVuwchGVUCTbl/vhLTaQqutuuySYOsu8YTgV+OxKc/8Yvx+mQ==", "dev": true, "license": "MIT", "engines": { @@ -1302,7 +1273,6 @@ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", "dev": true, - "license": "MIT", "engines": { "node": ">= 0.6" } @@ -1312,8 +1282,7 @@ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.0.tgz", "integrity": "sha512-kLRC6ncVpuEW/1kwrOXYX6KQASCVtrh1gQr/UiaVgFlf9WE5Vp+lNe5+h3LuMr5PAucWnnEXwH0nQHRH/gpGtw==", "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/core-util-is": { "version": "1.0.3", @@ -1751,8 +1720,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", "integrity": "sha512-46+Jxk9Yj/nQY+3a1KTnpbBTemcAbPySTKya8iM9D7EsiONpSWbvzesalcCJ6tmJrCUITT2fmAQfNHFG+OHM6Q==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/fill-range": { "version": "7.1.1", @@ -1771,8 +1739,7 @@ "version": "0.2.7", "resolved": "https://registry.npmjs.org/flow-static-land/-/flow-static-land-0.2.7.tgz", "integrity": "sha512-SmGgln4qcqLAysXM5BF8EQS+clj0TUf9+KlZUJgwuzNHvwbput+opz3CMyee9sDuLf4J/3sJbYGjdNsd2jSurA==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/for-each": { "version": "0.3.3", @@ -1865,7 +1832,6 @@ "resolved": "https://registry.npmjs.org/get-graphql-schema/-/get-graphql-schema-2.1.2.tgz", "integrity": "sha512-1z5Hw91VrE3GrpCZE6lE8Dy+jz4kXWesLS7rCSjwOxf5BOcIedAZeTUJRIeIzmmR+PA9CKOkPTYFRJbdgUtrxA==", "dev": true, - "license": "MIT", "dependencies": { "chalk": "^2.4.1", "graphql": "^14.0.2", @@ -1881,7 +1847,6 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, - "license": "MIT", "dependencies": { "color-convert": "^1.9.0" }, @@ -1894,7 +1859,6 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, - "license": "MIT", "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -1909,7 +1873,6 @@ "resolved": "https://registry.npmjs.org/graphql/-/graphql-14.7.0.tgz", "integrity": "sha512-l0xWZpoPKpppFzMfvVyFmp9vLN7w/ZZJPefUicMCepfJeQ8sMcztloGYY9DfjVPo6tIUDzU5Hw3MUbIjj9AVVA==", "dev": true, - "license": "MIT", "dependencies": { "iterall": "^1.2.2" }, @@ -1922,7 +1885,6 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, - "license": "MIT", "engines": { "node": ">=4" } @@ -1932,7 +1894,6 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, - "license": "MIT", "dependencies": { "has-flag": "^3.0.0" }, @@ -2023,22 +1984,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/glob/node_modules/minimatch": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", - "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/gopd": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", @@ -2053,11 +1998,10 @@ } }, "node_modules/graphql": { - "version": "16.9.0", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz", - "integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==", + "version": "16.10.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.10.0.tgz", + "integrity": "sha512-AjqGKbDGUFRKIRCP9tCKiIGHyriz2oHEbPIbEtcSLSs4YjReZOIPQQWek4+6hjw62H9QShXHyaGivGiYVLeYFQ==", "dev": true, - "license": "MIT", "engines": { "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" } @@ -2217,8 +2161,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/humps/-/humps-2.0.1.tgz", "integrity": "sha512-E0eIbrFWUhwfXJmsbdjRQFQPrl5pTEoKlz163j1mTqqUnU9PgR4AgB8AIITzuB3vLBdxZXyZ9TDIrwB2OASz4g==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/ieee754": { "version": "1.2.1", @@ -2414,8 +2357,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.3.0.tgz", "integrity": "sha512-QZ9qOMdF+QLHxy1QIpUHUU1D5pS2CG2P69LF6L6CPjPYA/XMOmKV3PZpawHoAjHNyB0swdVTRxdYT4tbBbxqwg==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/jackspeak": { "version": "4.0.2", @@ -2736,16 +2678,16 @@ "license": "MIT" }, "node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -3213,8 +3155,7 @@ "version": "1.7.18", "resolved": "https://registry.npmjs.org/phoenix/-/phoenix-1.7.18.tgz", "integrity": "sha512-Qo+V9+knfEd+R1pzCe+XJlj3GPSxWz4PNwzFl7GgssuTVYPoh/he3mbPQJ+NEDdqulxAbBtWCNYGPB3WplS5Mg==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/picomatch": { "version": "2.3.1", @@ -3286,11 +3227,10 @@ } }, "node_modules/preact": { - "version": "10.25.2", - "resolved": "https://registry.npmjs.org/preact/-/preact-10.25.2.tgz", - "integrity": "sha512-GEts1EH3oMnqdOIeXhlbBSddZ9nrINd070WBOiPO2ous1orrKGUM4SMDbwyjSWD1iMS2dBvaDjAa5qUhz3TXqw==", + "version": "10.25.4", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.25.4.tgz", + "integrity": "sha512-jLdZDb+Q+odkHJ+MpW/9U5cODzqnB+fy2EiHSZES7ldV5LK7yjlVzTp7R8Xy6W6y75kfK8iWYtFVH7lvjwrCMA==", "dev": true, - "license": "MIT", "funding": { "type": "opencollective", "url": "https://opencollective.com/preact" @@ -3424,8 +3364,7 @@ "version": "0.12.1", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/require-directory": { "version": "2.1.1", @@ -4001,7 +3940,6 @@ "resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-4.0.4.tgz", "integrity": "sha512-lbRVHoOMtItjWbM7TwDLdl8wug7izB0tq3/YVKhT/ahB4VDvWMyvnADfnJI8y6fSvsjh51Ix7lTGC6Tn4rMPhw==", "dev": true, - "license": "MIT", "dependencies": { "@types/cookie": "^0.3.3", "cookie": "^0.4.0" @@ -4402,8 +4340,7 @@ "version": "0.8.11", "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.11.tgz", "integrity": "sha512-N3xXQVr4L61rZvGMpWe8XoCGX8vhU35dPyQ4fm5CY/KDlG0F75un14hjbckPXTDuKUY6V0dqR2giT6xN8Y4GEQ==", - "dev": true, - "license": "MIT" + "dev": true } } } diff --git a/package.json b/package.json index a6e52ff..e02a196 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "author": "CodeSandbox", "license": "MIT", "repository": "git+https://github.com/codesandbox/codesandbox-sdk.git", + "type": "module", "bin": { "csb": "dist/bin/codesandbox.js" }, @@ -52,7 +53,7 @@ "build": "npm run clean && npm run build:esbuild && npm run build:cjs:types && npm run build:esm:types && chmod +x dist/bin/codesandbox.js", "build:cjs": "tsc -p ./tsconfig.build-cjs.json", "build:esm": "tsc -p ./tsconfig.build-esm.json", - "build:esbuild": "node esbuild.js", + "build:esbuild": "node esbuild.cjs", "build:cjs:types": "tsc -p ./tsconfig.build-cjs.json --emitDeclarationOnly", "build:esm:types": "tsc -p ./tsconfig.build-esm.json --emitDeclarationOnly", "build-openapi": "rimraf src/client && curl -o openapi.json https://api.codesandbox.io/meta/openapi && npx prettier --write ./openapi.json && node_modules/.bin/openapi-ts -i ./openapi.json -o src/client -c @hey-api/client-fetch", @@ -74,11 +75,11 @@ "README.md" ], "devDependencies": { - "@codesandbox/pitcher-client": "0.360.2", + "@codesandbox/pitcher-client": "1.1.5", "@codesandbox/pitcher-common": "0.360.2", "@codesandbox/pitcher-protocol": "0.360.4", - "@hey-api/client-fetch": "^0.5.1", - "@hey-api/openapi-ts": "0.60.1", + "@hey-api/client-fetch": "^0.7.3", + "@hey-api/openapi-ts": "^0.63.2", "@types/blessed": "^0.1.25", "@types/yargs": "^17.0.33", "blessed": "^0.1.81", diff --git a/src/client/client.gen.ts b/src/client/client.gen.ts new file mode 100644 index 0000000..1822a95 --- /dev/null +++ b/src/client/client.gen.ts @@ -0,0 +1,5 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createClient, createConfig } from '@hey-api/client-fetch'; + +export const client = createClient(createConfig()); \ No newline at end of file diff --git a/src/client/index.ts b/src/client/index.ts index 81abc82..e64537d 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './sdk.gen'; -export * from './types.gen'; \ No newline at end of file +export * from './types.gen'; +export * from './sdk.gen'; \ No newline at end of file diff --git a/src/client/sdk.gen.ts b/src/client/sdk.gen.ts index a2abfb8..58d7a67 100644 --- a/src/client/sdk.gen.ts +++ b/src/client/sdk.gen.ts @@ -1,17 +1,25 @@ // This file is auto-generated by @hey-api/openapi-ts -import { createClient, createConfig, type OptionsLegacyParser } from '@hey-api/client-fetch'; -import type { MetaInfoError, MetaInfoResponse, WorkspaceCreateData, WorkspaceCreateError, WorkspaceCreateResponse2, TokenCreateData, TokenCreateError, TokenCreateResponse2, TokenUpdateData, TokenUpdateError, TokenUpdateResponse2, SandboxListData, SandboxListError, SandboxListResponse2, SandboxCreateData, SandboxCreateError, SandboxCreateResponse2, SandboxGetData, SandboxGetError, SandboxGetResponse2, SandboxForkData, SandboxForkError, SandboxForkResponse2, VmHibernateData, VmHibernateError, VmHibernateResponse, VmUpdateHibernationTimeoutData, VmUpdateHibernationTimeoutError, VmUpdateHibernationTimeoutResponse, VmCreateSessionData, VmCreateSessionError, VmCreateSessionResponse, VmShutdownData, VmShutdownError, VmShutdownResponse, VmUpdateSpecsData, VmUpdateSpecsError, VmUpdateSpecsResponse, VmStartData, VmStartError, VmStartResponse, VmUpdateSpecs2Data, VmUpdateSpecs2Error, VmUpdateSpecs2Response } from './types.gen'; +import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch'; +import type { MetaInfoData, MetaInfoResponse, WorkspaceCreateData, WorkspaceCreateResponse2, TokenCreateData, TokenCreateResponse2, TokenUpdateData, TokenUpdateResponse2, SandboxListData, SandboxListResponse2, SandboxCreateData, SandboxCreateResponse2, SandboxGetData, SandboxGetResponse2, SandboxForkData, SandboxForkResponse2, VmHibernateData, VmHibernateResponse2, VmUpdateHibernationTimeoutData, VmUpdateHibernationTimeoutResponse2, VmCreateSessionData, VmCreateSessionResponse2, VmShutdownData, VmShutdownResponse2, VmUpdateSpecsData, VmUpdateSpecsResponse2, VmStartData, VmStartResponse2, VmUpdateSpecs2Data, VmUpdateSpecs2Response } from './types.gen'; +import { client as _heyApiClient } from './client.gen'; -export const client = createClient(createConfig()); +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; +}; /** * Metadata about the API */ -export const metaInfo = (options?: OptionsLegacyParser) => { - return (options?.client ?? client).get({ - ...options, - url: '/meta/info' +export const metaInfo = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/meta/info', + ...options }); }; @@ -20,10 +28,20 @@ export const metaInfo = (options?: Options * Create a new, empty, workspace in the current organization * */ -export const workspaceCreate = (options?: OptionsLegacyParser) => { - return (options?.client ?? client).post({ +export const workspaceCreate = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/org/workspace', ...options, - url: '/org/workspace' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; @@ -32,10 +50,20 @@ export const workspaceCreate = (options?: * Create a new API token for a workspace that is part of the current organization. * */ -export const tokenCreate = (options?: OptionsLegacyParser) => { - return (options?.client ?? client).post({ +export const tokenCreate = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/org/workspace/{team_id}/tokens', ...options, - url: '/org/workspace/{team_id}/tokens' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; @@ -44,10 +72,20 @@ export const tokenCreate = (options?: Opti * Update an API token for a workspace that is part of the current organization. * */ -export const tokenUpdate = (options?: OptionsLegacyParser) => { - return (options?.client ?? client).patch({ +export const tokenUpdate = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/org/workspace/{team_id}/tokens/{token_id}', ...options, - url: '/org/workspace/{team_id}/tokens/{token_id}' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; @@ -57,10 +95,16 @@ export const tokenUpdate = (options?: Opti * Results are limited to a maximum of 50 sandboxes per request. * */ -export const sandboxList = (options?: OptionsLegacyParser) => { - return (options?.client ?? client).get({ - ...options, - url: '/sandbox' +export const sandboxList = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/sandbox', + ...options }); }; @@ -69,10 +113,20 @@ export const sandboxList = (options?: Opti * Create a new sandbox in the current workspace with file contents * */ -export const sandboxCreate = (options?: OptionsLegacyParser) => { - return (options?.client ?? client).post({ +export const sandboxCreate = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/sandbox', ...options, - url: '/sandbox' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; @@ -81,10 +135,16 @@ export const sandboxCreate = (options?: Op * Retrieve a sandbox by its ID * */ -export const sandboxGet = (options: OptionsLegacyParser) => { - return (options?.client ?? client).get({ - ...options, - url: '/sandbox/{id}' +export const sandboxGet = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/sandbox/{id}', + ...options }); }; @@ -93,10 +153,20 @@ export const sandboxGet = (options: Option * Fork an existing sandbox to the current workspace * */ -export const sandboxFork = (options: OptionsLegacyParser) => { - return (options?.client ?? client).post({ +export const sandboxFork = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/sandbox/{id}/fork', ...options, - url: '/sandbox/{id}/fork' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; @@ -111,10 +181,20 @@ export const sandboxFork = (options: Optio * minimal latency. * */ -export const vmHibernate = (options: OptionsLegacyParser) => { - return (options?.client ?? client).post({ +export const vmHibernate = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/vm/{id}/hibernate', ...options, - url: '/vm/{id}/hibernate' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; @@ -126,10 +206,20 @@ export const vmHibernate = (options: Optio * The new timeout must be greater than 0 and less than or equal to 86400 seconds (24 hours). * */ -export const vmUpdateHibernationTimeout = (options: OptionsLegacyParser) => { - return (options?.client ?? client).put({ +export const vmUpdateHibernationTimeout = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/vm/{id}/hibernation_timeout', ...options, - url: '/vm/{id}/hibernation_timeout' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; @@ -142,10 +232,20 @@ export const vmUpdateHibernationTimeout = * This endpoint requires the VM to be running. If the VM is not running, it will return a 404 error. * */ -export const vmCreateSession = (options: OptionsLegacyParser) => { - return (options?.client ?? client).post({ +export const vmCreateSession = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/vm/{id}/sessions', ...options, - url: '/vm/{id}/sessions' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; @@ -159,10 +259,20 @@ export const vmCreateSession = (options: O * Shutdown VMs require additional time to start up. * */ -export const vmShutdown = (options: OptionsLegacyParser) => { - return (options?.client ?? client).post({ +export const vmShutdown = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/vm/{id}/shutdown', ...options, - url: '/vm/{id}/shutdown' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; @@ -174,10 +284,20 @@ export const vmShutdown = (options: Option * The new tier must not exceed your team's maximum allowed tier. * */ -export const vmUpdateSpecs = (options: OptionsLegacyParser) => { - return (options?.client ?? client).put({ +export const vmUpdateSpecs = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/vm/{id}/specs', ...options, - url: '/vm/{id}/specs' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; @@ -193,10 +313,20 @@ export const vmUpdateSpecs = (options: Opt * This endpoint is subject to special rate limits related to concurrent VM usage. * */ -export const vmStart = (options: OptionsLegacyParser) => { - return (options?.client ?? client).post({ +export const vmStart = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/vm/{id}/start', ...options, - url: '/vm/{id}/start' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; @@ -208,9 +338,19 @@ export const vmStart = (options: OptionsLe * The new tier must not exceed your team's maximum allowed tier. * */ -export const vmUpdateSpecs2 = (options: OptionsLegacyParser) => { - return (options?.client ?? client).post({ +export const vmUpdateSpecs2 = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + security: [ + { + scheme: 'bearer', + type: 'http' + } + ], + url: '/vm/{id}/update_specs', ...options, - url: '/vm/{id}/update_specs' + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } }); }; \ No newline at end of file diff --git a/src/client/types.gen.ts b/src/client/types.gen.ts index e6e699c..2d288ce 100644 --- a/src/client/types.gen.ts +++ b/src/client/types.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -export type Error = string | { +export type _Error = string | { [key: string]: unknown; }; @@ -16,16 +16,14 @@ export type MetaInformation = { * Meta information about the current authentication context */ auth?: { - scopes: Array<(string)>; - team: (string) | null; + scopes: Array; + team: string | null; version: string; }; }; export type Response = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; + errors?: Array; success?: boolean; }; @@ -41,7 +39,7 @@ export type SandboxCreateRequest = { /** * Array of strings with external resources to load. */ - external_resources?: Array<(string)>; + external_resources?: Array; /** * Map of `path => file` where each file is a map. */ @@ -69,7 +67,7 @@ export type SandboxCreateRequest = { * Map of dependencies and their version specifications. */ npm_dependencies?: { - [key: string]: (string); + [key: string]: string; }; /** * Path to the collection where the new sandbox should be stored. Defaults to "/". If no collection exists at the given path, it will be created. @@ -86,7 +84,7 @@ export type SandboxCreateRequest = { /** * List of string tags to apply to the sandbox. Only the first ten will be used. Defaults to no tags. */ - tags?: Array<(string)>; + tags?: Array; /** * Name of the template from which the sandbox is derived (for example, `"static"`). */ @@ -97,21 +95,14 @@ export type SandboxCreateRequest = { title?: string; }; -/** - * Runtime to use for the sandbox. Defaults to `"browser"`. - */ -export type runtime = 'browser' | 'vm'; - export type SandboxCreateResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; + errors?: Array; success?: boolean; } & { data?: { alias: string; id: string; - title: (string) | null; + title: string | null; }; }; @@ -160,27 +151,15 @@ export type SandboxForkRequest = { /** * Tags to set on the new sandbox, if any. Will not inherit tags from the source sandbox. */ - tags?: Array<(string)>; + tags?: Array; /** * Sandbox title. Maximum 255 characters. Defaults to title of original sandbox with (forked). */ title?: string; }; -/** - * Determines which specs to start the VM with. If not specified, the VM will start with the default specs for the workspace. - * - * You can only specify a VM tier when starting a VM that is inside your workspace. Specifying a VM tier for someone else's sandbox will return an error. - * - * Not all tiers will be available depending on the workspace subscription status, and higher tiers incur higher costs. Please see codesandbox.io/pricing for details on specs and costs. - * - */ -export type tier = 'Pico' | 'Nano' | 'Micro' | 'Small' | 'Medium' | 'Large' | 'XLarge'; - export type SandboxForkResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; + errors?: Array; success?: boolean; } & { data?: { @@ -202,32 +181,28 @@ export type SandboxForkResponse = { user_workspace_path: string; workspace_path: string; } | null; - title: (string) | null; + title: string | null; }; }; export type SandboxGetResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; + errors?: Array; success?: boolean; } & { data?: { created_at: string; - description?: (string) | null; + description?: string | null; id: string; is_frozen: boolean; privacy: number; - tags: Array<(string)>; - title?: (string) | null; + tags: Array; + title?: string | null; updated_at: string; }; }; export type SandboxListResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; + errors?: Array; success?: boolean; } & { data?: { @@ -236,17 +211,17 @@ export type SandboxListResponse = { /** * The number of the next page, if any. If `null`, the current page is the last page of records. */ - next_page: (number) | null; + next_page: number | null; total_records: number; }; sandboxes: Array<{ created_at: string; - description?: (string) | null; + description?: string | null; id: string; is_frozen: boolean; privacy: number; - tags: Array<(string)>; - title?: (string) | null; + tags: Array; + title?: string | null; updated_at: string; }>; }; @@ -256,7 +231,7 @@ export type TokenCreateRequest = { /** * API Version to use, formatted as YYYY-MM-DD. Defaults to the latest version at time of creation. */ - default_version?: (string) | null; + default_version?: string | null; /** * Description of this token, for instance where it will be used. */ @@ -264,23 +239,21 @@ export type TokenCreateRequest = { /** * UTC Timestamp until when this token is valid. Omitting this field will create a token without an expiry. */ - expires_at?: (string) | null; + expires_at?: string | null; /** * Which scopes to grant this token. The given scopes will replace the current scopes, revoking any that are no longer present in the list. */ - scopes?: Array<('sandbox_create' | 'sandbox_edit_code' | 'sandbox_read' | 'vm_manage')>; + scopes?: Array<'sandbox_create' | 'sandbox_edit_code' | 'sandbox_read' | 'vm_manage'>; }; export type TokenCreateResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; + errors?: Array; success?: boolean; } & { data?: { - description: (string) | null; - expires_at: (string) | null; - scopes: Array<(string)>; + description: string | null; + expires_at: string | null; + scopes: Array; team_id: string; token: string; token_id: string; @@ -294,37 +267,35 @@ export type TokenUpdateRequest = { /** * API Version to use, formatted as YYYY-MM-DD */ - default_version?: (string) | null; + default_version?: string | null; /** * Description of this token, for instance where it will be used. */ - description?: (string) | null; + description?: string | null; /** * Expiry time of this token. Cannot be set in the past, and cannot be changed for tokens that have already expired. Pass null to make this token never expire. */ - expires_at?: (string) | null; + expires_at?: string | null; /** * Which scopes to grant this token. The given scopes will replace the current scopes, revoking any that are no longer present in the list. */ - scopes?: Array<('sandbox_create' | 'sandbox_edit_code' | 'sandbox_read' | 'vm_manage')>; + scopes?: Array<'sandbox_create' | 'sandbox_edit_code' | 'sandbox_read' | 'vm_manage'>; }; export type TokenUpdateResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; + errors?: Array; success?: boolean; } & { data?: { - description: (string) | null; - expires_at?: (string) | null; - scopes: Array<(string)>; + description: string | null; + expires_at?: string | null; + scopes: Array; team_id: string; token_id: string; }; }; -export type VMCreateSessionRequest = { +export type VmCreateSessionRequest = { /** * Permission level for the session */ @@ -335,22 +306,15 @@ export type VMCreateSessionRequest = { session_id: string; }; -/** - * Permission level for the session - */ -export type permission = 'read' | 'write'; - -export type VMCreateSessionResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; +export type VmCreateSessionResponse = { + errors?: Array; success?: boolean; } & { data?: { /** * List of capabilities that Pitcher has */ - capabilities: Array<(string)>; + capabilities: Array; /** * The permissions of the current session */ @@ -376,14 +340,12 @@ export type VMCreateSessionResponse = { }; }; -export type VMHibernateRequest = { +export type VmHibernateRequest = { [key: string]: unknown; }; -export type VMHibernateResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; +export type VmHibernateResponse = { + errors?: Array; success?: boolean; } & { data?: { @@ -391,14 +353,12 @@ export type VMHibernateResponse = { }; }; -export type VMShutdownRequest = { +export type VmShutdownRequest = { [key: string]: unknown; }; -export type VMShutdownResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; +export type VmShutdownResponse = { + errors?: Array; success?: boolean; } & { data?: { @@ -406,7 +366,7 @@ export type VMShutdownResponse = { }; }; -export type VMStartRequest = { +export type VmStartRequest = { /** * The time in seconds after which the VM will hibernate due to inactivity. * Must be a positive integer between 1 and 86400 (24 hours). @@ -429,10 +389,8 @@ export type VMStartRequest = { tier?: 'Pico' | 'Nano' | 'Micro' | 'Small' | 'Medium' | 'Large' | 'XLarge'; }; -export type VMStartResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; +export type VmStartResponse = { + errors?: Array; success?: boolean; } & { data?: { @@ -450,7 +408,7 @@ export type VMStartResponse = { }; }; -export type VMUpdateHibernationTimeoutRequest = { +export type VmUpdateHibernationTimeoutRequest = { /** * The new hibernation timeout in seconds. * @@ -460,10 +418,8 @@ export type VMUpdateHibernationTimeoutRequest = { hibernation_timeout_seconds: number; }; -export type VMUpdateHibernationTimeoutResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; +export type VmUpdateHibernationTimeoutResponse = { + errors?: Array; success?: boolean; } & { data?: { @@ -472,7 +428,7 @@ export type VMUpdateHibernationTimeoutResponse = { }; }; -export type VMUpdateSpecsRequest = { +export type VmUpdateSpecsRequest = { /** * Determines which specs to update the VM with. * @@ -482,10 +438,8 @@ export type VMUpdateSpecsRequest = { tier: 'Pico' | 'Nano' | 'Micro' | 'Small' | 'Medium' | 'Large' | 'XLarge'; }; -export type VMUpdateSpecsResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; +export type VmUpdateSpecsResponse = { + errors?: Array; success?: boolean; } & { data?: { @@ -502,9 +456,7 @@ export type WorkspaceCreateRequest = { }; export type WorkspaceCreateResponse = { - errors?: Array<((string | { - [key: string]: unknown; -}))>; + errors?: Array; success?: boolean; } & { data?: { @@ -513,99 +465,159 @@ export type WorkspaceCreateResponse = { }; }; -export type MetaInfoResponse = (MetaInformation); +export type MetaInfoData = { + body?: never; + path?: never; + query?: never; + url: '/meta/info'; +}; + +export type MetaInfoResponses = { + /** + * Meta Info Response + */ + 200: MetaInformation; +}; -export type MetaInfoError = unknown; +export type MetaInfoResponse = MetaInfoResponses[keyof MetaInfoResponses]; export type WorkspaceCreateData = { /** * Workspace Create Request */ body?: WorkspaceCreateRequest; + path?: never; + query?: never; + url: '/org/workspace'; }; -export type WorkspaceCreateResponse2 = (WorkspaceCreateResponse); +export type WorkspaceCreateResponses = { + /** + * Workspace Create Response + */ + 201: WorkspaceCreateResponse; +}; -export type WorkspaceCreateError = unknown; +export type WorkspaceCreateResponse2 = WorkspaceCreateResponses[keyof WorkspaceCreateResponses]; export type TokenCreateData = { /** * Token Create Request */ body?: TokenCreateRequest; + path?: never; + query?: never; + url: '/org/workspace/{team_id}/tokens'; }; -export type TokenCreateResponse2 = (TokenCreateResponse); +export type TokenCreateResponses = { + /** + * Token Create Response + */ + 201: TokenCreateResponse; +}; -export type TokenCreateError = unknown; +export type TokenCreateResponse2 = TokenCreateResponses[keyof TokenCreateResponses]; export type TokenUpdateData = { /** * Token Update Request */ body?: TokenUpdateRequest; + path?: never; + query?: never; + url: '/org/workspace/{team_id}/tokens/{token_id}'; }; -export type TokenUpdateResponse2 = (TokenUpdateResponse); +export type TokenUpdateResponses = { + /** + * Token Update Response + */ + 201: TokenUpdateResponse; +}; -export type TokenUpdateError = unknown; +export type TokenUpdateResponse2 = TokenUpdateResponses[keyof TokenUpdateResponses]; export type SandboxListData = { + body?: never; + path?: never; query?: { /** - * Order direction + * Comma-separated list of tags to filter by */ - direction?: 'asc' | 'desc'; + tags?: string; /** * Field to order results by */ order_by?: 'inserted_at' | 'updated_at'; /** - * Page number to return + * Order direction */ - page?: number; + direction?: 'asc' | 'desc'; /** * Maximum number of sandboxes to return in a single response */ page_size?: number; /** - * If true, only returns VMs for which a heartbeat was received in the last 30 seconds. + * Page number to return */ - status?: 'running'; + page?: number; /** - * Comma-separated list of tags to filter by + * If true, only returns VMs for which a heartbeat was received in the last 30 seconds. */ - tags?: string; + status?: 'running'; }; + url: '/sandbox'; }; -export type SandboxListResponse2 = (SandboxListResponse); +export type SandboxListResponses = { + /** + * Sandbox List Response + */ + 200: SandboxListResponse; +}; -export type SandboxListError = unknown; +export type SandboxListResponse2 = SandboxListResponses[keyof SandboxListResponses]; export type SandboxCreateData = { /** * Sandbox Create Request */ body?: SandboxCreateRequest; + path?: never; + query?: never; + url: '/sandbox'; }; -export type SandboxCreateResponse2 = (SandboxCreateResponse); +export type SandboxCreateResponses = { + /** + * Sandbox Create Response + */ + 201: SandboxCreateResponse; +}; -export type SandboxCreateError = unknown; +export type SandboxCreateResponse2 = SandboxCreateResponses[keyof SandboxCreateResponses]; export type SandboxGetData = { + body?: never; path: { /** * Short ID of the sandbox to retrieve */ id: string; }; + query?: never; + url: '/sandbox/{id}'; }; -export type SandboxGetResponse2 = (SandboxGetResponse); +export type SandboxGetResponses = { + /** + * Sandbox Get Response + */ + 200: SandboxGetResponse; +}; -export type SandboxGetError = unknown; +export type SandboxGetResponse2 = SandboxGetResponses[keyof SandboxGetResponses]; export type SandboxForkData = { /** @@ -618,127 +630,183 @@ export type SandboxForkData = { */ id: string; }; + query?: never; + url: '/sandbox/{id}/fork'; }; -export type SandboxForkResponse2 = (SandboxForkResponse); +export type SandboxForkResponses = { + /** + * Sandbox Fork Response + */ + 201: SandboxForkResponse; +}; -export type SandboxForkError = unknown; +export type SandboxForkResponse2 = SandboxForkResponses[keyof SandboxForkResponses]; export type VmHibernateData = { /** * VM Hibernate Request */ - body?: VMHibernateRequest; + body?: VmHibernateRequest; path: { /** * Sandbox ID */ id: string; }; + query?: never; + url: '/vm/{id}/hibernate'; }; -export type VmHibernateResponse = (VMHibernateResponse); +export type VmHibernateResponses = { + /** + * VM Hibernate Response + */ + 200: VmHibernateResponse; +}; -export type VmHibernateError = unknown; +export type VmHibernateResponse2 = VmHibernateResponses[keyof VmHibernateResponses]; export type VmUpdateHibernationTimeoutData = { /** * VM Update Hibernation Timeout Request */ - body?: VMUpdateHibernationTimeoutRequest; + body?: VmUpdateHibernationTimeoutRequest; path: { /** * Sandbox ID */ id: string; }; + query?: never; + url: '/vm/{id}/hibernation_timeout'; }; -export type VmUpdateHibernationTimeoutResponse = (VMUpdateHibernationTimeoutResponse); +export type VmUpdateHibernationTimeoutResponses = { + /** + * VM Update Hibernation Timeout Response + */ + 200: VmUpdateHibernationTimeoutResponse; +}; -export type VmUpdateHibernationTimeoutError = unknown; +export type VmUpdateHibernationTimeoutResponse2 = VmUpdateHibernationTimeoutResponses[keyof VmUpdateHibernationTimeoutResponses]; export type VmCreateSessionData = { /** * VM Create Session Request */ - body?: VMCreateSessionRequest; + body?: VmCreateSessionRequest; path: { /** * Sandbox ID */ id: string; }; + query?: never; + url: '/vm/{id}/sessions'; }; -export type VmCreateSessionResponse = (VMCreateSessionResponse); +export type VmCreateSessionResponses = { + /** + * VM Create Session Response + */ + 200: VmCreateSessionResponse; +}; -export type VmCreateSessionError = unknown; +export type VmCreateSessionResponse2 = VmCreateSessionResponses[keyof VmCreateSessionResponses]; export type VmShutdownData = { /** * VM Shutdown Request */ - body?: VMShutdownRequest; + body?: VmShutdownRequest; path: { /** * Sandbox ID */ id: string; }; + query?: never; + url: '/vm/{id}/shutdown'; }; -export type VmShutdownResponse = (VMShutdownResponse); +export type VmShutdownResponses = { + /** + * VM Shutdown Response + */ + 200: VmShutdownResponse; +}; -export type VmShutdownError = unknown; +export type VmShutdownResponse2 = VmShutdownResponses[keyof VmShutdownResponses]; export type VmUpdateSpecsData = { /** * VM Update Specs Request */ - body?: VMUpdateSpecsRequest; + body?: VmUpdateSpecsRequest; path: { /** * Sandbox ID */ id: string; }; + query?: never; + url: '/vm/{id}/specs'; }; -export type VmUpdateSpecsResponse = (VMUpdateSpecsResponse); +export type VmUpdateSpecsResponses = { + /** + * VM Update Specs Response + */ + 200: VmUpdateSpecsResponse; +}; -export type VmUpdateSpecsError = unknown; +export type VmUpdateSpecsResponse2 = VmUpdateSpecsResponses[keyof VmUpdateSpecsResponses]; export type VmStartData = { /** * VM Start Request */ - body?: VMStartRequest; + body?: VmStartRequest; path: { /** * Sandbox ID */ id: string; }; + query?: never; + url: '/vm/{id}/start'; }; -export type VmStartResponse = (VMStartResponse); +export type VmStartResponses = { + /** + * VM Start Response + */ + 200: VmStartResponse; +}; -export type VmStartError = unknown; +export type VmStartResponse2 = VmStartResponses[keyof VmStartResponses]; export type VmUpdateSpecs2Data = { /** * VM Update Specs Request */ - body?: VMUpdateSpecsRequest; + body?: VmUpdateSpecsRequest; path: { /** * Sandbox ID */ id: string; }; + query?: never; + url: '/vm/{id}/update_specs'; }; -export type VmUpdateSpecs2Response = (VMUpdateSpecsResponse); +export type VmUpdateSpecs2Responses = { + /** + * VM Update Specs Response + */ + 200: VmUpdateSpecsResponse; +}; -export type VmUpdateSpecs2Error = unknown; \ No newline at end of file +export type VmUpdateSpecs2Response = VmUpdateSpecs2Responses[keyof VmUpdateSpecs2Responses]; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 5889515..bd012aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -81,6 +81,7 @@ export class CodeSandbox { Authorization: `Bearer ${this.apiToken}`, ...(opts.headers ?? {}), }, + fetch: opts.fetch ?? fetch, }) ); diff --git a/src/sandbox-client.ts b/src/sandbox-client.ts index f2a9a28..097a903 100644 --- a/src/sandbox-client.ts +++ b/src/sandbox-client.ts @@ -1,7 +1,7 @@ import { initPitcherClient } from "@codesandbox/pitcher-client"; import type { Client } from "@hey-api/client-fetch"; -import type { VmStartResponse, tier } from "./client"; +import type { VmStartResponse, VmUpdateSpecsRequest } from "./client"; import { sandboxFork, vmCreateSession, @@ -155,13 +155,13 @@ export class VMTier { public static readonly XLarge = new VMTier("XLarge", 64, 128, 50); private constructor( - public readonly name: tier, + public readonly name: VmUpdateSpecsRequest["tier"], public readonly cpuCores: number, public readonly memoryGiB: number, public readonly diskGB: number ) {} - public static fromName(name: tier): VMTier { + public static fromName(name: VmUpdateSpecsRequest["tier"]): VMTier { return VMTier[name]; }