refactor(sdk): remove local legacy package
This commit is contained in:
parent
28f4284bd7
commit
80865407e0
74 changed files with 46983 additions and 87229 deletions
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
"@opencode-ai/ai": patch
|
|
||||||
---
|
|
||||||
|
|
||||||
Report OpenAI prompt cache write tokens in normalized usage.
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
---
|
|
||||||
"@opencode-ai/client": patch
|
|
||||||
"@opencode-ai/protocol": patch
|
|
||||||
"@opencode-ai/cli": patch
|
|
||||||
---
|
|
||||||
|
|
||||||
Expose background-service lifecycle status, preserve one process-held owner through startup and failure, reconnect TUIs without activating replacement, and stop exact service instances gracefully.
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
"@opencode-ai/cli": patch
|
|
||||||
---
|
|
||||||
|
|
||||||
Expose a TUI plugin slot at the top of the session view.
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
---
|
|
||||||
"@opencode-ai/plugin": minor
|
|
||||||
"@opencode-ai/sdk": minor
|
|
||||||
"@opencode-ai/client": minor
|
|
||||||
"@opencode-ai/protocol": minor
|
|
||||||
---
|
|
||||||
|
|
||||||
Replace the V2 tool result model with one canonical representation per fact. Tools lose `structured`, projection callbacks, the `Structured` generic, and the exported `Tool.settle` interpreter; tool responses carry schema-validated `output`, model-visible `content`, and optional compact JSON `metadata`. Code Mode receives the validated encoded output. Durable tool success stores non-empty model content plus optional metadata; failure stores one error plus the final bounded partial snapshot. Progress carries metadata only, while `execute.after` hooks receive the canonical terminal outcome and managed `outputPaths`. A one-time migration rewrites existing projected tool rows and moves provider-hosted result payloads into provider-owned result state.
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
---
|
|
||||||
"@opencode-ai/client": patch
|
|
||||||
"@opencode-ai/plugin": patch
|
|
||||||
"@opencode-ai/protocol": patch
|
|
||||||
---
|
|
||||||
|
|
||||||
Expose transient, read-only session generation through the HTTP API, generated clients, and V2 plugin session context.
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
"@opencode-ai/cli": patch
|
|
||||||
---
|
|
||||||
|
|
||||||
Expose a TUI plugin slot above the session composer.
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
"@opencode-ai/ai": patch
|
|
||||||
---
|
|
||||||
|
|
||||||
Improve Anthropic and Bedrock prompt reuse with layered cache breakpoints that roll through long tool loops.
|
|
||||||
91
bun.lock
91
bun.lock
|
|
@ -8,7 +8,7 @@
|
||||||
"@aws-sdk/client-s3": "3.933.0",
|
"@aws-sdk/client-s3": "3.933.0",
|
||||||
"@opencode-ai/plugin": "workspace:*",
|
"@opencode-ai/plugin": "workspace:*",
|
||||||
"@opencode-ai/script": "workspace:*",
|
"@opencode-ai/script": "workspace:*",
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "1.18.5",
|
||||||
"heap-snapshot-toolkit": "1.1.3",
|
"heap-snapshot-toolkit": "1.1.3",
|
||||||
"typescript": "catalog:",
|
"typescript": "catalog:",
|
||||||
},
|
},
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
"@opencode-ai/client": "file:vendor/opencode-ai-client-1.17.13.tgz",
|
"@opencode-ai/client": "file:vendor/opencode-ai-client-1.17.13.tgz",
|
||||||
"@opencode-ai/core": "workspace:*",
|
"@opencode-ai/core": "workspace:*",
|
||||||
"@opencode-ai/schema": "workspace:*",
|
"@opencode-ai/schema": "workspace:*",
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "1.18.5",
|
||||||
"@opencode-ai/session-ui": "workspace:*",
|
"@opencode-ai/session-ui": "workspace:*",
|
||||||
"@opencode-ai/ui": "workspace:*",
|
"@opencode-ai/ui": "workspace:*",
|
||||||
"@pierre/trees": "1.0.0-beta.4",
|
"@pierre/trees": "1.0.0-beta.4",
|
||||||
|
|
@ -582,7 +582,7 @@
|
||||||
"@opencode-ai/ai": "workspace:*",
|
"@opencode-ai/ai": "workspace:*",
|
||||||
"@opencode-ai/client": "workspace:*",
|
"@opencode-ai/client": "workspace:*",
|
||||||
"@opencode-ai/schema": "workspace:*",
|
"@opencode-ai/schema": "workspace:*",
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "1.18.5",
|
||||||
"@standard-schema/spec": "^1.1.0",
|
"@standard-schema/spec": "^1.1.0",
|
||||||
"effect": "catalog:",
|
"effect": "catalog:",
|
||||||
"zod": "catalog:",
|
"zod": "catalog:",
|
||||||
|
|
@ -663,21 +663,6 @@
|
||||||
"@typescript/native-preview": "catalog:",
|
"@typescript/native-preview": "catalog:",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"packages/sdk/js": {
|
|
||||||
"name": "@opencode-ai/sdk",
|
|
||||||
"version": "1.18.4",
|
|
||||||
"dependencies": {
|
|
||||||
"cross-spawn": "catalog:",
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@hey-api/openapi-ts": "0.90.10",
|
|
||||||
"@tsconfig/node22": "catalog:",
|
|
||||||
"@types/cross-spawn": "catalog:",
|
|
||||||
"@types/node": "catalog:",
|
|
||||||
"@typescript/native-preview": "catalog:",
|
|
||||||
"typescript": "catalog:",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"packages/server": {
|
"packages/server": {
|
||||||
"name": "@opencode-ai/server",
|
"name": "@opencode-ai/server",
|
||||||
"version": "1.18.4",
|
"version": "1.18.4",
|
||||||
|
|
@ -703,7 +688,7 @@
|
||||||
"@kobalte/core": "catalog:",
|
"@kobalte/core": "catalog:",
|
||||||
"@opencode-ai/client": "file:../app/vendor/opencode-ai-client-1.17.13.tgz",
|
"@opencode-ai/client": "file:../app/vendor/opencode-ai-client-1.17.13.tgz",
|
||||||
"@opencode-ai/core": "workspace:*",
|
"@opencode-ai/core": "workspace:*",
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "1.18.5",
|
||||||
"@opencode-ai/ui": "workspace:*",
|
"@opencode-ai/ui": "workspace:*",
|
||||||
"@pierre/diffs": "catalog:",
|
"@pierre/diffs": "catalog:",
|
||||||
"@shikijs/stream": "catalog:",
|
"@shikijs/stream": "catalog:",
|
||||||
|
|
@ -767,7 +752,7 @@
|
||||||
"name": "@opencode-ai/slack",
|
"name": "@opencode-ai/slack",
|
||||||
"version": "1.18.4",
|
"version": "1.18.4",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "1.18.5",
|
||||||
"@slack/bolt": "^3.17.1",
|
"@slack/bolt": "^3.17.1",
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
@ -1716,14 +1701,6 @@
|
||||||
|
|
||||||
"@happy-dom/global-registrator": ["@happy-dom/global-registrator@20.0.11", "", { "dependencies": { "@types/node": "^20.0.0", "happy-dom": "^20.0.11" } }, "sha512-GqNqiShBT/lzkHTMC/slKBrvN0DsD4Di8ssBk4aDaVgEn+2WMzE6DXxq701ndSXj7/0cJ8mNT71pM7Bnrr6JRw=="],
|
"@happy-dom/global-registrator": ["@happy-dom/global-registrator@20.0.11", "", { "dependencies": { "@types/node": "^20.0.0", "happy-dom": "^20.0.11" } }, "sha512-GqNqiShBT/lzkHTMC/slKBrvN0DsD4Di8ssBk4aDaVgEn+2WMzE6DXxq701ndSXj7/0cJ8mNT71pM7Bnrr6JRw=="],
|
||||||
|
|
||||||
"@hey-api/codegen-core": ["@hey-api/codegen-core@0.5.5", "", { "dependencies": { "@hey-api/types": "0.1.2", "ansi-colors": "4.1.3", "c12": "3.3.3", "color-support": "1.1.3" }, "peerDependencies": { "typescript": ">=5.5.3" } }, "sha512-f2ZHucnA2wBGAY8ipB4wn/mrEYW+WUxU2huJmUvfDO6AE2vfILSHeF3wCO39Pz4wUYPoAWZByaauftLrOfC12Q=="],
|
|
||||||
|
|
||||||
"@hey-api/json-schema-ref-parser": ["@hey-api/json-schema-ref-parser@1.2.2", "", { "dependencies": { "@jsdevtools/ono": "^7.1.3", "@types/json-schema": "^7.0.15", "js-yaml": "^4.1.1", "lodash": "^4.17.21" } }, "sha512-oS+5yAdwnK20lSeFO1d53Ku+yaGCsY8PcrmSq2GtSs3bsBfRnHAbpPKSVzQcaxAOrzj5NB+f34WhZglVrNayBA=="],
|
|
||||||
|
|
||||||
"@hey-api/openapi-ts": ["@hey-api/openapi-ts@0.90.10", "", { "dependencies": { "@hey-api/codegen-core": "^0.5.5", "@hey-api/json-schema-ref-parser": "1.2.2", "@hey-api/types": "0.1.2", "ansi-colors": "4.1.3", "color-support": "1.1.3", "commander": "14.0.2", "open": "11.0.0", "semver": "7.7.3" }, "peerDependencies": { "typescript": ">=5.5.3" }, "bin": { "openapi-ts": "bin/run.js" } }, "sha512-o0wlFxuLt1bcyIV/ZH8DQ1wrgODTnUYj/VfCHOOYgXUQlLp9Dm2PjihOz+WYrZLowhqUhSKeJRArOGzvLuOTsg=="],
|
|
||||||
|
|
||||||
"@hey-api/types": ["@hey-api/types@0.1.2", "", {}, "sha512-uNNtiVAWL7XNrV/tFXx7GLY9lwaaDazx1173cGW3+UEaw4RUPsHEmiB4DSpcjNxMIcrctfz2sGKLnVx5PBG2RA=="],
|
|
||||||
|
|
||||||
"@hono/node-server": ["@hono/node-server@1.19.14", "", { "peerDependencies": { "hono": "^4" } }, "sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw=="],
|
"@hono/node-server": ["@hono/node-server@1.19.14", "", { "peerDependencies": { "hono": "^4" } }, "sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw=="],
|
||||||
|
|
||||||
"@hono/standard-validator": ["@hono/standard-validator@0.2.0", "", { "peerDependencies": { "@standard-schema/spec": "1.0.0", "hono": ">=3.9.0" } }, "sha512-pFq0UVAnjzXcDAgqFpDeVL3MOUPrlIh/kPqBDvbCYoThVhhS+Vf37VcdsakdOFFGiqoiYVxp3LifXFhGhp/rgQ=="],
|
"@hono/standard-validator": ["@hono/standard-validator@0.2.0", "", { "peerDependencies": { "@standard-schema/spec": "1.0.0", "hono": ">=3.9.0" } }, "sha512-pFq0UVAnjzXcDAgqFpDeVL3MOUPrlIh/kPqBDvbCYoThVhhS+Vf37VcdsakdOFFGiqoiYVxp3LifXFhGhp/rgQ=="],
|
||||||
|
|
@ -1814,8 +1791,6 @@
|
||||||
|
|
||||||
"@js-temporal/polyfill": ["@js-temporal/polyfill@0.5.1", "", { "dependencies": { "jsbi": "^4.3.0" } }, "sha512-hloP58zRVCRSpgDxmqCWJNlizAlUgJFqG2ypq79DCvyv9tHjRYMDOcPFjzfl/A1/YxDvRCZz8wvZvmapQnKwFQ=="],
|
"@js-temporal/polyfill": ["@js-temporal/polyfill@0.5.1", "", { "dependencies": { "jsbi": "^4.3.0" } }, "sha512-hloP58zRVCRSpgDxmqCWJNlizAlUgJFqG2ypq79DCvyv9tHjRYMDOcPFjzfl/A1/YxDvRCZz8wvZvmapQnKwFQ=="],
|
||||||
|
|
||||||
"@jsdevtools/ono": ["@jsdevtools/ono@7.1.3", "", {}, "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg=="],
|
|
||||||
|
|
||||||
"@jsx-email/all": ["@jsx-email/all@2.2.3", "", { "dependencies": { "@jsx-email/body": "1.0.2", "@jsx-email/button": "1.0.4", "@jsx-email/column": "1.0.3", "@jsx-email/container": "1.0.2", "@jsx-email/font": "1.0.3", "@jsx-email/head": "1.0.2", "@jsx-email/heading": "1.0.2", "@jsx-email/hr": "1.0.2", "@jsx-email/html": "1.0.2", "@jsx-email/img": "1.0.2", "@jsx-email/link": "1.0.2", "@jsx-email/markdown": "2.0.4", "@jsx-email/preview": "1.0.2", "@jsx-email/render": "1.1.1", "@jsx-email/row": "1.0.2", "@jsx-email/section": "1.0.2", "@jsx-email/tailwind": "2.4.4", "@jsx-email/text": "1.0.2" }, "peerDependencies": { "react": "^18.2.0" } }, "sha512-OBvLe/hVSQc0LlMSTJnkjFoqs3bmxcC4zpy/5pT5agPCSKMvAKQjzmsc2xJ2wO73jSpRV1K/g38GmvdCfrhSoQ=="],
|
"@jsx-email/all": ["@jsx-email/all@2.2.3", "", { "dependencies": { "@jsx-email/body": "1.0.2", "@jsx-email/button": "1.0.4", "@jsx-email/column": "1.0.3", "@jsx-email/container": "1.0.2", "@jsx-email/font": "1.0.3", "@jsx-email/head": "1.0.2", "@jsx-email/heading": "1.0.2", "@jsx-email/hr": "1.0.2", "@jsx-email/html": "1.0.2", "@jsx-email/img": "1.0.2", "@jsx-email/link": "1.0.2", "@jsx-email/markdown": "2.0.4", "@jsx-email/preview": "1.0.2", "@jsx-email/render": "1.1.1", "@jsx-email/row": "1.0.2", "@jsx-email/section": "1.0.2", "@jsx-email/tailwind": "2.4.4", "@jsx-email/text": "1.0.2" }, "peerDependencies": { "react": "^18.2.0" } }, "sha512-OBvLe/hVSQc0LlMSTJnkjFoqs3bmxcC4zpy/5pT5agPCSKMvAKQjzmsc2xJ2wO73jSpRV1K/g38GmvdCfrhSoQ=="],
|
||||||
|
|
||||||
"@jsx-email/body": ["@jsx-email/body@1.0.2", "", { "peerDependencies": { "react": "^18.2.0" } }, "sha512-NjR2tgLH4XGfGkm+O8kcVwi9MBqZsXZCLlmk3HlMux3/n/+a5zB+yhJqXWZBJl2i+6cSF+E2O6hK11ekyK9WWQ=="],
|
"@jsx-email/body": ["@jsx-email/body@1.0.2", "", { "peerDependencies": { "react": "^18.2.0" } }, "sha512-NjR2tgLH4XGfGkm+O8kcVwi9MBqZsXZCLlmk3HlMux3/n/+a5zB+yhJqXWZBJl2i+6cSF+E2O6hK11ekyK9WWQ=="],
|
||||||
|
|
@ -2074,7 +2049,7 @@
|
||||||
|
|
||||||
"@opencode-ai/script": ["@opencode-ai/script@workspace:packages/script"],
|
"@opencode-ai/script": ["@opencode-ai/script@workspace:packages/script"],
|
||||||
|
|
||||||
"@opencode-ai/sdk": ["@opencode-ai/sdk@workspace:packages/sdk/js"],
|
"@opencode-ai/sdk": ["@opencode-ai/sdk@1.18.5", "", { "dependencies": { "cross-spawn": "7.0.6" } }, "sha512-7KgMvP5/1oxbhHj6kYBtPSTEdFKYpUeEYOzBTKdzSaRpapUpFFdn6Hkus3rr0rljO0kukWZIgRd3DrVBwTULGA=="],
|
||||||
|
|
||||||
"@opencode-ai/sdk-next": ["@opencode-ai/sdk-next@workspace:packages/sdk-next"],
|
"@opencode-ai/sdk-next": ["@opencode-ai/sdk-next@workspace:packages/sdk-next"],
|
||||||
|
|
||||||
|
|
@ -3308,8 +3283,6 @@
|
||||||
|
|
||||||
"ansi-align": ["ansi-align@3.0.1", "", { "dependencies": { "string-width": "^4.1.0" } }, "sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w=="],
|
"ansi-align": ["ansi-align@3.0.1", "", { "dependencies": { "string-width": "^4.1.0" } }, "sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w=="],
|
||||||
|
|
||||||
"ansi-colors": ["ansi-colors@4.1.3", "", {}, "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw=="],
|
|
||||||
|
|
||||||
"ansi-regex": ["ansi-regex@6.2.2", "", {}, "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg=="],
|
"ansi-regex": ["ansi-regex@6.2.2", "", {}, "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg=="],
|
||||||
|
|
||||||
"ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
|
"ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
|
||||||
|
|
@ -3500,8 +3473,6 @@
|
||||||
|
|
||||||
"bytestreamjs": ["bytestreamjs@2.0.1", "", {}, "sha512-U1Z/ob71V/bXfVABvNr/Kumf5VyeQRBEm6Txb0PQ6S7V5GpBM3w4Cbqz/xPDicR5tN0uvDifng8C+5qECeGwyQ=="],
|
"bytestreamjs": ["bytestreamjs@2.0.1", "", {}, "sha512-U1Z/ob71V/bXfVABvNr/Kumf5VyeQRBEm6Txb0PQ6S7V5GpBM3w4Cbqz/xPDicR5tN0uvDifng8C+5qECeGwyQ=="],
|
||||||
|
|
||||||
"c12": ["c12@3.3.3", "", { "dependencies": { "chokidar": "^5.0.0", "confbox": "^0.2.2", "defu": "^6.1.4", "dotenv": "^17.2.3", "exsolve": "^1.0.8", "giget": "^2.0.0", "jiti": "^2.6.1", "ohash": "^2.0.11", "pathe": "^2.0.3", "perfect-debounce": "^2.0.0", "pkg-types": "^2.3.0", "rc9": "^2.1.2" }, "peerDependencies": { "magicast": "*" }, "optionalPeers": ["magicast"] }, "sha512-750hTRvgBy5kcMNPdh95Qo+XUBeGo8C7nsKSmedDmaQI+E0r82DwHeM6vBewDe4rGFbnxoa4V9pw+sPh5+Iz8Q=="],
|
|
||||||
|
|
||||||
"cac": ["cac@6.7.14", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="],
|
"cac": ["cac@6.7.14", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="],
|
||||||
|
|
||||||
"cacache": ["cacache@20.0.4", "", { "dependencies": { "@npmcli/fs": "^5.0.0", "fs-minipass": "^3.0.0", "glob": "^13.0.0", "lru-cache": "^11.1.0", "minipass": "^7.0.3", "minipass-collect": "^2.0.1", "minipass-flush": "^1.0.5", "minipass-pipeline": "^1.2.4", "p-map": "^7.0.2", "ssri": "^13.0.0" } }, "sha512-M3Lab8NPYlZU2exsL3bMVvMrMqgwCnMWfdZbK28bn3pK6APT/Te/I8hjRPNu1uwORY9a1eEQoifXbKPQMfMTOA=="],
|
"cacache": ["cacache@20.0.4", "", { "dependencies": { "@npmcli/fs": "^5.0.0", "fs-minipass": "^3.0.0", "glob": "^13.0.0", "lru-cache": "^11.1.0", "minipass": "^7.0.3", "minipass-collect": "^2.0.1", "minipass-flush": "^1.0.5", "minipass-pipeline": "^1.2.4", "p-map": "^7.0.2", "ssri": "^13.0.0" } }, "sha512-M3Lab8NPYlZU2exsL3bMVvMrMqgwCnMWfdZbK28bn3pK6APT/Te/I8hjRPNu1uwORY9a1eEQoifXbKPQMfMTOA=="],
|
||||||
|
|
@ -3596,13 +3567,11 @@
|
||||||
|
|
||||||
"color-string": ["color-string@1.9.1", "", { "dependencies": { "color-name": "^1.0.0", "simple-swizzle": "^0.2.2" } }, "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg=="],
|
"color-string": ["color-string@1.9.1", "", { "dependencies": { "color-name": "^1.0.0", "simple-swizzle": "^0.2.2" } }, "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg=="],
|
||||||
|
|
||||||
"color-support": ["color-support@1.1.3", "", { "bin": { "color-support": "bin.js" } }, "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg=="],
|
|
||||||
|
|
||||||
"combined-stream": ["combined-stream@1.0.8", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
|
"combined-stream": ["combined-stream@1.0.8", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
|
||||||
|
|
||||||
"comma-separated-tokens": ["comma-separated-tokens@2.0.3", "", {}, "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="],
|
"comma-separated-tokens": ["comma-separated-tokens@2.0.3", "", {}, "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="],
|
||||||
|
|
||||||
"commander": ["commander@14.0.2", "", {}, "sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ=="],
|
"commander": ["commander@8.3.0", "", {}, "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww=="],
|
||||||
|
|
||||||
"common-ancestor-path": ["common-ancestor-path@2.0.0", "", {}, "sha512-dnN3ibLeoRf2HNC+OlCiNc5d2zxbLJXOtiZUudNFSXZrNSydxcCsSpRzXwfu7BBWCIfHPw+xTayeBvJCP/D8Ng=="],
|
"common-ancestor-path": ["common-ancestor-path@2.0.0", "", {}, "sha512-dnN3ibLeoRf2HNC+OlCiNc5d2zxbLJXOtiZUudNFSXZrNSydxcCsSpRzXwfu7BBWCIfHPw+xTayeBvJCP/D8Ng=="],
|
||||||
|
|
||||||
|
|
@ -3616,8 +3585,6 @@
|
||||||
|
|
||||||
"conf": ["conf@15.1.0", "", { "dependencies": { "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "atomically": "^2.0.3", "debounce-fn": "^6.0.0", "dot-prop": "^10.0.0", "env-paths": "^3.0.0", "json-schema-typed": "^8.0.1", "semver": "^7.7.2", "uint8array-extras": "^1.5.0" } }, "sha512-Uy5YN9KEu0WWDaZAVJ5FAmZoaJt9rdK6kH+utItPyGsCqCgaTKkrmZx3zoE0/3q6S3bcp3Ihkk+ZqPxWxFK5og=="],
|
"conf": ["conf@15.1.0", "", { "dependencies": { "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "atomically": "^2.0.3", "debounce-fn": "^6.0.0", "dot-prop": "^10.0.0", "env-paths": "^3.0.0", "json-schema-typed": "^8.0.1", "semver": "^7.7.2", "uint8array-extras": "^1.5.0" } }, "sha512-Uy5YN9KEu0WWDaZAVJ5FAmZoaJt9rdK6kH+utItPyGsCqCgaTKkrmZx3zoE0/3q6S3bcp3Ihkk+ZqPxWxFK5og=="],
|
||||||
|
|
||||||
"confbox": ["confbox@0.2.4", "", {}, "sha512-ysOGlgTFbN2/Y6Cg3Iye8YKulHw+R2fNXHrgSmXISQdMnomY6eNDprVdW9R5xBguEqI954+S6709UyiO7B+6OQ=="],
|
|
||||||
|
|
||||||
"config-chain": ["config-chain@1.1.13", "", { "dependencies": { "ini": "^1.3.4", "proto-list": "~1.2.1" } }, "sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ=="],
|
"config-chain": ["config-chain@1.1.13", "", { "dependencies": { "ini": "^1.3.4", "proto-list": "~1.2.1" } }, "sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ=="],
|
||||||
|
|
||||||
"consola": ["consola@3.4.2", "", {}, "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA=="],
|
"consola": ["consola@3.4.2", "", {}, "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA=="],
|
||||||
|
|
@ -4006,8 +3973,6 @@
|
||||||
|
|
||||||
"expressive-code": ["expressive-code@0.41.7", "", { "dependencies": { "@expressive-code/core": "^0.41.7", "@expressive-code/plugin-frames": "^0.41.7", "@expressive-code/plugin-shiki": "^0.41.7", "@expressive-code/plugin-text-markers": "^0.41.7" } }, "sha512-2wZjC8OQ3TaVEMcBtYY4Va3lo6J+Ai9jf3d4dbhURMJcU4Pbqe6EcHe424MIZI0VHUA1bR6xdpoHYi3yxokWqA=="],
|
"expressive-code": ["expressive-code@0.41.7", "", { "dependencies": { "@expressive-code/core": "^0.41.7", "@expressive-code/plugin-frames": "^0.41.7", "@expressive-code/plugin-shiki": "^0.41.7", "@expressive-code/plugin-text-markers": "^0.41.7" } }, "sha512-2wZjC8OQ3TaVEMcBtYY4Va3lo6J+Ai9jf3d4dbhURMJcU4Pbqe6EcHe424MIZI0VHUA1bR6xdpoHYi3yxokWqA=="],
|
||||||
|
|
||||||
"exsolve": ["exsolve@1.1.0", "", {}, "sha512-D+42+T12DdIlJM3uepa55qGiL3sYdLBOxIl2ifQCzCHz4c7eiolaHsi3BIqEr7JxBzxv2pYZQX9kw16ziMcEmw=="],
|
|
||||||
|
|
||||||
"ext-list": ["ext-list@2.2.2", "", { "dependencies": { "mime-db": "^1.28.0" } }, "sha512-u+SQgsubraE6zItfVA0tBuCBhfU9ogSRnsvygI7wht9TS510oLkBRXBsqopeUG/GBOIQyKZO9wjTqIu/sf5zFA=="],
|
"ext-list": ["ext-list@2.2.2", "", { "dependencies": { "mime-db": "^1.28.0" } }, "sha512-u+SQgsubraE6zItfVA0tBuCBhfU9ogSRnsvygI7wht9TS510oLkBRXBsqopeUG/GBOIQyKZO9wjTqIu/sf5zFA=="],
|
||||||
|
|
||||||
"ext-name": ["ext-name@5.0.0", "", { "dependencies": { "ext-list": "^2.0.0", "sort-keys-length": "^1.0.0" } }, "sha512-yblEwXAbGv1VQDmow7s38W77hzAgJAO50ztBLMcUyUBfxv1HC+LGwtiEN+Co6LtlqT/5uwVOxsD4TNIilWhwdQ=="],
|
"ext-name": ["ext-name@5.0.0", "", { "dependencies": { "ext-list": "^2.0.0", "sort-keys-length": "^1.0.0" } }, "sha512-yblEwXAbGv1VQDmow7s38W77hzAgJAO50ztBLMcUyUBfxv1HC+LGwtiEN+Co6LtlqT/5uwVOxsD4TNIilWhwdQ=="],
|
||||||
|
|
@ -4140,8 +4105,6 @@
|
||||||
|
|
||||||
"ghostty-web": ["ghostty-web@github:anomalyco/ghostty-web#83c0a07", {}, "anomalyco-ghostty-web-83c0a07", "sha512-Lf2v1agHkVUpMpHBWWuCZrhOEmcwwin5/Hboc9rZwQ7/CKkIh5rU1r1CvfLlhkMoFv+ed8z52RZ8hkzGZZj3MQ=="],
|
"ghostty-web": ["ghostty-web@github:anomalyco/ghostty-web#83c0a07", {}, "anomalyco-ghostty-web-83c0a07", "sha512-Lf2v1agHkVUpMpHBWWuCZrhOEmcwwin5/Hboc9rZwQ7/CKkIh5rU1r1CvfLlhkMoFv+ed8z52RZ8hkzGZZj3MQ=="],
|
||||||
|
|
||||||
"giget": ["giget@2.0.0", "", { "dependencies": { "citty": "^0.1.6", "consola": "^3.4.0", "defu": "^6.1.4", "node-fetch-native": "^1.6.6", "nypm": "^0.6.0", "pathe": "^2.0.3" }, "bin": { "giget": "dist/cli.mjs" } }, "sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA=="],
|
|
||||||
|
|
||||||
"github-slugger": ["github-slugger@2.0.0", "", {}, "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw=="],
|
"github-slugger": ["github-slugger@2.0.0", "", {}, "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw=="],
|
||||||
|
|
||||||
"gitlab-ai-provider": ["gitlab-ai-provider@6.11.1", "", { "dependencies": { "@anthropic-ai/sdk": "^0.71.0", "@anycable/core": "^0.9.2", "graphql-request": "^6.1.0", "isomorphic-ws": "^5.0.0", "openai": "^6.16.0", "socket.io-client": "^4.8.1", "vscode-jsonrpc": "^8.2.1", "zod": "^3.25.76" }, "peerDependencies": { "@ai-sdk/provider": ">=3.0.0", "@ai-sdk/provider-utils": ">=4.0.0" } }, "sha512-SJ6f5qa7P8md6lPrserryER3zerLkrezlnqqYQ2AbvDPpHLbwtbyk0FYJ5kNRcmbI80i/VMcsMBP0YIRdc3ucQ=="],
|
"gitlab-ai-provider": ["gitlab-ai-provider@6.11.1", "", { "dependencies": { "@anthropic-ai/sdk": "^0.71.0", "@anycable/core": "^0.9.2", "graphql-request": "^6.1.0", "isomorphic-ws": "^5.0.0", "openai": "^6.16.0", "socket.io-client": "^4.8.1", "vscode-jsonrpc": "^8.2.1", "zod": "^3.25.76" }, "peerDependencies": { "@ai-sdk/provider": ">=3.0.0", "@ai-sdk/provider-utils": ">=4.0.0" } }, "sha512-SJ6f5qa7P8md6lPrserryER3zerLkrezlnqqYQ2AbvDPpHLbwtbyk0FYJ5kNRcmbI80i/VMcsMBP0YIRdc3ucQ=="],
|
||||||
|
|
@ -4374,8 +4337,6 @@
|
||||||
|
|
||||||
"is-hexadecimal": ["is-hexadecimal@2.0.1", "", {}, "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg=="],
|
"is-hexadecimal": ["is-hexadecimal@2.0.1", "", {}, "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg=="],
|
||||||
|
|
||||||
"is-in-ssh": ["is-in-ssh@1.0.0", "", {}, "sha512-jYa6Q9rH90kR1vKB6NM7qqd1mge3Fx4Dhw5TVlK1MUBqhEOuCagrEHMevNuCcbECmXZ0ThXkRm+Ymr51HwEPAw=="],
|
|
||||||
|
|
||||||
"is-inside-container": ["is-inside-container@1.0.0", "", { "dependencies": { "is-docker": "^3.0.0" }, "bin": { "is-inside-container": "cli.js" } }, "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA=="],
|
"is-inside-container": ["is-inside-container@1.0.0", "", { "dependencies": { "is-docker": "^3.0.0" }, "bin": { "is-inside-container": "cli.js" } }, "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA=="],
|
||||||
|
|
||||||
"is-map": ["is-map@2.0.3", "", {}, "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw=="],
|
"is-map": ["is-map@2.0.3", "", {}, "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw=="],
|
||||||
|
|
@ -4886,8 +4847,6 @@
|
||||||
|
|
||||||
"nth-check": ["nth-check@2.1.1", "", { "dependencies": { "boolbase": "^1.0.0" } }, "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w=="],
|
"nth-check": ["nth-check@2.1.1", "", { "dependencies": { "boolbase": "^1.0.0" } }, "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w=="],
|
||||||
|
|
||||||
"nypm": ["nypm@0.6.8", "", { "dependencies": { "citty": "^0.2.2", "pathe": "^2.0.3", "tinyexec": "^1.2.4" }, "bin": { "nypm": "./dist/cli.mjs" } }, "sha512-Q9K4Diu6l5u6xJQogeFSs/zKtyMSgFKFtRQV+tHP4kL7KPm2grpBU0dFIwFaXwNxN0MtfKWc43VpCugAa+LPsw=="],
|
|
||||||
|
|
||||||
"object-assign": ["object-assign@4.1.1", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="],
|
"object-assign": ["object-assign@4.1.1", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="],
|
||||||
|
|
||||||
"object-hash": ["object-hash@2.2.0", "", {}, "sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw=="],
|
"object-hash": ["object-hash@2.2.0", "", {}, "sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw=="],
|
||||||
|
|
@ -5024,8 +4983,6 @@
|
||||||
|
|
||||||
"pend": ["pend@1.2.0", "", {}, "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg=="],
|
"pend": ["pend@1.2.0", "", {}, "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg=="],
|
||||||
|
|
||||||
"perfect-debounce": ["perfect-debounce@2.1.0", "", {}, "sha512-LjgdTytVFXeUgtHZr9WYViYSM/g8MkcTPYDlPa3cDqMirHjKiSZPYd6DoL7pK8AJQr+uWkQvCjHNdiMqsrJs+g=="],
|
|
||||||
|
|
||||||
"piccolore": ["piccolore@0.1.3", "", {}, "sha512-o8bTeDWjE086iwKrROaDf31K0qC/BENdm15/uH9usSC/uZjJOKb2YGiVHfLY4GhwsERiPI1jmwI2XrA7ACOxVw=="],
|
"piccolore": ["piccolore@0.1.3", "", {}, "sha512-o8bTeDWjE086iwKrROaDf31K0qC/BENdm15/uH9usSC/uZjJOKb2YGiVHfLY4GhwsERiPI1jmwI2XrA7ACOxVw=="],
|
||||||
|
|
||||||
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
||||||
|
|
@ -5040,8 +4997,6 @@
|
||||||
|
|
||||||
"pkg-dir": ["pkg-dir@4.2.0", "", { "dependencies": { "find-up": "^4.0.0" } }, "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ=="],
|
"pkg-dir": ["pkg-dir@4.2.0", "", { "dependencies": { "find-up": "^4.0.0" } }, "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ=="],
|
||||||
|
|
||||||
"pkg-types": ["pkg-types@2.3.1", "", { "dependencies": { "confbox": "^0.2.4", "exsolve": "^1.0.8", "pathe": "^2.0.3" } }, "sha512-y+ichcgc2LrADuhLNAx8DFjVfgz91pRxfZdI3UDhxHvcVEZsenLO+7XaU5vOp0u/7V/wZ+plyuQxtrDlZJ+yeg=="],
|
|
||||||
|
|
||||||
"pkg-up": ["pkg-up@3.1.0", "", { "dependencies": { "find-up": "^3.0.0" } }, "sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA=="],
|
"pkg-up": ["pkg-up@3.1.0", "", { "dependencies": { "find-up": "^3.0.0" } }, "sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA=="],
|
||||||
|
|
||||||
"pkijs": ["pkijs@3.4.0", "", { "dependencies": { "@noble/hashes": "1.4.0", "asn1js": "^3.0.6", "bytestreamjs": "^2.0.1", "pvtsutils": "^1.3.6", "pvutils": "^1.1.3", "tslib": "^2.8.1" } }, "sha512-emEcLuomt2j03vxD54giVB4SxTjnsqkU692xZOZXHDVoYyypEm+b3jpiTcc+Cf+myooc+/Ly0z01jqeNHVgJGw=="],
|
"pkijs": ["pkijs@3.4.0", "", { "dependencies": { "@noble/hashes": "1.4.0", "asn1js": "^3.0.6", "bytestreamjs": "^2.0.1", "pvtsutils": "^1.3.6", "pvutils": "^1.1.3", "tslib": "^2.8.1" } }, "sha512-emEcLuomt2j03vxD54giVB4SxTjnsqkU692xZOZXHDVoYyypEm+b3jpiTcc+Cf+myooc+/Ly0z01jqeNHVgJGw=="],
|
||||||
|
|
@ -5078,8 +5033,6 @@
|
||||||
|
|
||||||
"postject": ["postject@1.0.0-alpha.6", "", { "dependencies": { "commander": "^9.4.0" }, "bin": { "postject": "dist/cli.js" } }, "sha512-b9Eb8h2eVqNE8edvKdwqkrY6O7kAwmI8kcnBv1NScolYJbo59XUF0noFq+lxbC1yN20bmC0WBEbDC5H/7ASb0A=="],
|
"postject": ["postject@1.0.0-alpha.6", "", { "dependencies": { "commander": "^9.4.0" }, "bin": { "postject": "dist/cli.js" } }, "sha512-b9Eb8h2eVqNE8edvKdwqkrY6O7kAwmI8kcnBv1NScolYJbo59XUF0noFq+lxbC1yN20bmC0WBEbDC5H/7ASb0A=="],
|
||||||
|
|
||||||
"powershell-utils": ["powershell-utils@0.1.0", "", {}, "sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A=="],
|
|
||||||
|
|
||||||
"preact": ["preact@11.0.0-beta.0", "", {}, "sha512-IcODoASASYwJ9kxz7+MJeiJhvLriwSb4y4mHIyxdgaRZp6kPUud7xytrk/6GZw8U3y6EFJaRb5wi9SrEK+8+lg=="],
|
"preact": ["preact@11.0.0-beta.0", "", {}, "sha512-IcODoASASYwJ9kxz7+MJeiJhvLriwSb4y4mHIyxdgaRZp6kPUud7xytrk/6GZw8U3y6EFJaRb5wi9SrEK+8+lg=="],
|
||||||
|
|
||||||
"preact-render-to-string": ["preact-render-to-string@6.6.5", "", { "peerDependencies": { "preact": ">=10 || >= 11.0.0-0" } }, "sha512-O6MHzYNIKYaiSX3bOw0gGZfEbOmlIDtDfWwN1JJdc/T3ihzRT6tGGSEWE088dWrEDGa1u7101q+6fzQnO9XCPA=="],
|
"preact-render-to-string": ["preact-render-to-string@6.6.5", "", { "peerDependencies": { "preact": ">=10 || >= 11.0.0-0" } }, "sha512-O6MHzYNIKYaiSX3bOw0gGZfEbOmlIDtDfWwN1JJdc/T3ihzRT6tGGSEWE088dWrEDGa1u7101q+6fzQnO9XCPA=="],
|
||||||
|
|
@ -5152,8 +5105,6 @@
|
||||||
|
|
||||||
"raw-body": ["raw-body@3.0.2", "", { "dependencies": { "bytes": "~3.1.2", "http-errors": "~2.0.1", "iconv-lite": "~0.7.0", "unpipe": "~1.0.0" } }, "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA=="],
|
"raw-body": ["raw-body@3.0.2", "", { "dependencies": { "bytes": "~3.1.2", "http-errors": "~2.0.1", "iconv-lite": "~0.7.0", "unpipe": "~1.0.0" } }, "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA=="],
|
||||||
|
|
||||||
"rc9": ["rc9@2.1.2", "", { "dependencies": { "defu": "^6.1.4", "destr": "^2.0.3" } }, "sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg=="],
|
|
||||||
|
|
||||||
"react": ["react@18.2.0", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ=="],
|
"react": ["react@18.2.0", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ=="],
|
||||||
|
|
||||||
"react-dom": ["react-dom@18.2.0", "", { "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.0" }, "peerDependencies": { "react": "^18.2.0" } }, "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g=="],
|
"react-dom": ["react-dom@18.2.0", "", { "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.0" }, "peerDependencies": { "react": "^18.2.0" } }, "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g=="],
|
||||||
|
|
@ -5876,7 +5827,7 @@
|
||||||
|
|
||||||
"ws": ["ws@8.21.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g=="],
|
"ws": ["ws@8.21.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g=="],
|
||||||
|
|
||||||
"wsl-utils": ["wsl-utils@0.3.1", "", { "dependencies": { "is-wsl": "^3.1.0", "powershell-utils": "^0.1.0" } }, "sha512-g/eziiSUNBSsdDJtCLB8bdYEUMj4jR7AGeUo96p/3dTafgjHhpF4RiCFPiRILwjQoDXx5MqkBr4fwWtR3Ky4Wg=="],
|
"wsl-utils": ["wsl-utils@0.1.0", "", { "dependencies": { "is-wsl": "^3.1.0" } }, "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw=="],
|
||||||
|
|
||||||
"xdg-app-paths": ["xdg-app-paths@5.5.1", "", { "dependencies": { "os-paths": "^4.0.1", "xdg-portable": "^7.2.0" } }, "sha512-hI3flOB4PLZIy5prbtTpirobtPE2ZtZ52szO+2mM9Efp6ErM398La+C1lIpNWDfNoQk+6Lsi6nMcCwVB7pxeMQ=="],
|
"xdg-app-paths": ["xdg-app-paths@5.5.1", "", { "dependencies": { "os-paths": "^4.0.1", "xdg-portable": "^7.2.0" } }, "sha512-hI3flOB4PLZIy5prbtTpirobtPE2ZtZ52szO+2mM9Efp6ErM398La+C1lIpNWDfNoQk+6Lsi6nMcCwVB7pxeMQ=="],
|
||||||
|
|
||||||
|
|
@ -6224,12 +6175,6 @@
|
||||||
|
|
||||||
"@expressive-code/plugin-shiki/shiki": ["shiki@3.23.0", "", { "dependencies": { "@shikijs/core": "3.23.0", "@shikijs/engine-javascript": "3.23.0", "@shikijs/engine-oniguruma": "3.23.0", "@shikijs/langs": "3.23.0", "@shikijs/themes": "3.23.0", "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-55Dj73uq9ZXL5zyeRPzHQsK7Nbyt6Y10k5s7OjuFZGMhpp4r/rsLBH0o/0fstIzX1Lep9VxefWljK/SKCzygIA=="],
|
"@expressive-code/plugin-shiki/shiki": ["shiki@3.23.0", "", { "dependencies": { "@shikijs/core": "3.23.0", "@shikijs/engine-javascript": "3.23.0", "@shikijs/engine-oniguruma": "3.23.0", "@shikijs/langs": "3.23.0", "@shikijs/themes": "3.23.0", "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-55Dj73uq9ZXL5zyeRPzHQsK7Nbyt6Y10k5s7OjuFZGMhpp4r/rsLBH0o/0fstIzX1Lep9VxefWljK/SKCzygIA=="],
|
||||||
|
|
||||||
"@hey-api/json-schema-ref-parser/js-yaml": ["js-yaml@4.3.0", "", { "dependencies": { "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q=="],
|
|
||||||
|
|
||||||
"@hey-api/openapi-ts/open": ["open@11.0.0", "", { "dependencies": { "default-browser": "^5.4.0", "define-lazy-prop": "^3.0.0", "is-in-ssh": "^1.0.0", "is-inside-container": "^1.0.0", "powershell-utils": "^0.1.0", "wsl-utils": "^0.3.0" } }, "sha512-smsWv2LzFjP03xmvFoJ331ss6h+jixfA4UUV/Bsiyuu4YJPfN+FIQGOIiv4w9/+MoHkfkJ22UIaQWRVFRfH6Vw=="],
|
|
||||||
|
|
||||||
"@hey-api/openapi-ts/semver": ["semver@7.7.3", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q=="],
|
|
||||||
|
|
||||||
"@img/sharp-wasm32/@emnapi/runtime": ["@emnapi/runtime@1.11.2", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-kyOl3X0DuTiT1h2ft8r2fYO8JYtU9a9Xis/zBSiGArNaagCOWx90N1k2wxp18czFDH+OgcWGb5ZP/XMt3dcyPA=="],
|
"@img/sharp-wasm32/@emnapi/runtime": ["@emnapi/runtime@1.11.2", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-kyOl3X0DuTiT1h2ft8r2fYO8JYtU9a9Xis/zBSiGArNaagCOWx90N1k2wxp18czFDH+OgcWGb5ZP/XMt3dcyPA=="],
|
||||||
|
|
||||||
"@jsx-email/cli/chalk": ["chalk@4.1.2", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="],
|
"@jsx-email/cli/chalk": ["chalk@4.1.2", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="],
|
||||||
|
|
@ -6604,10 +6549,6 @@
|
||||||
|
|
||||||
"builder-util/js-yaml": ["js-yaml@4.3.0", "", { "dependencies": { "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q=="],
|
"builder-util/js-yaml": ["js-yaml@4.3.0", "", { "dependencies": { "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q=="],
|
||||||
|
|
||||||
"c12/chokidar": ["chokidar@5.0.0", "", { "dependencies": { "readdirp": "^5.0.0" } }, "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw=="],
|
|
||||||
|
|
||||||
"c12/dotenv": ["dotenv@17.4.2", "", {}, "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw=="],
|
|
||||||
|
|
||||||
"cliui/string-width": ["string-width@4.2.3", "", { "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="],
|
"cliui/string-width": ["string-width@4.2.3", "", { "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="],
|
||||||
|
|
||||||
"cliui/strip-ansi": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="],
|
"cliui/strip-ansi": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="],
|
||||||
|
|
@ -6724,8 +6665,6 @@
|
||||||
|
|
||||||
"jszip/readable-stream": ["readable-stream@2.3.8", "", { "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", "process-nextick-args": "~2.0.0", "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" } }, "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA=="],
|
"jszip/readable-stream": ["readable-stream@2.3.8", "", { "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", "process-nextick-args": "~2.0.0", "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" } }, "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA=="],
|
||||||
|
|
||||||
"katex/commander": ["commander@8.3.0", "", {}, "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww=="],
|
|
||||||
|
|
||||||
"lazystream/readable-stream": ["readable-stream@2.3.8", "", { "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", "process-nextick-args": "~2.0.0", "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" } }, "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA=="],
|
"lazystream/readable-stream": ["readable-stream@2.3.8", "", { "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", "process-nextick-args": "~2.0.0", "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" } }, "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA=="],
|
||||||
|
|
||||||
"matcher/escape-string-regexp": ["escape-string-regexp@4.0.0", "", {}, "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="],
|
"matcher/escape-string-regexp": ["escape-string-regexp@4.0.0", "", {}, "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="],
|
||||||
|
|
@ -6764,10 +6703,6 @@
|
||||||
|
|
||||||
"npm-run-path/path-key": ["path-key@4.0.0", "", {}, "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ=="],
|
"npm-run-path/path-key": ["path-key@4.0.0", "", {}, "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ=="],
|
||||||
|
|
||||||
"nypm/citty": ["citty@0.2.2", "", {}, "sha512-+6vJA3L98yv+IdfKGZHBNiGW5KHn22e/JwID0Strsz8h4S/csAu/OuICwxrg44k5MRiZHWIo8XXuJgQTriRP4w=="],
|
|
||||||
|
|
||||||
"nypm/tinyexec": ["tinyexec@1.2.4", "", {}, "sha512-SHf/r48b7vOrjve9PxJo3MN5v5yuyjHvdUcrQffT3WXMUfnGmHDVbC4k3sHJaJTgZCwpUplIaAo5ANtMyp3YHg=="],
|
|
||||||
|
|
||||||
"openid-client/jose": ["jose@4.15.9", "", {}, "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA=="],
|
"openid-client/jose": ["jose@4.15.9", "", {}, "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA=="],
|
||||||
|
|
||||||
"openid-client/lru-cache": ["lru-cache@6.0.0", "", { "dependencies": { "yallist": "^4.0.0" } }, "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA=="],
|
"openid-client/lru-cache": ["lru-cache@6.0.0", "", { "dependencies": { "yallist": "^4.0.0" } }, "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA=="],
|
||||||
|
|
@ -7222,8 +7157,6 @@
|
||||||
|
|
||||||
"@expressive-code/plugin-shiki/shiki/@shikijs/types": ["@shikijs/types@3.23.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-3JZ5HXOZfYjsYSk0yPwBrkupyYSLpAE26Qc0HLghhZNGTZg/SKxXIIgoxOpmmeQP0RRSDJTk1/vPfw9tbw+jSQ=="],
|
"@expressive-code/plugin-shiki/shiki/@shikijs/types": ["@shikijs/types@3.23.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-3JZ5HXOZfYjsYSk0yPwBrkupyYSLpAE26Qc0HLghhZNGTZg/SKxXIIgoxOpmmeQP0RRSDJTk1/vPfw9tbw+jSQ=="],
|
||||||
|
|
||||||
"@hey-api/json-schema-ref-parser/js-yaml/argparse": ["argparse@2.0.1", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
|
|
||||||
|
|
||||||
"@jsx-email/cli/esbuild/@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.19.12", "", { "os": "aix", "cpu": "ppc64" }, "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA=="],
|
"@jsx-email/cli/esbuild/@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.19.12", "", { "os": "aix", "cpu": "ppc64" }, "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA=="],
|
||||||
|
|
||||||
"@jsx-email/cli/esbuild/@esbuild/android-arm": ["@esbuild/android-arm@0.19.12", "", { "os": "android", "cpu": "arm" }, "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w=="],
|
"@jsx-email/cli/esbuild/@esbuild/android-arm": ["@esbuild/android-arm@0.19.12", "", { "os": "android", "cpu": "arm" }, "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w=="],
|
||||||
|
|
@ -7714,8 +7647,6 @@
|
||||||
|
|
||||||
"blume/js-yaml/argparse": ["argparse@2.0.1", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
|
"blume/js-yaml/argparse": ["argparse@2.0.1", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
|
||||||
|
|
||||||
"blume/katex/commander": ["commander@8.3.0", "", {}, "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww=="],
|
|
||||||
|
|
||||||
"blume/node-html-parser/entities": ["entities@8.0.0", "", {}, "sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA=="],
|
"blume/node-html-parser/entities": ["entities@8.0.0", "", {}, "sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA=="],
|
||||||
|
|
||||||
"blume/react-dom/scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
|
"blume/react-dom/scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
|
||||||
|
|
@ -7734,8 +7665,6 @@
|
||||||
|
|
||||||
"builder-util/js-yaml/argparse": ["argparse@2.0.1", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
|
"builder-util/js-yaml/argparse": ["argparse@2.0.1", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
|
||||||
|
|
||||||
"c12/chokidar/readdirp": ["readdirp@5.0.0", "", {}, "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ=="],
|
|
||||||
|
|
||||||
"cliui/string-width/emoji-regex": ["emoji-regex@8.0.0", "", {}, "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="],
|
"cliui/string-width/emoji-regex": ["emoji-regex@8.0.0", "", {}, "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="],
|
||||||
|
|
||||||
"cliui/strip-ansi/ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
|
"cliui/strip-ansi/ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
|
||||||
|
|
@ -7802,8 +7731,6 @@
|
||||||
|
|
||||||
"lazystream/readable-stream/string_decoder": ["string_decoder@1.1.1", "", { "dependencies": { "safe-buffer": "~5.1.0" } }, "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg=="],
|
"lazystream/readable-stream/string_decoder": ["string_decoder@1.1.1", "", { "dependencies": { "safe-buffer": "~5.1.0" } }, "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg=="],
|
||||||
|
|
||||||
"mermaid/katex/commander": ["commander@8.3.0", "", {}, "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww=="],
|
|
||||||
|
|
||||||
"motion/framer-motion/motion-dom": ["motion-dom@12.42.2", "", { "dependencies": { "motion-utils": "^12.39.0" } }, "sha512-5gIMWLp/PycBtJRJWRgjxke5n8dlvkSn2DrYW+tr3XcqAZY1xZh6BJyooJXCM8wdfM7wfMjkBJNLge1CKPUIRA=="],
|
"motion/framer-motion/motion-dom": ["motion-dom@12.42.2", "", { "dependencies": { "motion-utils": "^12.39.0" } }, "sha512-5gIMWLp/PycBtJRJWRgjxke5n8dlvkSn2DrYW+tr3XcqAZY1xZh6BJyooJXCM8wdfM7wfMjkBJNLge1CKPUIRA=="],
|
||||||
|
|
||||||
"motion/framer-motion/motion-utils": ["motion-utils@12.39.0", "", {}, "sha512-8nadJAJjTtqRkmRF36FoJTrywK9nnFmnPwnSMyxaOCU7GDjN9RTMJIxx9De8ErM+vpPhMccr/6fo5WciyQLnMQ=="],
|
"motion/framer-motion/motion-utils": ["motion-utils@12.39.0", "", {}, "sha512-8nadJAJjTtqRkmRF36FoJTrywK9nnFmnPwnSMyxaOCU7GDjN9RTMJIxx9De8ErM+vpPhMccr/6fo5WciyQLnMQ=="],
|
||||||
|
|
@ -7822,8 +7749,6 @@
|
||||||
|
|
||||||
"rimraf/glob/path-scurry": ["path-scurry@1.11.1", "", { "dependencies": { "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" } }, "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA=="],
|
"rimraf/glob/path-scurry": ["path-scurry@1.11.1", "", { "dependencies": { "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" } }, "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA=="],
|
||||||
|
|
||||||
"storybook/open/wsl-utils": ["wsl-utils@0.1.0", "", { "dependencies": { "is-wsl": "^3.1.0" } }, "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw=="],
|
|
||||||
|
|
||||||
"string-width-cjs/strip-ansi/ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
|
"string-width-cjs/strip-ansi/ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
|
||||||
|
|
||||||
"temp/rimraf/glob": ["glob@7.2.3", "", { "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q=="],
|
"temp/rimraf/glob": ["glob@7.2.3", "", { "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q=="],
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
exact = true
|
exact = true
|
||||||
# Only install newly resolved package versions published at least 3 days ago.
|
# Only install newly resolved package versions published at least 3 days ago.
|
||||||
minimumReleaseAge = 259200
|
minimumReleaseAge = 259200
|
||||||
minimumReleaseAgeExcludes = ["@ai-sdk/amazon-bedrock", "@ai-sdk/anthropic", "@opentui/core", "@opentui/core-darwin-arm64", "@opentui/core-darwin-x64", "@opentui/core-linux-arm64", "@opentui/core-linux-arm64-musl", "@opentui/core-linux-x64", "@opentui/core-linux-x64-musl", "@opentui/core-win32-arm64", "@opentui/core-win32-x64", "@opentui/keymap", "@opentui/solid", "opentui-spinner", "gitlab-ai-provider", "opencode-gitlab-auth", "@ff-labs/fff-node", "@ff-labs/fff-bun", "@ff-labs/fff-bin-darwin-arm64", "@ff-labs/fff-bin-darwin-x64", "@ff-labs/fff-bin-linux-arm64-gnu", "@ff-labs/fff-bin-linux-arm64-musl", "@ff-labs/fff-bin-linux-x64-gnu", "@ff-labs/fff-bin-linux-x64-musl", "@ff-labs/fff-bin-win32-arm64", "@ff-labs/fff-bin-win32-x64", "@pierre/diffs", "@pierre/theming", "app-builder-lib", "dmg-builder", "electron-builder", "electron-publish"]
|
minimumReleaseAgeExcludes = ["@ai-sdk/amazon-bedrock", "@ai-sdk/anthropic", "@opencode-ai/sdk", "@opentui/core", "@opentui/core-darwin-arm64", "@opentui/core-darwin-x64", "@opentui/core-linux-arm64", "@opentui/core-linux-arm64-musl", "@opentui/core-linux-x64", "@opentui/core-linux-x64-musl", "@opentui/core-win32-arm64", "@opentui/core-win32-x64", "@opentui/keymap", "@opentui/solid", "opentui-spinner", "gitlab-ai-provider", "opencode-gitlab-auth", "@ff-labs/fff-node", "@ff-labs/fff-bun", "@ff-labs/fff-bin-darwin-arm64", "@ff-labs/fff-bin-darwin-x64", "@ff-labs/fff-bin-linux-arm64-gnu", "@ff-labs/fff-bin-linux-arm64-musl", "@ff-labs/fff-bin-linux-x64-gnu", "@ff-labs/fff-bin-linux-x64-musl", "@ff-labs/fff-bin-win32-arm64", "@ff-labs/fff-bin-win32-x64", "@pierre/diffs", "@pierre/theming", "app-builder-lib", "dmg-builder", "electron-builder", "electron-publish"]
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
root = "./do-not-run-tests-from-root"
|
root = "./do-not-run-tests-from-root"
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,6 @@
|
||||||
"@actions/github": "6.0.1",
|
"@actions/github": "6.0.1",
|
||||||
"@octokit/graphql": "9.0.1",
|
"@octokit/graphql": "9.0.1",
|
||||||
"@octokit/rest": "catalog:",
|
"@octokit/rest": "catalog:",
|
||||||
"@opencode-ai/sdk": "workspace:*"
|
"@opencode-ai/sdk": "1.18.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@
|
||||||
"packages/*",
|
"packages/*",
|
||||||
"packages/console/*",
|
"packages/console/*",
|
||||||
"packages/stats/*",
|
"packages/stats/*",
|
||||||
"packages/sdk/js",
|
|
||||||
"packages/slack"
|
"packages/slack"
|
||||||
],
|
],
|
||||||
"catalog": {
|
"catalog": {
|
||||||
|
|
@ -124,7 +123,7 @@
|
||||||
"@aws-sdk/client-s3": "3.933.0",
|
"@aws-sdk/client-s3": "3.933.0",
|
||||||
"@opencode-ai/plugin": "workspace:*",
|
"@opencode-ai/plugin": "workspace:*",
|
||||||
"@opencode-ai/script": "workspace:*",
|
"@opencode-ai/script": "workspace:*",
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "1.18.5",
|
||||||
"heap-snapshot-toolkit": "1.1.3",
|
"heap-snapshot-toolkit": "1.1.3",
|
||||||
"typescript": "catalog:"
|
"typescript": "catalog:"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
"@opencode-ai/client": "file:vendor/opencode-ai-client-1.17.13.tgz",
|
"@opencode-ai/client": "file:vendor/opencode-ai-client-1.17.13.tgz",
|
||||||
"@opencode-ai/core": "workspace:*",
|
"@opencode-ai/core": "workspace:*",
|
||||||
"@opencode-ai/schema": "workspace:*",
|
"@opencode-ai/schema": "workspace:*",
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "1.18.5",
|
||||||
"@opencode-ai/session-ui": "workspace:*",
|
"@opencode-ai/session-ui": "workspace:*",
|
||||||
"@opencode-ai/ui": "workspace:*",
|
"@opencode-ai/ui": "workspace:*",
|
||||||
"@pierre/trees": "1.0.0-beta.4",
|
"@pierre/trees": "1.0.0-beta.4",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"https://raw.githubusercontent.com/anomalyco/opencode/refs/heads/dev/packages/sdk/openapi.json",
|
"https://raw.githubusercontent.com/anomalyco/opencode/refs/heads/dev/packages/protocol/openapi.json",
|
||||||
)
|
)
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
return json
|
return json
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
"@opencode-ai/ai": "workspace:*",
|
"@opencode-ai/ai": "workspace:*",
|
||||||
"@opencode-ai/client": "workspace:*",
|
"@opencode-ai/client": "workspace:*",
|
||||||
"@opencode-ai/schema": "workspace:*",
|
"@opencode-ai/schema": "workspace:*",
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "1.18.5",
|
||||||
"@standard-schema/spec": "^1.1.0",
|
"@standard-schema/spec": "^1.1.0",
|
||||||
"effect": "catalog:",
|
"effect": "catalog:",
|
||||||
"zod": "catalog:"
|
"zod": "catalog:"
|
||||||
|
|
|
||||||
29592
packages/protocol/openapi.json
Normal file
29592
packages/protocol/openapi.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -20,6 +20,8 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "bun run script/build.ts",
|
"build": "bun run script/build.ts",
|
||||||
|
"generate": "bun run script/generate-openapi.ts",
|
||||||
|
"check:generated": "bun run script/generate-openapi.ts --check",
|
||||||
"typecheck": "tsgo --noEmit"
|
"typecheck": "tsgo --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
16
packages/protocol/script/generate-openapi.ts
Normal file
16
packages/protocol/script/generate-openapi.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { OpenApi } from "effect/unstable/httpapi"
|
||||||
|
import { fileURLToPath } from "url"
|
||||||
|
import { ClientApi } from "../src/client.js"
|
||||||
|
|
||||||
|
const document = JSON.stringify(OpenApi.fromApi(ClientApi), null, 2) + "\n"
|
||||||
|
const target = fileURLToPath(new URL("../openapi.json", import.meta.url))
|
||||||
|
|
||||||
|
if (process.argv.includes("--check")) {
|
||||||
|
if ((await Bun.file(target).text()) !== document) {
|
||||||
|
console.error("Generated OpenAPI document is stale. Run `bun run generate` from packages/protocol.")
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
await Bun.write(target, document)
|
||||||
10
packages/sdk/.gitignore
vendored
10
packages/sdk/.gitignore
vendored
|
|
@ -1,10 +0,0 @@
|
||||||
.prism.log
|
|
||||||
node_modules
|
|
||||||
yarn-error.log
|
|
||||||
codegen.log
|
|
||||||
Brewfile.lock.json
|
|
||||||
dist
|
|
||||||
dist-deno
|
|
||||||
/*.tgz
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
import { createOpencodeClient, createOpencodeServer } from "@opencode-ai/sdk"
|
|
||||||
import { pathToFileURL } from "bun"
|
|
||||||
|
|
||||||
const server = await createOpencodeServer()
|
|
||||||
const client = createOpencodeClient({ baseUrl: server.url })
|
|
||||||
|
|
||||||
const input = await Array.fromAsync(new Bun.Glob("packages/core/*.ts").scan())
|
|
||||||
|
|
||||||
const tasks: Promise<void>[] = []
|
|
||||||
for await (const file of input) {
|
|
||||||
console.log("processing", file)
|
|
||||||
const session = await client.session.create()
|
|
||||||
tasks.push(
|
|
||||||
client.session.prompt({
|
|
||||||
path: { id: session.data.id },
|
|
||||||
body: {
|
|
||||||
parts: [
|
|
||||||
{
|
|
||||||
type: "file",
|
|
||||||
mime: "text/plain",
|
|
||||||
url: pathToFileURL(file).href,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "text",
|
|
||||||
text: `Write tests for every public function in this file.`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
console.log("done", file)
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(
|
|
||||||
input.map(async (file) => {
|
|
||||||
const session = await client.session.create()
|
|
||||||
console.log("processing", file)
|
|
||||||
await client.session.prompt({
|
|
||||||
path: { id: session.data.id },
|
|
||||||
body: {
|
|
||||||
parts: [
|
|
||||||
{
|
|
||||||
type: "file",
|
|
||||||
mime: "text/plain",
|
|
||||||
url: pathToFileURL(file).href,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "text",
|
|
||||||
text: `Write tests for every public function in this file.`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
console.log("done", file)
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/package.json",
|
|
||||||
"name": "@opencode-ai/sdk",
|
|
||||||
"version": "1.18.4",
|
|
||||||
"type": "module",
|
|
||||||
"license": "MIT",
|
|
||||||
"scripts": {
|
|
||||||
"test": "bun test",
|
|
||||||
"typecheck": "tsgo --noEmit"
|
|
||||||
},
|
|
||||||
"exports": {
|
|
||||||
".": "./src/index.ts",
|
|
||||||
"./client": "./src/client.ts",
|
|
||||||
"./server": "./src/server.ts",
|
|
||||||
"./v2": "./src/v2/index.ts",
|
|
||||||
"./v2/client": "./src/v2/client.ts",
|
|
||||||
"./v2/gen/client": "./src/v2/gen/client/index.ts",
|
|
||||||
"./v2/server": "./src/v2/server.ts",
|
|
||||||
"./v2/types": "./src/v2/gen/types.gen.ts"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist"
|
|
||||||
],
|
|
||||||
"devDependencies": {
|
|
||||||
"@hey-api/openapi-ts": "0.90.10",
|
|
||||||
"@tsconfig/node22": "catalog:",
|
|
||||||
"@types/cross-spawn": "catalog:",
|
|
||||||
"@types/node": "catalog:",
|
|
||||||
"@typescript/native-preview": "catalog:",
|
|
||||||
"typescript": "catalog:"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"cross-spawn": "catalog:"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,424 +0,0 @@
|
||||||
#!/usr/bin/env bun
|
|
||||||
import { fileURLToPath } from "url"
|
|
||||||
|
|
||||||
const dir = fileURLToPath(new URL("..", import.meta.url))
|
|
||||||
process.chdir(dir)
|
|
||||||
|
|
||||||
import { $ } from "bun"
|
|
||||||
import path from "path"
|
|
||||||
|
|
||||||
import { createClient } from "@hey-api/openapi-ts"
|
|
||||||
|
|
||||||
const opencode = path.resolve(dir, "../../opencode")
|
|
||||||
const client = path.resolve(dir, "../../client")
|
|
||||||
|
|
||||||
if (!(await Bun.file(path.join(opencode, "package.json")).exists())) {
|
|
||||||
await $`rm -rf dist`
|
|
||||||
await $`bun tsc`
|
|
||||||
process.exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
await $`bun dev generate > ${dir}/openapi.json`.cwd(opencode)
|
|
||||||
await $`bun -e ${`
|
|
||||||
import { OpenApi } from "effect/unstable/httpapi"
|
|
||||||
import { ClientApi } from "@opencode-ai/protocol/client"
|
|
||||||
|
|
||||||
const output = process.argv.at(-1)
|
|
||||||
if (!output) throw new Error("Missing OpenAPI output path")
|
|
||||||
await Bun.write(output, JSON.stringify(OpenApi.fromApi(ClientApi)))
|
|
||||||
`} ${path.join(dir, "openapi-v2.json")}`.cwd(client)
|
|
||||||
|
|
||||||
type OpenApiDocument = {
|
|
||||||
components?: { schemas?: Record<string, unknown> }
|
|
||||||
paths?: Record<string, unknown>
|
|
||||||
[key: string]: unknown
|
|
||||||
}
|
|
||||||
|
|
||||||
const document = (await Bun.file("./openapi.json").json()) as OpenApiDocument
|
|
||||||
const v2Document = (await Bun.file("./openapi-v2.json").json()) as OpenApiDocument
|
|
||||||
normalizeComponentNames(v2Document)
|
|
||||||
deduplicateEquivalentComponent(v2Document, "Shell", "Shell1")
|
|
||||||
renameCollidingComponents(document, v2Document)
|
|
||||||
document.paths = { ...document.paths, ...v2Document.paths }
|
|
||||||
document.components = {
|
|
||||||
...document.components,
|
|
||||||
schemas: { ...document.components?.schemas, ...v2Document.components?.schemas },
|
|
||||||
}
|
|
||||||
inlineTypedAllOfConstraints(document)
|
|
||||||
const schemas = document.components?.schemas
|
|
||||||
if (schemas) {
|
|
||||||
const reachable = new Set<string>()
|
|
||||||
const visit = (value: unknown) => {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
value.forEach(visit)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (typeof value !== "object" || value === null) return
|
|
||||||
for (const [key, child] of Object.entries(value)) {
|
|
||||||
if (key === "$ref" && typeof child === "string" && child.startsWith("#/components/schemas/")) {
|
|
||||||
const name = child.slice("#/components/schemas/".length)
|
|
||||||
if (reachable.has(name)) continue
|
|
||||||
reachable.add(name)
|
|
||||||
visit(schemas[name])
|
|
||||||
} else {
|
|
||||||
visit(child)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
visit({ ...document, components: { ...document.components, schemas: undefined } })
|
|
||||||
for (const name of Object.keys(schemas)) {
|
|
||||||
if (
|
|
||||||
/^(SessionAgentSelected|SessionModelSelected|SessionMoved|SessionRenamed|SessionForked|SessionInputPromoted|SessionInputAdmitted|SessionExecutionStarted|SessionExecutionSucceeded|SessionExecutionFailed|SessionExecutionInterrupted|SessionInstructionsUpdated|SessionSynthetic|SessionSkillActivated|SessionShellStarted|SessionShellEnded|SessionStepStarted|SessionStepEnded|SessionStepFailed|SessionTextStarted|SessionTextDelta|SessionTextEnded|SessionToolInputStarted|SessionToolInputDelta|SessionToolInputEnded|SessionToolCalled|SessionToolProgress|SessionToolSuccess|SessionToolFailed|SessionRetryScheduled|SessionCompactionStarted|SessionCompactionDelta|SessionCompactionEnded|SessionRevertStaged|SessionRevertCleared|SessionRevertCommitted)\d+$/.test(
|
|
||||||
name,
|
|
||||||
) &&
|
|
||||||
!reachable.has(name)
|
|
||||||
)
|
|
||||||
delete schemas[name]
|
|
||||||
}
|
|
||||||
await Bun.write("./openapi.json", JSON.stringify(document))
|
|
||||||
}
|
|
||||||
|
|
||||||
await createClient({
|
|
||||||
input: "./openapi.json",
|
|
||||||
output: {
|
|
||||||
path: "./src/v2/gen",
|
|
||||||
tsConfigPath: path.join(dir, "tsconfig.json"),
|
|
||||||
clean: true,
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
{
|
|
||||||
name: "@hey-api/typescript",
|
|
||||||
exportFromIndex: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "@hey-api/sdk",
|
|
||||||
instance: "OpencodeClient",
|
|
||||||
exportFromIndex: false,
|
|
||||||
auth: false,
|
|
||||||
paramsStructure: "flat",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "@hey-api/client-fetch",
|
|
||||||
exportFromIndex: false,
|
|
||||||
baseUrl: "http://localhost:4096",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
|
|
||||||
const generatedTypesPath = "./src/v2/gen/types.gen.ts"
|
|
||||||
const generatedTypes = await Bun.file(generatedTypesPath).text()
|
|
||||||
if (
|
|
||||||
/export type (SessionAgentSelected|SessionModelSelected|SessionMoved|SessionRenamed|SessionForked|SessionInputPromoted|SessionInputAdmitted|SessionExecutionStarted|SessionExecutionSucceeded|SessionExecutionFailed|SessionExecutionInterrupted|SessionInstructionsUpdated|SessionSynthetic|SessionSkillActivated|SessionShellStarted|SessionShellEnded|SessionStepStarted|SessionStepEnded|SessionStepFailed|SessionTextStarted|SessionTextDelta|SessionTextEnded|SessionToolInputStarted|SessionToolInputDelta|SessionToolInputEnded|SessionToolCalled|SessionToolProgress|SessionToolSuccess|SessionToolFailed|SessionRetryScheduled|SessionCompactionStarted|SessionCompactionDelta|SessionCompactionEnded|SessionRevertStaged|SessionRevertCleared|SessionRevertCommitted)\d+ =/.test(
|
|
||||||
generatedTypes,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw new Error("Session history generated duplicate Session event variants")
|
|
||||||
}
|
|
||||||
const sessionErrorTypesPatched = deduplicateEquivalentGeneratedTypes(
|
|
||||||
generatedTypes,
|
|
||||||
"SessionStructuredError",
|
|
||||||
/^SessionStructuredError\d+$/,
|
|
||||||
)
|
|
||||||
const obsoleteSessionNext = [...sessionErrorTypesPatched.matchAll(/export type (SessionNext\w*) =/g)].map(
|
|
||||||
(match) => match[1],
|
|
||||||
)
|
|
||||||
if (obsoleteSessionNext.length > 0) {
|
|
||||||
throw new Error(`Obsolete SessionNext generated type noise reintroduced: ${obsoleteSessionNext.join(", ")}`)
|
|
||||||
}
|
|
||||||
const logTypesPatched = sessionErrorTypesPatched.replace(
|
|
||||||
/(export type V2SessionLogData = \{[\s\S]*?query\?: \{\s*after\?: )string/,
|
|
||||||
"$1number",
|
|
||||||
)
|
|
||||||
if (logTypesPatched === sessionErrorTypesPatched) {
|
|
||||||
throw new Error("Session log numeric query patch did not apply")
|
|
||||||
}
|
|
||||||
const sessionListTypesPatched = logTypesPatched.replace(
|
|
||||||
/(export type V2SessionListData = \{[\s\S]*?query\?: \{[\s\S]*?limit\?: )string( \| null)/,
|
|
||||||
"$1number$2",
|
|
||||||
)
|
|
||||||
if (sessionListTypesPatched === logTypesPatched) {
|
|
||||||
throw new Error("Session list numeric query patch did not apply")
|
|
||||||
}
|
|
||||||
const sessionMessagesTypesPatched = sessionListTypesPatched.replace(
|
|
||||||
/(export type V2MessageListData = \{[\s\S]*?query\?: \{[\s\S]*?limit\?: )string( \| null)/,
|
|
||||||
"$1number$2",
|
|
||||||
)
|
|
||||||
if (sessionMessagesTypesPatched === sessionListTypesPatched) {
|
|
||||||
throw new Error("Session messages numeric query patch did not apply")
|
|
||||||
}
|
|
||||||
const eventSubscribeTypesPatched = sessionMessagesTypesPatched.replace(
|
|
||||||
/(export type V2EventSubscribeResponses = \{\s*\/\*\*[\s\S]*?\*\/\s*200: )\{\s*id: string \| null;?\s*event: string;?\s*data: (?:V2EventStream(?:V2)?|V2EventJsonString);?\s*\};?/,
|
|
||||||
"$1V2Event",
|
|
||||||
)
|
|
||||||
if (eventSubscribeTypesPatched === sessionMessagesTypesPatched) {
|
|
||||||
throw new Error("Event subscribe response patch did not apply")
|
|
||||||
}
|
|
||||||
if (/SessionStructuredError\d/.test(eventSubscribeTypesPatched)) {
|
|
||||||
throw new Error("Session structured error generated a name-mangled duplicate")
|
|
||||||
}
|
|
||||||
if (/\bSessionNext\w*\b/.test(eventSubscribeTypesPatched)) {
|
|
||||||
throw new Error("Obsolete SessionNext generated type noise reintroduced")
|
|
||||||
}
|
|
||||||
if (/export type Shell\d+V2 =/.test(eventSubscribeTypesPatched)) {
|
|
||||||
throw new Error("Shell generated a name-mangled duplicate")
|
|
||||||
}
|
|
||||||
await Bun.write(generatedTypesPath, eventSubscribeTypesPatched)
|
|
||||||
|
|
||||||
const querySerializerPath = "./src/v2/gen/client/utils.gen.ts"
|
|
||||||
const querySerializerSource = await Bun.file(querySerializerPath).text()
|
|
||||||
const querySerializerPatched = querySerializerSource.replace(
|
|
||||||
/if \(value === undefined \|\| value === null\) \{\s*continue;?\s*\}/,
|
|
||||||
"if (value === undefined) {\n continue;\n }\n\n if (value === null) {\n search.push(`${name}=null`);\n continue;\n }",
|
|
||||||
)
|
|
||||||
if (querySerializerPatched === querySerializerSource) {
|
|
||||||
throw new Error(
|
|
||||||
`Query serializer null patch did not apply; @hey-api/openapi-ts output may have changed (${querySerializerPath})`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
await Bun.write(querySerializerPath, querySerializerPatched)
|
|
||||||
|
|
||||||
const generatedSdkPath = "./src/v2/gen/sdk.gen.ts"
|
|
||||||
const generatedSdk = await Bun.file(generatedSdkPath).text()
|
|
||||||
const logSdkPatched = generatedSdk.replace(
|
|
||||||
/(Read the session log[\s\S]*?parameters: \{[\s\S]*?after\?: )string(\s*\|\s*null)?/,
|
|
||||||
"$1number$2",
|
|
||||||
)
|
|
||||||
if (logSdkPatched === generatedSdk) {
|
|
||||||
throw new Error("Session log numeric SDK patch did not apply")
|
|
||||||
}
|
|
||||||
const sessionListSdkPatched = logSdkPatched.replace(
|
|
||||||
/(List sessions[\s\S]*?parameters\?: \{[\s\S]*?limit\?: )string( \| null)/,
|
|
||||||
"$1number$2",
|
|
||||||
)
|
|
||||||
if (sessionListSdkPatched === logSdkPatched) {
|
|
||||||
throw new Error("Session list numeric SDK patch did not apply")
|
|
||||||
}
|
|
||||||
const sessionMessagesSdkPatched = sessionListSdkPatched.replace(
|
|
||||||
/(Get session messages[\s\S]*?parameters: \{[\s\S]*?limit\?: )string( \| null)/,
|
|
||||||
"$1number$2",
|
|
||||||
)
|
|
||||||
if (sessionMessagesSdkPatched === sessionListSdkPatched) {
|
|
||||||
throw new Error("Session messages numeric SDK patch did not apply")
|
|
||||||
}
|
|
||||||
await Bun.write(generatedSdkPath, sessionMessagesSdkPatched)
|
|
||||||
|
|
||||||
// Patch a @hey-api/openapi-ts codegen bug: SseFn incorrectly passes the
|
|
||||||
// endpoint's TError into the second generic of ServerSentEventsResult, which
|
|
||||||
// is the AsyncGenerator's TReturn slot. Iterator return values have nothing
|
|
||||||
// to do with HTTP errors, and any consumer that calls `.return()` or returns
|
|
||||||
// from a mock generator gets type-checked against the wrong shape. Drop the
|
|
||||||
// arg so TReturn defaults to void.
|
|
||||||
const sseTypesPath = "./src/v2/gen/client/types.gen.ts"
|
|
||||||
const sseTypesFile = Bun.file(sseTypesPath)
|
|
||||||
const sseTypesSource = await sseTypesFile.text()
|
|
||||||
const sseTypesPatched = sseTypesSource.replace(
|
|
||||||
"=> Promise<ServerSentEventsResult<TData, TError>>",
|
|
||||||
"=> Promise<ServerSentEventsResult<TData>>",
|
|
||||||
)
|
|
||||||
if (sseTypesPatched === sseTypesSource) {
|
|
||||||
throw new Error(`SseFn patch did not apply; @hey-api/openapi-ts output may have changed (${sseTypesPath})`)
|
|
||||||
}
|
|
||||||
await Bun.write(sseTypesPath, sseTypesPatched)
|
|
||||||
|
|
||||||
await $`bun prettier --write src/gen`
|
|
||||||
await $`bun prettier --write src/v2`
|
|
||||||
await $`rm -rf dist`
|
|
||||||
await $`bun tsc`
|
|
||||||
await $`rm openapi.json openapi-v2.json`
|
|
||||||
|
|
||||||
function renameCollidingComponents(target: OpenApiDocument, source: OpenApiDocument) {
|
|
||||||
const targetSchemas = target.components?.schemas
|
|
||||||
const sourceSchemas = source.components?.schemas
|
|
||||||
if (!targetSchemas || !sourceSchemas) return
|
|
||||||
|
|
||||||
const renames = new Map<string, string>()
|
|
||||||
for (const name of Object.keys(sourceSchemas)) {
|
|
||||||
if (!Object.hasOwn(targetSchemas, name)) continue
|
|
||||||
if (JSON.stringify(normalizeSchema(sourceSchemas[name])) === JSON.stringify(normalizeSchema(targetSchemas[name]))) {
|
|
||||||
delete sourceSchemas[name]
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
let renamed = `${name}V2`
|
|
||||||
let index = 2
|
|
||||||
while (Object.hasOwn(targetSchemas, renamed) || Object.hasOwn(sourceSchemas, renamed)) {
|
|
||||||
renamed = `${name}V2${index}`
|
|
||||||
index++
|
|
||||||
}
|
|
||||||
renames.set(name, renamed)
|
|
||||||
}
|
|
||||||
if (renames.size === 0) return
|
|
||||||
|
|
||||||
source.components = {
|
|
||||||
...source.components,
|
|
||||||
schemas: Object.fromEntries(
|
|
||||||
Object.entries(sourceSchemas).map(([name, schema]) => [renames.get(name) ?? name, rewriteRefs(schema, renames)]),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
source.paths = rewriteRefs(source.paths, renames) as Record<string, unknown> | undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeComponentNames(document: OpenApiDocument) {
|
|
||||||
const schemas = document.components?.schemas
|
|
||||||
if (!schemas) return
|
|
||||||
|
|
||||||
const canonical = new Map(Object.entries(schemas))
|
|
||||||
const renames = new Map<string, string>()
|
|
||||||
for (const name of Object.keys(schemas)) {
|
|
||||||
const next = componentTypeName(name)
|
|
||||||
if (next === name) continue
|
|
||||||
const existing = canonical.get(next)
|
|
||||||
if (existing !== undefined) {
|
|
||||||
if (JSON.stringify(normalizeSchema(schemas[name])) !== JSON.stringify(normalizeSchema(existing))) continue
|
|
||||||
renames.set(name, next)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
renames.set(name, next)
|
|
||||||
canonical.set(next, schemas[name])
|
|
||||||
}
|
|
||||||
if (renames.size === 0) return
|
|
||||||
|
|
||||||
const renamed = new Set<string>()
|
|
||||||
document.components = {
|
|
||||||
...document.components,
|
|
||||||
schemas: Object.fromEntries(
|
|
||||||
[
|
|
||||||
...Object.entries(schemas).filter(([name]) => !renames.has(name)),
|
|
||||||
...Object.entries(schemas).flatMap(([name, schema]) => {
|
|
||||||
const next = renames.get(name)
|
|
||||||
if (!next || Object.hasOwn(schemas, next) || renamed.has(next)) return []
|
|
||||||
renamed.add(next)
|
|
||||||
return [[next, schema] as const]
|
|
||||||
}),
|
|
||||||
].map(([name, schema]) => [name, rewriteRefs(schema, renames)]),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
document.paths = rewriteRefs(document.paths, renames) as Record<string, unknown> | undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
function componentTypeName(name: string) {
|
|
||||||
if (!name.includes(".")) return name
|
|
||||||
return name
|
|
||||||
.split(".")
|
|
||||||
.filter((part) => !/^\d+$/.test(part))
|
|
||||||
.map((part) => part.slice(0, 1).toUpperCase() + part.slice(1))
|
|
||||||
.join("")
|
|
||||||
}
|
|
||||||
|
|
||||||
function deduplicateEquivalentComponent(document: OpenApiDocument, canonical: string, duplicate: string) {
|
|
||||||
const schemas = document.components?.schemas
|
|
||||||
if (!schemas?.[canonical] || !schemas[duplicate]) return
|
|
||||||
if (JSON.stringify(normalizeSchema(schemas[canonical])) !== JSON.stringify(normalizeSchema(schemas[duplicate]))) {
|
|
||||||
throw new Error(`${duplicate} no longer has the same wire shape as ${canonical}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const renames = new Map([[duplicate, canonical]])
|
|
||||||
const rewritten = rewriteRefs(schemas, renames) as Record<string, unknown>
|
|
||||||
delete rewritten[duplicate]
|
|
||||||
document.components = { ...document.components, schemas: rewritten }
|
|
||||||
document.paths = rewriteRefs(document.paths, renames) as Record<string, unknown> | undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
function deduplicateEquivalentGeneratedTypes(source: string, canonical: string, duplicates: RegExp) {
|
|
||||||
const canonicalType = generatedType(source, canonical)
|
|
||||||
if (!canonicalType) throw new Error(`Generated canonical type missing: ${canonical}`)
|
|
||||||
const names = [...source.matchAll(/export type (\w+) =/g)]
|
|
||||||
.map((match) => match[1])
|
|
||||||
.filter((name): name is string => name !== undefined && duplicates.test(name))
|
|
||||||
|
|
||||||
return names.reduce((patched, name) => {
|
|
||||||
const duplicate = generatedType(patched, name)
|
|
||||||
const currentCanonical = generatedType(patched, canonical)
|
|
||||||
if (!duplicate || !currentCanonical) throw new Error(`Generated type declaration missing while comparing ${name}`)
|
|
||||||
if (normalizeGeneratedType(currentCanonical.shape) !== normalizeGeneratedType(duplicate.shape)) {
|
|
||||||
throw new Error(`${name} no longer has the same generated type shape as ${canonical}`)
|
|
||||||
}
|
|
||||||
return (patched.slice(0, duplicate.start) + patched.slice(duplicate.end)).replaceAll(name, canonical)
|
|
||||||
}, source)
|
|
||||||
}
|
|
||||||
|
|
||||||
function generatedType(source: string, name: string) {
|
|
||||||
const start = source.indexOf(`export type ${name} =`)
|
|
||||||
if (start === -1) return undefined
|
|
||||||
const next = source.indexOf("\n\nexport type ", start + 1)
|
|
||||||
const shapeEnd = next === -1 ? source.length : next
|
|
||||||
return {
|
|
||||||
start,
|
|
||||||
end: next === -1 ? source.length : next + 2,
|
|
||||||
shape: source.slice(source.indexOf("=", start) + 1, shapeEnd),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeGeneratedType(shape: string) {
|
|
||||||
return shape.replaceAll(/\s/g, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeSchema(value: unknown, key?: string): unknown {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
const flattened =
|
|
||||||
key === "anyOf"
|
|
||||||
? value.flatMap((item) =>
|
|
||||||
typeof item === "object" && item !== null && Object.keys(item).length === 1 && "anyOf" in item
|
|
||||||
? Array.isArray(item.anyOf)
|
|
||||||
? item.anyOf
|
|
||||||
: [item]
|
|
||||||
: [item],
|
|
||||||
)
|
|
||||||
: value
|
|
||||||
const expanded =
|
|
||||||
key === "anyOf"
|
|
||||||
? flattened.flatMap((item) => {
|
|
||||||
if (typeof item !== "object" || item === null || !("type" in item) || !("enum" in item)) return [item]
|
|
||||||
if (Object.keys(item).some((property) => property !== "type" && property !== "enum")) return [item]
|
|
||||||
if (!Array.isArray(item.enum)) return [item]
|
|
||||||
return item.enum.map((member) => ({ type: item.type, enum: [member] }))
|
|
||||||
})
|
|
||||||
: flattened
|
|
||||||
const normalized = expanded.map((item) => normalizeSchema(item))
|
|
||||||
if (key !== "anyOf" && key !== "required" && key !== "enum") return normalized
|
|
||||||
return [...new Map(normalized.map((item) => [JSON.stringify(item), item])).values()].sort((a, b) =>
|
|
||||||
JSON.stringify(a).localeCompare(JSON.stringify(b)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (typeof value !== "object" || value === null) return value
|
|
||||||
return Object.fromEntries(
|
|
||||||
Object.entries(value)
|
|
||||||
.sort(([left], [right]) => left.localeCompare(right))
|
|
||||||
.map(([property, child]) => [property, normalizeSchema(child, property)]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function rewriteRefs(value: unknown, renames: Map<string, string>): unknown {
|
|
||||||
if (Array.isArray(value)) return value.map((item) => rewriteRefs(item, renames))
|
|
||||||
if (typeof value !== "object" || value === null) return value
|
|
||||||
|
|
||||||
return Object.fromEntries(
|
|
||||||
Object.entries(value).map(([key, child]) => {
|
|
||||||
if (key !== "$ref" || typeof child !== "string") return [key, rewriteRefs(child, renames)]
|
|
||||||
const prefix = "#/components/schemas/"
|
|
||||||
if (!child.startsWith(prefix)) return [key, child]
|
|
||||||
return [key, `${prefix}${renames.get(child.slice(prefix.length)) ?? child.slice(prefix.length)}`]
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function inlineTypedAllOfConstraints(value: unknown): void {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
value.forEach(inlineTypedAllOfConstraints)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (typeof value !== "object" || value === null) return
|
|
||||||
|
|
||||||
const schema = value as { allOf?: unknown; type?: unknown; [key: string]: unknown }
|
|
||||||
if (typeof schema.type === "string" && Array.isArray(schema.allOf) && schema.allOf.every(isConstraintSchema)) {
|
|
||||||
for (const item of schema.allOf) Object.assign(schema, item)
|
|
||||||
delete schema.allOf
|
|
||||||
}
|
|
||||||
Object.values(schema).forEach(inlineTypedAllOfConstraints)
|
|
||||||
}
|
|
||||||
|
|
||||||
function isConstraintSchema(value: unknown): value is Record<string, unknown> {
|
|
||||||
if (typeof value !== "object" || value === null || Array.isArray(value)) return false
|
|
||||||
return !Object.keys(value).some(
|
|
||||||
(key) => key === "$ref" || key === "type" || key === "allOf" || key === "anyOf" || key === "oneOf",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
#!/usr/bin/env bun
|
|
||||||
|
|
||||||
import { Script } from "@opencode-ai/script"
|
|
||||||
import { $ } from "bun"
|
|
||||||
import { fileURLToPath } from "url"
|
|
||||||
|
|
||||||
const dir = fileURLToPath(new URL("..", import.meta.url))
|
|
||||||
process.chdir(dir)
|
|
||||||
|
|
||||||
async function published(name: string, version: string) {
|
|
||||||
return (await $`npm view ${name}@${version} version`.nothrow()).exitCode === 0
|
|
||||||
}
|
|
||||||
|
|
||||||
const originalText = await Bun.file("package.json").text()
|
|
||||||
const pkg = JSON.parse(originalText) as {
|
|
||||||
name: string
|
|
||||||
version: string
|
|
||||||
exports: Record<string, unknown>
|
|
||||||
}
|
|
||||||
function transformExports(exports: Record<string, unknown>) {
|
|
||||||
return Object.fromEntries(
|
|
||||||
Object.entries(exports).map(([key, value]) => {
|
|
||||||
if (typeof value === "string") {
|
|
||||||
const file = value.replace("./src/", "./dist/").replace(".ts", "")
|
|
||||||
return [key, { import: file + ".js", types: file + ".d.ts" }]
|
|
||||||
}
|
|
||||||
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
||||||
return [key, transformExports(value)]
|
|
||||||
}
|
|
||||||
return [key, value]
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (await published(pkg.name, pkg.version)) {
|
|
||||||
console.log(`already published ${pkg.name}@${pkg.version}`)
|
|
||||||
} else {
|
|
||||||
pkg.exports = transformExports(pkg.exports)
|
|
||||||
await Bun.write("package.json", JSON.stringify(pkg, null, 2))
|
|
||||||
try {
|
|
||||||
await $`bun pm pack`
|
|
||||||
await $`npm publish *.tgz --tag ${Script.channel} --access public`
|
|
||||||
} finally {
|
|
||||||
await Bun.write("package.json", originalText)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
export * from "./gen/types.gen.js"
|
|
||||||
|
|
||||||
import { createClient } from "./gen/client/client.gen.js"
|
|
||||||
import { type Config } from "./gen/client/types.gen.js"
|
|
||||||
import { OpencodeClient } from "./gen/sdk.gen.js"
|
|
||||||
import { wrapClientError } from "./error-interceptor.js"
|
|
||||||
export { type Config as OpencodeClientConfig, OpencodeClient }
|
|
||||||
|
|
||||||
function pick(value: string | null, fallback?: string) {
|
|
||||||
if (!value) return
|
|
||||||
if (!fallback) return value
|
|
||||||
if (value === fallback) return fallback
|
|
||||||
if (value === encodeURIComponent(fallback)) return fallback
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
function rewrite(request: Request, directory?: string) {
|
|
||||||
if (request.method !== "GET" && request.method !== "HEAD") return request
|
|
||||||
|
|
||||||
const value = pick(request.headers.get("x-opencode-directory"), directory)
|
|
||||||
if (!value) return request
|
|
||||||
|
|
||||||
const url = new URL(request.url)
|
|
||||||
if (!url.searchParams.has("directory")) {
|
|
||||||
url.searchParams.set("directory", value)
|
|
||||||
}
|
|
||||||
|
|
||||||
const next = new Request(url, request)
|
|
||||||
next.headers.delete("x-opencode-directory")
|
|
||||||
return next
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createOpencodeClient(config?: Config & { directory?: string }) {
|
|
||||||
if (!config?.fetch) {
|
|
||||||
const customFetch: any = (req: any) => {
|
|
||||||
// @ts-ignore
|
|
||||||
req.timeout = false
|
|
||||||
return fetch(req)
|
|
||||||
}
|
|
||||||
config = {
|
|
||||||
...config,
|
|
||||||
fetch: customFetch,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config?.directory) {
|
|
||||||
config.headers = {
|
|
||||||
...config.headers,
|
|
||||||
"x-opencode-directory": encodeURIComponent(config.directory),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const client = createClient(config)
|
|
||||||
client.interceptors.request.use((request) => rewrite(request, config?.directory))
|
|
||||||
client.interceptors.error.use(wrapClientError)
|
|
||||||
return new OpencodeClient({ client })
|
|
||||||
}
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
/**
|
|
||||||
* Wrap whatever the generated client decoded from a non-2xx error body
|
|
||||||
* into a real `Error` so downstream formatters (TUI, plugins) get a
|
|
||||||
* useful `.message` instead of `[object Object]` or blank. The original
|
|
||||||
* parsed body and status live under `.cause` for callers that need
|
|
||||||
* structured fields.
|
|
||||||
*
|
|
||||||
* Only fires when the caller used `{ throwOnError: true }`. Callers that
|
|
||||||
* read `result.error` directly (the result-tuple path) get the parsed
|
|
||||||
* body unchanged so existing field-level reads (`.error.name`,
|
|
||||||
* `JSON.stringify(error)`, etc.) are byte-for-byte identical to before.
|
|
||||||
*/
|
|
||||||
export function wrapClientError(
|
|
||||||
error: unknown,
|
|
||||||
response: Response | undefined,
|
|
||||||
request: Request | undefined,
|
|
||||||
opts: { throwOnError?: boolean } | undefined,
|
|
||||||
): unknown {
|
|
||||||
if (!opts?.throwOnError) return error
|
|
||||||
if (error instanceof Error) return error
|
|
||||||
|
|
||||||
// NamedError-shaped responses (the common case for opencode 4xx) come
|
|
||||||
// through as POJOs — extract a useful message first, then wrap.
|
|
||||||
if (typeof error === "object" && error !== null && Object.keys(error).length > 0) {
|
|
||||||
const obj = error as { data?: { message?: unknown }; message?: unknown; name?: unknown }
|
|
||||||
const message =
|
|
||||||
(typeof obj.data?.message === "string" && obj.data.message) ||
|
|
||||||
(typeof obj.message === "string" && obj.message) ||
|
|
||||||
(typeof obj.name === "string" && obj.name) ||
|
|
||||||
describe(request, response)
|
|
||||||
return new Error(message, { cause: { body: error, status: response?.status } })
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof error === "string" && error.length > 0) {
|
|
||||||
return new Error(error, { cause: { body: error, status: response?.status } })
|
|
||||||
}
|
|
||||||
|
|
||||||
// Empty body / network failure / undefined / null / empty object.
|
|
||||||
const reason = response ? "(empty response body)" : "network error (no response)"
|
|
||||||
return new Error(`opencode server ${describe(request, response)}: ${reason}`, {
|
|
||||||
cause: { body: error, status: response?.status },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function describe(request: Request | undefined, response: Response | undefined) {
|
|
||||||
const method = request?.method ?? "?"
|
|
||||||
const url = request?.url ?? "?"
|
|
||||||
const status = response?.status
|
|
||||||
const statusText = response?.statusText
|
|
||||||
return `${method} ${url}${status ? " → " + status : ""}${statusText ? " " + statusText : ""}`
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { ClientOptions } from "./types.gen.js"
|
|
||||||
import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from "./client/index.js"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The `createClientConfig()` function will be called on client initialization
|
|
||||||
* and the returned object will become the client's initial configuration.
|
|
||||||
*
|
|
||||||
* You may want to initialize your client this way instead of calling
|
|
||||||
* `setConfig()`. This is useful for example if you're using Next.js
|
|
||||||
* to ensure your client always has the correct values.
|
|
||||||
*/
|
|
||||||
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (
|
|
||||||
override?: Config<DefaultClientOptions & T>,
|
|
||||||
) => Config<Required<DefaultClientOptions> & T>
|
|
||||||
|
|
||||||
export const client = createClient(
|
|
||||||
createConfig<ClientOptions>({
|
|
||||||
baseUrl: "http://localhost:4096",
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
|
|
@ -1,212 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import { createSseClient } from "../core/serverSentEvents.gen.js"
|
|
||||||
import type { Client, Config, RequestOptions, ResolvedRequestOptions } from "./types.gen.js"
|
|
||||||
import {
|
|
||||||
buildUrl,
|
|
||||||
createConfig,
|
|
||||||
createInterceptors,
|
|
||||||
getParseAs,
|
|
||||||
mergeConfigs,
|
|
||||||
mergeHeaders,
|
|
||||||
setAuthParams,
|
|
||||||
} from "./utils.gen.js"
|
|
||||||
|
|
||||||
type ReqInit = Omit<RequestInit, "body" | "headers"> & {
|
|
||||||
body?: any
|
|
||||||
headers: ReturnType<typeof mergeHeaders>
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createClient = (config: Config = {}): Client => {
|
|
||||||
let _config = mergeConfigs(createConfig(), config)
|
|
||||||
|
|
||||||
const getConfig = (): Config => ({ ..._config })
|
|
||||||
|
|
||||||
const setConfig = (config: Config): Config => {
|
|
||||||
_config = mergeConfigs(_config, config)
|
|
||||||
return getConfig()
|
|
||||||
}
|
|
||||||
|
|
||||||
const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>()
|
|
||||||
|
|
||||||
const beforeRequest = async (options: RequestOptions) => {
|
|
||||||
const opts = {
|
|
||||||
..._config,
|
|
||||||
...options,
|
|
||||||
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
||||||
headers: mergeHeaders(_config.headers, options.headers),
|
|
||||||
serializedBody: undefined,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.security) {
|
|
||||||
await setAuthParams({
|
|
||||||
...opts,
|
|
||||||
security: opts.security,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.requestValidator) {
|
|
||||||
await opts.requestValidator(opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.body && opts.bodySerializer) {
|
|
||||||
opts.serializedBody = opts.bodySerializer(opts.body)
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
||||||
if (opts.serializedBody === undefined || opts.serializedBody === "") {
|
|
||||||
opts.headers.delete("Content-Type")
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = buildUrl(opts)
|
|
||||||
|
|
||||||
return { opts, url }
|
|
||||||
}
|
|
||||||
|
|
||||||
const request: Client["request"] = async (options) => {
|
|
||||||
// @ts-expect-error
|
|
||||||
const { opts, url } = await beforeRequest(options)
|
|
||||||
const requestInit: ReqInit = {
|
|
||||||
redirect: "follow",
|
|
||||||
...opts,
|
|
||||||
body: opts.serializedBody,
|
|
||||||
}
|
|
||||||
|
|
||||||
let request = new Request(url, requestInit)
|
|
||||||
|
|
||||||
for (const fn of interceptors.request._fns) {
|
|
||||||
if (fn) {
|
|
||||||
request = await fn(request, opts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// fetch must be assigned here, otherwise it would throw the error:
|
|
||||||
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
||||||
const _fetch = opts.fetch!
|
|
||||||
let response = await _fetch(request)
|
|
||||||
|
|
||||||
for (const fn of interceptors.response._fns) {
|
|
||||||
if (fn) {
|
|
||||||
response = await fn(response, request, opts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = {
|
|
||||||
request,
|
|
||||||
response,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
||||||
return opts.responseStyle === "data"
|
|
||||||
? {}
|
|
||||||
: {
|
|
||||||
data: {},
|
|
||||||
...result,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const parseAs =
|
|
||||||
(opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json"
|
|
||||||
|
|
||||||
let data: any
|
|
||||||
switch (parseAs) {
|
|
||||||
case "arrayBuffer":
|
|
||||||
case "blob":
|
|
||||||
case "formData":
|
|
||||||
case "json":
|
|
||||||
case "text":
|
|
||||||
data = await response[parseAs]()
|
|
||||||
break
|
|
||||||
case "stream":
|
|
||||||
return opts.responseStyle === "data"
|
|
||||||
? response.body
|
|
||||||
: {
|
|
||||||
data: response.body,
|
|
||||||
...result,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parseAs === "json") {
|
|
||||||
if (opts.responseValidator) {
|
|
||||||
await opts.responseValidator(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.responseTransformer) {
|
|
||||||
data = await opts.responseTransformer(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return opts.responseStyle === "data"
|
|
||||||
? data
|
|
||||||
: {
|
|
||||||
data,
|
|
||||||
...result,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const textError = await response.text()
|
|
||||||
let jsonError: unknown
|
|
||||||
|
|
||||||
try {
|
|
||||||
jsonError = JSON.parse(textError)
|
|
||||||
} catch {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
|
|
||||||
const error = jsonError ?? textError
|
|
||||||
let finalError = error
|
|
||||||
|
|
||||||
for (const fn of interceptors.error._fns) {
|
|
||||||
if (fn) {
|
|
||||||
finalError = (await fn(error, response, request, opts)) as string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
finalError = finalError || ({} as string)
|
|
||||||
|
|
||||||
if (opts.throwOnError) {
|
|
||||||
throw finalError
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: we probably want to return error and improve types
|
|
||||||
return opts.responseStyle === "data"
|
|
||||||
? undefined
|
|
||||||
: {
|
|
||||||
error: finalError,
|
|
||||||
...result,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const makeMethod = (method: Required<Config>["method"]) => {
|
|
||||||
const fn = (options: RequestOptions) => request({ ...options, method })
|
|
||||||
fn.sse = async (options: RequestOptions) => {
|
|
||||||
const { opts, url } = await beforeRequest(options)
|
|
||||||
return createSseClient({
|
|
||||||
...opts,
|
|
||||||
body: opts.body as BodyInit | null | undefined,
|
|
||||||
headers: opts.headers as unknown as Record<string, string>,
|
|
||||||
method,
|
|
||||||
url,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return fn
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
buildUrl,
|
|
||||||
connect: makeMethod("CONNECT"),
|
|
||||||
delete: makeMethod("DELETE"),
|
|
||||||
get: makeMethod("GET"),
|
|
||||||
getConfig,
|
|
||||||
head: makeMethod("HEAD"),
|
|
||||||
interceptors,
|
|
||||||
options: makeMethod("OPTIONS"),
|
|
||||||
patch: makeMethod("PATCH"),
|
|
||||||
post: makeMethod("POST"),
|
|
||||||
put: makeMethod("PUT"),
|
|
||||||
request,
|
|
||||||
setConfig,
|
|
||||||
trace: makeMethod("TRACE"),
|
|
||||||
} as Client
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
export type { Auth } from "../core/auth.gen.js"
|
|
||||||
export type { QuerySerializerOptions } from "../core/bodySerializer.gen.js"
|
|
||||||
export {
|
|
||||||
formDataBodySerializer,
|
|
||||||
jsonBodySerializer,
|
|
||||||
urlSearchParamsBodySerializer,
|
|
||||||
} from "../core/bodySerializer.gen.js"
|
|
||||||
export { buildClientParams } from "../core/params.gen.js"
|
|
||||||
export { createClient } from "./client.gen.js"
|
|
||||||
export type {
|
|
||||||
Client,
|
|
||||||
ClientOptions,
|
|
||||||
Config,
|
|
||||||
CreateClientConfig,
|
|
||||||
Options,
|
|
||||||
OptionsLegacyParser,
|
|
||||||
RequestOptions,
|
|
||||||
RequestResult,
|
|
||||||
ResolvedRequestOptions,
|
|
||||||
ResponseStyle,
|
|
||||||
TDataShape,
|
|
||||||
} from "./types.gen.js"
|
|
||||||
export { createConfig, mergeHeaders } from "./utils.gen.js"
|
|
||||||
|
|
@ -1,222 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { Auth } from "../core/auth.gen.js"
|
|
||||||
import type { ServerSentEventsOptions, ServerSentEventsResult } from "../core/serverSentEvents.gen.js"
|
|
||||||
import type { Client as CoreClient, Config as CoreConfig } from "../core/types.gen.js"
|
|
||||||
import type { Middleware } from "./utils.gen.js"
|
|
||||||
|
|
||||||
export type ResponseStyle = "data" | "fields"
|
|
||||||
|
|
||||||
export interface Config<T extends ClientOptions = ClientOptions>
|
|
||||||
extends Omit<RequestInit, "body" | "headers" | "method">,
|
|
||||||
CoreConfig {
|
|
||||||
/**
|
|
||||||
* Base URL for all requests made by this client.
|
|
||||||
*/
|
|
||||||
baseUrl?: T["baseUrl"]
|
|
||||||
/**
|
|
||||||
* Fetch API implementation. You can use this option to provide a custom
|
|
||||||
* fetch instance.
|
|
||||||
*
|
|
||||||
* @default globalThis.fetch
|
|
||||||
*/
|
|
||||||
fetch?: (request: Request) => ReturnType<typeof fetch>
|
|
||||||
/**
|
|
||||||
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
||||||
* options won't have any effect.
|
|
||||||
*
|
|
||||||
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
|
|
||||||
*/
|
|
||||||
next?: never
|
|
||||||
/**
|
|
||||||
* Return the response data parsed in a specified format. By default, `auto`
|
|
||||||
* will infer the appropriate method from the `Content-Type` response header.
|
|
||||||
* You can override this behavior with any of the {@link Body} methods.
|
|
||||||
* Select `stream` if you don't want to parse response data at all.
|
|
||||||
*
|
|
||||||
* @default 'auto'
|
|
||||||
*/
|
|
||||||
parseAs?: "arrayBuffer" | "auto" | "blob" | "formData" | "json" | "stream" | "text"
|
|
||||||
/**
|
|
||||||
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
||||||
*
|
|
||||||
* @default 'fields'
|
|
||||||
*/
|
|
||||||
responseStyle?: ResponseStyle
|
|
||||||
/**
|
|
||||||
* Throw an error instead of returning it in the response?
|
|
||||||
*
|
|
||||||
* @default false
|
|
||||||
*/
|
|
||||||
throwOnError?: T["throwOnError"]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RequestOptions<
|
|
||||||
TData = unknown,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
Url extends string = string,
|
|
||||||
> extends Config<{
|
|
||||||
responseStyle: TResponseStyle
|
|
||||||
throwOnError: ThrowOnError
|
|
||||||
}>,
|
|
||||||
Pick<
|
|
||||||
ServerSentEventsOptions<TData>,
|
|
||||||
"onSseError" | "onSseEvent" | "sseDefaultRetryDelay" | "sseMaxRetryAttempts" | "sseMaxRetryDelay"
|
|
||||||
> {
|
|
||||||
/**
|
|
||||||
* Any body that you want to add to your request.
|
|
||||||
*
|
|
||||||
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
||||||
*/
|
|
||||||
body?: unknown
|
|
||||||
path?: Record<string, unknown>
|
|
||||||
query?: Record<string, unknown>
|
|
||||||
/**
|
|
||||||
* Security mechanism(s) to use for the request.
|
|
||||||
*/
|
|
||||||
security?: ReadonlyArray<Auth>
|
|
||||||
url: Url
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ResolvedRequestOptions<
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
Url extends string = string,
|
|
||||||
> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
||||||
serializedBody?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type RequestResult<
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
> = ThrowOnError extends true
|
|
||||||
? Promise<
|
|
||||||
TResponseStyle extends "data"
|
|
||||||
? TData extends Record<string, unknown>
|
|
||||||
? TData[keyof TData]
|
|
||||||
: TData
|
|
||||||
: {
|
|
||||||
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData
|
|
||||||
request: Request
|
|
||||||
response: Response
|
|
||||||
}
|
|
||||||
>
|
|
||||||
: Promise<
|
|
||||||
TResponseStyle extends "data"
|
|
||||||
? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined
|
|
||||||
: (
|
|
||||||
| {
|
|
||||||
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData
|
|
||||||
error: undefined
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
data: undefined
|
|
||||||
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError
|
|
||||||
}
|
|
||||||
) & {
|
|
||||||
request: Request
|
|
||||||
response: Response
|
|
||||||
}
|
|
||||||
>
|
|
||||||
|
|
||||||
export interface ClientOptions {
|
|
||||||
baseUrl?: string
|
|
||||||
responseStyle?: ResponseStyle
|
|
||||||
throwOnError?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
type MethodFnBase = <
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
>(
|
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">,
|
|
||||||
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>
|
|
||||||
|
|
||||||
type MethodFnServerSentEvents = <
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
>(
|
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">,
|
|
||||||
) => Promise<ServerSentEventsResult<TData, TError>>
|
|
||||||
|
|
||||||
type MethodFn = MethodFnBase & {
|
|
||||||
sse: MethodFnServerSentEvents
|
|
||||||
}
|
|
||||||
|
|
||||||
type RequestFn = <
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
>(
|
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method"> &
|
|
||||||
Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, "method">,
|
|
||||||
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>
|
|
||||||
|
|
||||||
type BuildUrlFn = <
|
|
||||||
TData extends {
|
|
||||||
body?: unknown
|
|
||||||
path?: Record<string, unknown>
|
|
||||||
query?: Record<string, unknown>
|
|
||||||
url: string
|
|
||||||
},
|
|
||||||
>(
|
|
||||||
options: Pick<TData, "url"> & Options<TData>,
|
|
||||||
) => string
|
|
||||||
|
|
||||||
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn> & {
|
|
||||||
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The `createClientConfig()` function will be called on client initialization
|
|
||||||
* and the returned object will become the client's initial configuration.
|
|
||||||
*
|
|
||||||
* You may want to initialize your client this way instead of calling
|
|
||||||
* `setConfig()`. This is useful for example if you're using Next.js
|
|
||||||
* to ensure your client always has the correct values.
|
|
||||||
*/
|
|
||||||
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
|
||||||
override?: Config<ClientOptions & T>,
|
|
||||||
) => Config<Required<ClientOptions> & T>
|
|
||||||
|
|
||||||
export interface TDataShape {
|
|
||||||
body?: unknown
|
|
||||||
headers?: unknown
|
|
||||||
path?: unknown
|
|
||||||
query?: unknown
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>
|
|
||||||
|
|
||||||
export type Options<
|
|
||||||
TData extends TDataShape = TDataShape,
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
TResponse = unknown,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, "body" | "path" | "query" | "url"> &
|
|
||||||
Omit<TData, "url">
|
|
||||||
|
|
||||||
export type OptionsLegacyParser<
|
|
||||||
TData = unknown,
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
> = TData extends { body?: any }
|
|
||||||
? TData extends { headers?: any }
|
|
||||||
? OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "body" | "headers" | "url"> & TData
|
|
||||||
: OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "body" | "url"> &
|
|
||||||
TData &
|
|
||||||
Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "headers">
|
|
||||||
: TData extends { headers?: any }
|
|
||||||
? OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "headers" | "url"> &
|
|
||||||
TData &
|
|
||||||
Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "body">
|
|
||||||
: OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "url"> & TData
|
|
||||||
|
|
@ -1,287 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import { getAuthToken } from "../core/auth.gen.js"
|
|
||||||
import type { QuerySerializerOptions } from "../core/bodySerializer.gen.js"
|
|
||||||
import { jsonBodySerializer } from "../core/bodySerializer.gen.js"
|
|
||||||
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam } from "../core/pathSerializer.gen.js"
|
|
||||||
import { getUrl } from "../core/utils.gen.js"
|
|
||||||
import type { Client, ClientOptions, Config, RequestOptions } from "./types.gen.js"
|
|
||||||
|
|
||||||
export const createQuerySerializer = <T = unknown>({ allowReserved, array, object }: QuerySerializerOptions = {}) => {
|
|
||||||
const querySerializer = (queryParams: T) => {
|
|
||||||
const search: string[] = []
|
|
||||||
if (queryParams && typeof queryParams === "object") {
|
|
||||||
for (const name in queryParams) {
|
|
||||||
const value = queryParams[name]
|
|
||||||
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
const serializedArray = serializeArrayParam({
|
|
||||||
allowReserved,
|
|
||||||
explode: true,
|
|
||||||
name,
|
|
||||||
style: "form",
|
|
||||||
value,
|
|
||||||
...array,
|
|
||||||
})
|
|
||||||
if (serializedArray) search.push(serializedArray)
|
|
||||||
} else if (typeof value === "object") {
|
|
||||||
const serializedObject = serializeObjectParam({
|
|
||||||
allowReserved,
|
|
||||||
explode: true,
|
|
||||||
name,
|
|
||||||
style: "deepObject",
|
|
||||||
value: value as Record<string, unknown>,
|
|
||||||
...object,
|
|
||||||
})
|
|
||||||
if (serializedObject) search.push(serializedObject)
|
|
||||||
} else {
|
|
||||||
const serializedPrimitive = serializePrimitiveParam({
|
|
||||||
allowReserved,
|
|
||||||
name,
|
|
||||||
value: value as string,
|
|
||||||
})
|
|
||||||
if (serializedPrimitive) search.push(serializedPrimitive)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return search.join("&")
|
|
||||||
}
|
|
||||||
return querySerializer
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Infers parseAs value from provided Content-Type header.
|
|
||||||
*/
|
|
||||||
export const getParseAs = (contentType: string | null): Exclude<Config["parseAs"], "auto"> => {
|
|
||||||
if (!contentType) {
|
|
||||||
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
||||||
// which is effectively the same as the 'stream' option.
|
|
||||||
return "stream"
|
|
||||||
}
|
|
||||||
|
|
||||||
const cleanContent = contentType.split(";")[0]?.trim()
|
|
||||||
|
|
||||||
if (!cleanContent) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
||||||
return "json"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cleanContent === "multipart/form-data") {
|
|
||||||
return "formData"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
||||||
return "blob"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cleanContent.startsWith("text/")) {
|
|
||||||
return "text"
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const checkForExistence = (
|
|
||||||
options: Pick<RequestOptions, "auth" | "query"> & {
|
|
||||||
headers: Headers
|
|
||||||
},
|
|
||||||
name?: string,
|
|
||||||
): boolean => {
|
|
||||||
if (!name) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
export const setAuthParams = async ({
|
|
||||||
security,
|
|
||||||
...options
|
|
||||||
}: Pick<Required<RequestOptions>, "security"> &
|
|
||||||
Pick<RequestOptions, "auth" | "query"> & {
|
|
||||||
headers: Headers
|
|
||||||
}) => {
|
|
||||||
for (const auth of security) {
|
|
||||||
if (checkForExistence(options, auth.name)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = await getAuthToken(auth, options.auth)
|
|
||||||
|
|
||||||
if (!token) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const name = auth.name ?? "Authorization"
|
|
||||||
|
|
||||||
switch (auth.in) {
|
|
||||||
case "query":
|
|
||||||
if (!options.query) {
|
|
||||||
options.query = {}
|
|
||||||
}
|
|
||||||
options.query[name] = token
|
|
||||||
break
|
|
||||||
case "cookie":
|
|
||||||
options.headers.append("Cookie", `${name}=${token}`)
|
|
||||||
break
|
|
||||||
case "header":
|
|
||||||
default:
|
|
||||||
options.headers.set(name, token)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const buildUrl: Client["buildUrl"] = (options) =>
|
|
||||||
getUrl({
|
|
||||||
baseUrl: options.baseUrl as string,
|
|
||||||
path: options.path,
|
|
||||||
query: options.query,
|
|
||||||
querySerializer:
|
|
||||||
typeof options.querySerializer === "function"
|
|
||||||
? options.querySerializer
|
|
||||||
: createQuerySerializer(options.querySerializer),
|
|
||||||
url: options.url,
|
|
||||||
})
|
|
||||||
|
|
||||||
export const mergeConfigs = (a: Config, b: Config): Config => {
|
|
||||||
const config = { ...a, ...b }
|
|
||||||
if (config.baseUrl?.endsWith("/")) {
|
|
||||||
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1)
|
|
||||||
}
|
|
||||||
config.headers = mergeHeaders(a.headers, b.headers)
|
|
||||||
return config
|
|
||||||
}
|
|
||||||
|
|
||||||
export const mergeHeaders = (...headers: Array<Required<Config>["headers"] | undefined>): Headers => {
|
|
||||||
const mergedHeaders = new Headers()
|
|
||||||
for (const header of headers) {
|
|
||||||
if (!header || typeof header !== "object") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const iterator = header instanceof Headers ? header.entries() : Object.entries(header)
|
|
||||||
|
|
||||||
for (const [key, value] of iterator) {
|
|
||||||
if (value === null) {
|
|
||||||
mergedHeaders.delete(key)
|
|
||||||
} else if (Array.isArray(value)) {
|
|
||||||
for (const v of value) {
|
|
||||||
mergedHeaders.append(key, v as string)
|
|
||||||
}
|
|
||||||
} else if (value !== undefined) {
|
|
||||||
// assume object headers are meant to be JSON stringified, i.e. their
|
|
||||||
// content value in OpenAPI specification is 'application/json'
|
|
||||||
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : (value as string))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mergedHeaders
|
|
||||||
}
|
|
||||||
|
|
||||||
type ErrInterceptor<Err, Res, Req, Options> = (
|
|
||||||
error: Err,
|
|
||||||
response: Res,
|
|
||||||
request: Req,
|
|
||||||
options: Options,
|
|
||||||
) => Err | Promise<Err>
|
|
||||||
|
|
||||||
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>
|
|
||||||
|
|
||||||
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>
|
|
||||||
|
|
||||||
class Interceptors<Interceptor> {
|
|
||||||
_fns: (Interceptor | null)[]
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this._fns = []
|
|
||||||
}
|
|
||||||
|
|
||||||
clear() {
|
|
||||||
this._fns = []
|
|
||||||
}
|
|
||||||
|
|
||||||
getInterceptorIndex(id: number | Interceptor): number {
|
|
||||||
if (typeof id === "number") {
|
|
||||||
return this._fns[id] ? id : -1
|
|
||||||
} else {
|
|
||||||
return this._fns.indexOf(id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exists(id: number | Interceptor) {
|
|
||||||
const index = this.getInterceptorIndex(id)
|
|
||||||
return !!this._fns[index]
|
|
||||||
}
|
|
||||||
|
|
||||||
eject(id: number | Interceptor) {
|
|
||||||
const index = this.getInterceptorIndex(id)
|
|
||||||
if (this._fns[index]) {
|
|
||||||
this._fns[index] = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
update(id: number | Interceptor, fn: Interceptor) {
|
|
||||||
const index = this.getInterceptorIndex(id)
|
|
||||||
if (this._fns[index]) {
|
|
||||||
this._fns[index] = fn
|
|
||||||
return id
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
use(fn: Interceptor) {
|
|
||||||
this._fns = [...this._fns, fn]
|
|
||||||
return this._fns.length - 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// `createInterceptors()` response, meant for external use as it does not
|
|
||||||
// expose internals
|
|
||||||
export interface Middleware<Req, Res, Err, Options> {
|
|
||||||
error: Pick<Interceptors<ErrInterceptor<Err, Res, Req, Options>>, "eject" | "use">
|
|
||||||
request: Pick<Interceptors<ReqInterceptor<Req, Options>>, "eject" | "use">
|
|
||||||
response: Pick<Interceptors<ResInterceptor<Res, Req, Options>>, "eject" | "use">
|
|
||||||
}
|
|
||||||
|
|
||||||
// do not add `Middleware` as return type so we can use _fns internally
|
|
||||||
export const createInterceptors = <Req, Res, Err, Options>() => ({
|
|
||||||
error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(),
|
|
||||||
request: new Interceptors<ReqInterceptor<Req, Options>>(),
|
|
||||||
response: new Interceptors<ResInterceptor<Res, Req, Options>>(),
|
|
||||||
})
|
|
||||||
|
|
||||||
const defaultQuerySerializer = createQuerySerializer({
|
|
||||||
allowReserved: false,
|
|
||||||
array: {
|
|
||||||
explode: true,
|
|
||||||
style: "form",
|
|
||||||
},
|
|
||||||
object: {
|
|
||||||
explode: true,
|
|
||||||
style: "deepObject",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const defaultHeaders = {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
|
||||||
override: Config<Omit<ClientOptions, keyof T> & T> = {},
|
|
||||||
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
|
||||||
...jsonBodySerializer,
|
|
||||||
headers: defaultHeaders,
|
|
||||||
parseAs: "auto",
|
|
||||||
querySerializer: defaultQuerySerializer,
|
|
||||||
...override,
|
|
||||||
})
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
export type AuthToken = string | undefined
|
|
||||||
|
|
||||||
export interface Auth {
|
|
||||||
/**
|
|
||||||
* Which part of the request do we use to send the auth?
|
|
||||||
*
|
|
||||||
* @default 'header'
|
|
||||||
*/
|
|
||||||
in?: "header" | "query" | "cookie"
|
|
||||||
/**
|
|
||||||
* Header or query parameter name.
|
|
||||||
*
|
|
||||||
* @default 'Authorization'
|
|
||||||
*/
|
|
||||||
name?: string
|
|
||||||
scheme?: "basic" | "bearer"
|
|
||||||
type: "apiKey" | "http"
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getAuthToken = async (
|
|
||||||
auth: Auth,
|
|
||||||
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
|
||||||
): Promise<string | undefined> => {
|
|
||||||
const token = typeof callback === "function" ? await callback(auth) : callback
|
|
||||||
|
|
||||||
if (!token) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auth.scheme === "bearer") {
|
|
||||||
return `Bearer ${token}`
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auth.scheme === "basic") {
|
|
||||||
return `Basic ${btoa(token)}`
|
|
||||||
}
|
|
||||||
|
|
||||||
return token
|
|
||||||
}
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { ArrayStyle, ObjectStyle, SerializerOptions } from "./pathSerializer.gen.js"
|
|
||||||
|
|
||||||
export type QuerySerializer = (query: Record<string, unknown>) => string
|
|
||||||
|
|
||||||
export type BodySerializer = (body: any) => any
|
|
||||||
|
|
||||||
export interface QuerySerializerOptions {
|
|
||||||
allowReserved?: boolean
|
|
||||||
array?: SerializerOptions<ArrayStyle>
|
|
||||||
object?: SerializerOptions<ObjectStyle>
|
|
||||||
}
|
|
||||||
|
|
||||||
const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => {
|
|
||||||
if (typeof value === "string" || value instanceof Blob) {
|
|
||||||
data.append(key, value)
|
|
||||||
} else if (value instanceof Date) {
|
|
||||||
data.append(key, value.toISOString())
|
|
||||||
} else {
|
|
||||||
data.append(key, JSON.stringify(value))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => {
|
|
||||||
if (typeof value === "string") {
|
|
||||||
data.append(key, value)
|
|
||||||
} else {
|
|
||||||
data.append(key, JSON.stringify(value))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const formDataBodySerializer = {
|
|
||||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): FormData => {
|
|
||||||
const data = new FormData()
|
|
||||||
|
|
||||||
Object.entries(body).forEach(([key, value]) => {
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
value.forEach((v) => serializeFormDataPair(data, key, v))
|
|
||||||
} else {
|
|
||||||
serializeFormDataPair(data, key, value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return data
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export const jsonBodySerializer = {
|
|
||||||
bodySerializer: <T>(body: T): string =>
|
|
||||||
JSON.stringify(body, (_key, value) => (typeof value === "bigint" ? value.toString() : value)),
|
|
||||||
}
|
|
||||||
|
|
||||||
export const urlSearchParamsBodySerializer = {
|
|
||||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): string => {
|
|
||||||
const data = new URLSearchParams()
|
|
||||||
|
|
||||||
Object.entries(body).forEach(([key, value]) => {
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v))
|
|
||||||
} else {
|
|
||||||
serializeUrlSearchParamsPair(data, key, value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return data.toString()
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -1,144 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
type Slot = "body" | "headers" | "path" | "query"
|
|
||||||
|
|
||||||
export type Field =
|
|
||||||
| {
|
|
||||||
in: Exclude<Slot, "body">
|
|
||||||
/**
|
|
||||||
* Field name. This is the name we want the user to see and use.
|
|
||||||
*/
|
|
||||||
key: string
|
|
||||||
/**
|
|
||||||
* Field mapped name. This is the name we want to use in the request.
|
|
||||||
* If omitted, we use the same value as `key`.
|
|
||||||
*/
|
|
||||||
map?: string
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
in: Extract<Slot, "body">
|
|
||||||
/**
|
|
||||||
* Key isn't required for bodies.
|
|
||||||
*/
|
|
||||||
key?: string
|
|
||||||
map?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Fields {
|
|
||||||
allowExtra?: Partial<Record<Slot, boolean>>
|
|
||||||
args?: ReadonlyArray<Field>
|
|
||||||
}
|
|
||||||
|
|
||||||
export type FieldsConfig = ReadonlyArray<Field | Fields>
|
|
||||||
|
|
||||||
const extraPrefixesMap: Record<string, Slot> = {
|
|
||||||
$body_: "body",
|
|
||||||
$headers_: "headers",
|
|
||||||
$path_: "path",
|
|
||||||
$query_: "query",
|
|
||||||
}
|
|
||||||
const extraPrefixes = Object.entries(extraPrefixesMap)
|
|
||||||
|
|
||||||
type KeyMap = Map<
|
|
||||||
string,
|
|
||||||
{
|
|
||||||
in: Slot
|
|
||||||
map?: string
|
|
||||||
}
|
|
||||||
>
|
|
||||||
|
|
||||||
const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
|
|
||||||
if (!map) {
|
|
||||||
map = new Map()
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const config of fields) {
|
|
||||||
if ("in" in config) {
|
|
||||||
if (config.key) {
|
|
||||||
map.set(config.key, {
|
|
||||||
in: config.in,
|
|
||||||
map: config.map,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else if (config.args) {
|
|
||||||
buildKeyMap(config.args, map)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return map
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Params {
|
|
||||||
body: unknown
|
|
||||||
headers: Record<string, unknown>
|
|
||||||
path: Record<string, unknown>
|
|
||||||
query: Record<string, unknown>
|
|
||||||
}
|
|
||||||
|
|
||||||
const stripEmptySlots = (params: Params) => {
|
|
||||||
for (const [slot, value] of Object.entries(params)) {
|
|
||||||
if (value && typeof value === "object" && !Object.keys(value).length) {
|
|
||||||
delete params[slot as Slot]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsConfig) => {
|
|
||||||
const params: Params = {
|
|
||||||
body: {},
|
|
||||||
headers: {},
|
|
||||||
path: {},
|
|
||||||
query: {},
|
|
||||||
}
|
|
||||||
|
|
||||||
const map = buildKeyMap(fields)
|
|
||||||
|
|
||||||
let config: FieldsConfig[number] | undefined
|
|
||||||
|
|
||||||
for (const [index, arg] of args.entries()) {
|
|
||||||
if (fields[index]) {
|
|
||||||
config = fields[index]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!config) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("in" in config) {
|
|
||||||
if (config.key) {
|
|
||||||
const field = map.get(config.key)!
|
|
||||||
const name = field.map || config.key
|
|
||||||
;(params[field.in] as Record<string, unknown>)[name] = arg
|
|
||||||
} else {
|
|
||||||
params.body = arg
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
||||||
const field = map.get(key)
|
|
||||||
|
|
||||||
if (field) {
|
|
||||||
const name = field.map || key
|
|
||||||
;(params[field.in] as Record<string, unknown>)[name] = value
|
|
||||||
} else {
|
|
||||||
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix))
|
|
||||||
|
|
||||||
if (extra) {
|
|
||||||
const [prefix, slot] = extra
|
|
||||||
;(params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value
|
|
||||||
} else {
|
|
||||||
for (const [slot, allowed] of Object.entries(config.allowExtra ?? {})) {
|
|
||||||
if (allowed) {
|
|
||||||
;(params[slot as Slot] as Record<string, unknown>)[key] = value
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stripEmptySlots(params)
|
|
||||||
|
|
||||||
return params
|
|
||||||
}
|
|
||||||
|
|
@ -1,167 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {}
|
|
||||||
|
|
||||||
interface SerializePrimitiveOptions {
|
|
||||||
allowReserved?: boolean
|
|
||||||
name: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SerializerOptions<T> {
|
|
||||||
/**
|
|
||||||
* @default true
|
|
||||||
*/
|
|
||||||
explode: boolean
|
|
||||||
style: T
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ArrayStyle = "form" | "spaceDelimited" | "pipeDelimited"
|
|
||||||
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle
|
|
||||||
type MatrixStyle = "label" | "matrix" | "simple"
|
|
||||||
export type ObjectStyle = "form" | "deepObject"
|
|
||||||
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle
|
|
||||||
|
|
||||||
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|
||||||
value: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
|
||||||
switch (style) {
|
|
||||||
case "label":
|
|
||||||
return "."
|
|
||||||
case "matrix":
|
|
||||||
return ";"
|
|
||||||
case "simple":
|
|
||||||
return ","
|
|
||||||
default:
|
|
||||||
return "&"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
|
||||||
switch (style) {
|
|
||||||
case "form":
|
|
||||||
return ","
|
|
||||||
case "pipeDelimited":
|
|
||||||
return "|"
|
|
||||||
case "spaceDelimited":
|
|
||||||
return "%20"
|
|
||||||
default:
|
|
||||||
return ","
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
|
|
||||||
switch (style) {
|
|
||||||
case "label":
|
|
||||||
return "."
|
|
||||||
case "matrix":
|
|
||||||
return ";"
|
|
||||||
case "simple":
|
|
||||||
return ","
|
|
||||||
default:
|
|
||||||
return "&"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const serializeArrayParam = ({
|
|
||||||
allowReserved,
|
|
||||||
explode,
|
|
||||||
name,
|
|
||||||
style,
|
|
||||||
value,
|
|
||||||
}: SerializeOptions<ArraySeparatorStyle> & {
|
|
||||||
value: unknown[]
|
|
||||||
}) => {
|
|
||||||
if (!explode) {
|
|
||||||
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v as string))).join(
|
|
||||||
separatorArrayNoExplode(style),
|
|
||||||
)
|
|
||||||
switch (style) {
|
|
||||||
case "label":
|
|
||||||
return `.${joinedValues}`
|
|
||||||
case "matrix":
|
|
||||||
return `;${name}=${joinedValues}`
|
|
||||||
case "simple":
|
|
||||||
return joinedValues
|
|
||||||
default:
|
|
||||||
return `${name}=${joinedValues}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const separator = separatorArrayExplode(style)
|
|
||||||
const joinedValues = value
|
|
||||||
.map((v) => {
|
|
||||||
if (style === "label" || style === "simple") {
|
|
||||||
return allowReserved ? v : encodeURIComponent(v as string)
|
|
||||||
}
|
|
||||||
|
|
||||||
return serializePrimitiveParam({
|
|
||||||
allowReserved,
|
|
||||||
name,
|
|
||||||
value: v as string,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.join(separator)
|
|
||||||
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues
|
|
||||||
}
|
|
||||||
|
|
||||||
export const serializePrimitiveParam = ({ allowReserved, name, value }: SerializePrimitiveParam) => {
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof value === "object") {
|
|
||||||
throw new Error(
|
|
||||||
"Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`
|
|
||||||
}
|
|
||||||
|
|
||||||
export const serializeObjectParam = ({
|
|
||||||
allowReserved,
|
|
||||||
explode,
|
|
||||||
name,
|
|
||||||
style,
|
|
||||||
value,
|
|
||||||
valueOnly,
|
|
||||||
}: SerializeOptions<ObjectSeparatorStyle> & {
|
|
||||||
value: Record<string, unknown> | Date
|
|
||||||
valueOnly?: boolean
|
|
||||||
}) => {
|
|
||||||
if (value instanceof Date) {
|
|
||||||
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style !== "deepObject" && !explode) {
|
|
||||||
let values: string[] = []
|
|
||||||
Object.entries(value).forEach(([key, v]) => {
|
|
||||||
values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)]
|
|
||||||
})
|
|
||||||
const joinedValues = values.join(",")
|
|
||||||
switch (style) {
|
|
||||||
case "form":
|
|
||||||
return `${name}=${joinedValues}`
|
|
||||||
case "label":
|
|
||||||
return `.${joinedValues}`
|
|
||||||
case "matrix":
|
|
||||||
return `;${name}=${joinedValues}`
|
|
||||||
default:
|
|
||||||
return joinedValues
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const separator = separatorObjectExplode(style)
|
|
||||||
const joinedValues = Object.entries(value)
|
|
||||||
.map(([key, v]) =>
|
|
||||||
serializePrimitiveParam({
|
|
||||||
allowReserved,
|
|
||||||
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
||||||
value: v as string,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.join(separator)
|
|
||||||
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues
|
|
||||||
}
|
|
||||||
|
|
@ -1,111 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON-friendly union that mirrors what Pinia Colada can hash.
|
|
||||||
*/
|
|
||||||
export type JsonValue = null | string | number | boolean | JsonValue[] | { [key: string]: JsonValue }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
||||||
*/
|
|
||||||
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
|
|
||||||
if (value === undefined || typeof value === "function" || typeof value === "symbol") {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
if (typeof value === "bigint") {
|
|
||||||
return value.toString()
|
|
||||||
}
|
|
||||||
if (value instanceof Date) {
|
|
||||||
return value.toISOString()
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Safely stringifies a value and parses it back into a JsonValue.
|
|
||||||
*/
|
|
||||||
export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => {
|
|
||||||
try {
|
|
||||||
const json = JSON.stringify(input, queryKeyJsonReplacer)
|
|
||||||
if (json === undefined) {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
return JSON.parse(json) as JsonValue
|
|
||||||
} catch {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Detects plain objects (including objects with a null prototype).
|
|
||||||
*/
|
|
||||||
const isPlainObject = (value: unknown): value is Record<string, unknown> => {
|
|
||||||
if (value === null || typeof value !== "object") {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const prototype = Object.getPrototypeOf(value as object)
|
|
||||||
return prototype === Object.prototype || prototype === null
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns URLSearchParams into a sorted JSON object for deterministic keys.
|
|
||||||
*/
|
|
||||||
const serializeSearchParams = (params: URLSearchParams): JsonValue => {
|
|
||||||
const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b))
|
|
||||||
const result: Record<string, JsonValue> = {}
|
|
||||||
|
|
||||||
for (const [key, value] of entries) {
|
|
||||||
const existing = result[key]
|
|
||||||
if (existing === undefined) {
|
|
||||||
result[key] = value
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(existing)) {
|
|
||||||
;(existing as string[]).push(value)
|
|
||||||
} else {
|
|
||||||
result[key] = [existing, value]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
|
||||||
*/
|
|
||||||
export const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => {
|
|
||||||
if (value === null) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value === undefined || typeof value === "function" || typeof value === "symbol") {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof value === "bigint") {
|
|
||||||
return value.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Date) {
|
|
||||||
return value.toISOString()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
return stringifyToJsonValue(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams) {
|
|
||||||
return serializeSearchParams(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPlainObject(value)) {
|
|
||||||
return stringifyToJsonValue(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
@ -1,210 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { Config } from "./types.gen.js"
|
|
||||||
|
|
||||||
export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, "method"> &
|
|
||||||
Pick<Config, "method" | "responseTransformer" | "responseValidator"> & {
|
|
||||||
/**
|
|
||||||
* Callback invoked when a network or parsing error occurs during streaming.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @param error The error that occurred.
|
|
||||||
*/
|
|
||||||
onSseError?: (error: unknown) => void
|
|
||||||
/**
|
|
||||||
* Callback invoked when an event is streamed from the server.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @param event Event streamed from the server.
|
|
||||||
* @returns Nothing (void).
|
|
||||||
*/
|
|
||||||
onSseEvent?: (event: StreamEvent<TData>) => void
|
|
||||||
/**
|
|
||||||
* Default retry delay in milliseconds.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @default 3000
|
|
||||||
*/
|
|
||||||
sseDefaultRetryDelay?: number
|
|
||||||
/**
|
|
||||||
* Maximum number of retry attempts before giving up.
|
|
||||||
*/
|
|
||||||
sseMaxRetryAttempts?: number
|
|
||||||
/**
|
|
||||||
* Maximum retry delay in milliseconds.
|
|
||||||
*
|
|
||||||
* Applies only when exponential backoff is used.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @default 30000
|
|
||||||
*/
|
|
||||||
sseMaxRetryDelay?: number
|
|
||||||
/**
|
|
||||||
* Optional sleep function for retry backoff.
|
|
||||||
*
|
|
||||||
* Defaults to using `setTimeout`.
|
|
||||||
*/
|
|
||||||
sseSleepFn?: (ms: number) => Promise<void>
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface StreamEvent<TData = unknown> {
|
|
||||||
data: TData
|
|
||||||
event?: string
|
|
||||||
id?: string
|
|
||||||
retry?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
|
|
||||||
stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createSseClient = <TData = unknown>({
|
|
||||||
onSseError,
|
|
||||||
onSseEvent,
|
|
||||||
responseTransformer,
|
|
||||||
responseValidator,
|
|
||||||
sseDefaultRetryDelay,
|
|
||||||
sseMaxRetryAttempts,
|
|
||||||
sseMaxRetryDelay,
|
|
||||||
sseSleepFn,
|
|
||||||
url,
|
|
||||||
...options
|
|
||||||
}: ServerSentEventsOptions): ServerSentEventsResult<TData> => {
|
|
||||||
let lastEventId: string | undefined
|
|
||||||
|
|
||||||
const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms)))
|
|
||||||
|
|
||||||
const createStream = async function* () {
|
|
||||||
let retryDelay: number = sseDefaultRetryDelay ?? 3000
|
|
||||||
let attempt = 0
|
|
||||||
const signal = options.signal ?? new AbortController().signal
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
if (signal.aborted) break
|
|
||||||
|
|
||||||
attempt++
|
|
||||||
|
|
||||||
const headers =
|
|
||||||
options.headers instanceof Headers
|
|
||||||
? options.headers
|
|
||||||
: new Headers(options.headers as Record<string, string> | undefined)
|
|
||||||
|
|
||||||
if (lastEventId !== undefined) {
|
|
||||||
headers.set("Last-Event-ID", lastEventId)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(url, { ...options, headers, signal })
|
|
||||||
|
|
||||||
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`)
|
|
||||||
|
|
||||||
if (!response.body) throw new Error("No body in SSE response")
|
|
||||||
|
|
||||||
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader()
|
|
||||||
|
|
||||||
let buffer = ""
|
|
||||||
|
|
||||||
const abortHandler = () => {
|
|
||||||
try {
|
|
||||||
void reader.cancel()
|
|
||||||
} catch {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signal.addEventListener("abort", abortHandler)
|
|
||||||
|
|
||||||
try {
|
|
||||||
while (true) {
|
|
||||||
const { done, value } = await reader.read()
|
|
||||||
if (done) break
|
|
||||||
buffer += value
|
|
||||||
|
|
||||||
const chunks = buffer.split("\n\n")
|
|
||||||
buffer = chunks.pop() ?? ""
|
|
||||||
|
|
||||||
for (const chunk of chunks) {
|
|
||||||
const lines = chunk.split("\n")
|
|
||||||
const dataLines: Array<string> = []
|
|
||||||
let eventName: string | undefined
|
|
||||||
|
|
||||||
for (const line of lines) {
|
|
||||||
if (line.startsWith("data:")) {
|
|
||||||
dataLines.push(line.replace(/^data:\s*/, ""))
|
|
||||||
} else if (line.startsWith("event:")) {
|
|
||||||
eventName = line.replace(/^event:\s*/, "")
|
|
||||||
} else if (line.startsWith("id:")) {
|
|
||||||
lastEventId = line.replace(/^id:\s*/, "")
|
|
||||||
} else if (line.startsWith("retry:")) {
|
|
||||||
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10)
|
|
||||||
if (!Number.isNaN(parsed)) {
|
|
||||||
retryDelay = parsed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let data: unknown
|
|
||||||
let parsedJson = false
|
|
||||||
|
|
||||||
if (dataLines.length) {
|
|
||||||
const rawData = dataLines.join("\n")
|
|
||||||
try {
|
|
||||||
data = JSON.parse(rawData)
|
|
||||||
parsedJson = true
|
|
||||||
} catch {
|
|
||||||
data = rawData
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parsedJson) {
|
|
||||||
if (responseValidator) {
|
|
||||||
await responseValidator(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (responseTransformer) {
|
|
||||||
data = await responseTransformer(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onSseEvent?.({
|
|
||||||
data,
|
|
||||||
event: eventName,
|
|
||||||
id: lastEventId,
|
|
||||||
retry: retryDelay,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (dataLines.length) {
|
|
||||||
yield data as any
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
signal.removeEventListener("abort", abortHandler)
|
|
||||||
reader.releaseLock()
|
|
||||||
}
|
|
||||||
|
|
||||||
break // exit loop on normal completion
|
|
||||||
} catch (error) {
|
|
||||||
// connection failed or aborted; retry after delay
|
|
||||||
onSseError?.(error)
|
|
||||||
|
|
||||||
if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
|
|
||||||
break // stop after firing error
|
|
||||||
}
|
|
||||||
|
|
||||||
// exponential backoff: double retry each attempt, cap at 30s
|
|
||||||
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000)
|
|
||||||
await sleep(backoff)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const stream = createStream()
|
|
||||||
|
|
||||||
return { stream }
|
|
||||||
}
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { Auth, AuthToken } from "./auth.gen.js"
|
|
||||||
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from "./bodySerializer.gen.js"
|
|
||||||
|
|
||||||
export interface Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> {
|
|
||||||
/**
|
|
||||||
* Returns the final request URL.
|
|
||||||
*/
|
|
||||||
buildUrl: BuildUrlFn
|
|
||||||
connect: MethodFn
|
|
||||||
delete: MethodFn
|
|
||||||
get: MethodFn
|
|
||||||
getConfig: () => Config
|
|
||||||
head: MethodFn
|
|
||||||
options: MethodFn
|
|
||||||
patch: MethodFn
|
|
||||||
post: MethodFn
|
|
||||||
put: MethodFn
|
|
||||||
request: RequestFn
|
|
||||||
setConfig: (config: Config) => Config
|
|
||||||
trace: MethodFn
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Config {
|
|
||||||
/**
|
|
||||||
* Auth token or a function returning auth token. The resolved value will be
|
|
||||||
* added to the request payload as defined by its `security` array.
|
|
||||||
*/
|
|
||||||
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken
|
|
||||||
/**
|
|
||||||
* A function for serializing request body parameter. By default,
|
|
||||||
* {@link JSON.stringify()} will be used.
|
|
||||||
*/
|
|
||||||
bodySerializer?: BodySerializer | null
|
|
||||||
/**
|
|
||||||
* An object containing any HTTP headers that you want to pre-populate your
|
|
||||||
* `Headers` object with.
|
|
||||||
*
|
|
||||||
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
||||||
*/
|
|
||||||
headers?:
|
|
||||||
| RequestInit["headers"]
|
|
||||||
| Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>
|
|
||||||
/**
|
|
||||||
* The request method.
|
|
||||||
*
|
|
||||||
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
|
||||||
*/
|
|
||||||
method?: "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE"
|
|
||||||
/**
|
|
||||||
* A function for serializing request query parameters. By default, arrays
|
|
||||||
* will be exploded in form style, objects will be exploded in deepObject
|
|
||||||
* style, and reserved characters are percent-encoded.
|
|
||||||
*
|
|
||||||
* This method will have no effect if the native `paramsSerializer()` Axios
|
|
||||||
* API function is used.
|
|
||||||
*
|
|
||||||
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
|
||||||
*/
|
|
||||||
querySerializer?: QuerySerializer | QuerySerializerOptions
|
|
||||||
/**
|
|
||||||
* A function validating request data. This is useful if you want to ensure
|
|
||||||
* the request conforms to the desired shape, so it can be safely sent to
|
|
||||||
* the server.
|
|
||||||
*/
|
|
||||||
requestValidator?: (data: unknown) => Promise<unknown>
|
|
||||||
/**
|
|
||||||
* A function transforming response data before it's returned. This is useful
|
|
||||||
* for post-processing data, e.g. converting ISO strings into Date objects.
|
|
||||||
*/
|
|
||||||
responseTransformer?: (data: unknown) => Promise<unknown>
|
|
||||||
/**
|
|
||||||
* A function validating response data. This is useful if you want to ensure
|
|
||||||
* the response conforms to the desired shape, so it can be safely passed to
|
|
||||||
* the transformers and returned to the user.
|
|
||||||
*/
|
|
||||||
responseValidator?: (data: unknown) => Promise<unknown>
|
|
||||||
}
|
|
||||||
|
|
||||||
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
|
|
||||||
? true
|
|
||||||
: [T] extends [never | undefined]
|
|
||||||
? [undefined] extends [T]
|
|
||||||
? false
|
|
||||||
: true
|
|
||||||
: false
|
|
||||||
|
|
||||||
export type OmitNever<T extends Record<string, unknown>> = {
|
|
||||||
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K]
|
|
||||||
}
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { QuerySerializer } from "./bodySerializer.gen.js"
|
|
||||||
import {
|
|
||||||
type ArraySeparatorStyle,
|
|
||||||
serializeArrayParam,
|
|
||||||
serializeObjectParam,
|
|
||||||
serializePrimitiveParam,
|
|
||||||
} from "./pathSerializer.gen.js"
|
|
||||||
|
|
||||||
export interface PathSerializer {
|
|
||||||
path: Record<string, unknown>
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export const PATH_PARAM_RE = /\{[^{}]+\}/g
|
|
||||||
|
|
||||||
export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
||||||
let url = _url
|
|
||||||
const matches = _url.match(PATH_PARAM_RE)
|
|
||||||
if (matches) {
|
|
||||||
for (const match of matches) {
|
|
||||||
let explode = false
|
|
||||||
let name = match.substring(1, match.length - 1)
|
|
||||||
let style: ArraySeparatorStyle = "simple"
|
|
||||||
|
|
||||||
if (name.endsWith("*")) {
|
|
||||||
explode = true
|
|
||||||
name = name.substring(0, name.length - 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name.startsWith(".")) {
|
|
||||||
name = name.substring(1)
|
|
||||||
style = "label"
|
|
||||||
} else if (name.startsWith(";")) {
|
|
||||||
name = name.substring(1)
|
|
||||||
style = "matrix"
|
|
||||||
}
|
|
||||||
|
|
||||||
const value = path[name]
|
|
||||||
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
url = url.replace(match, serializeArrayParam({ explode, name, style, value }))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof value === "object") {
|
|
||||||
url = url.replace(
|
|
||||||
match,
|
|
||||||
serializeObjectParam({
|
|
||||||
explode,
|
|
||||||
name,
|
|
||||||
style,
|
|
||||||
value: value as Record<string, unknown>,
|
|
||||||
valueOnly: true,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style === "matrix") {
|
|
||||||
url = url.replace(
|
|
||||||
match,
|
|
||||||
`;${serializePrimitiveParam({
|
|
||||||
name,
|
|
||||||
value: value as string,
|
|
||||||
})}`,
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const replaceValue = encodeURIComponent(style === "label" ? `.${value as string}` : (value as string))
|
|
||||||
url = url.replace(match, replaceValue)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return url
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getUrl = ({
|
|
||||||
baseUrl,
|
|
||||||
path,
|
|
||||||
query,
|
|
||||||
querySerializer,
|
|
||||||
url: _url,
|
|
||||||
}: {
|
|
||||||
baseUrl?: string
|
|
||||||
path?: Record<string, unknown>
|
|
||||||
query?: Record<string, unknown>
|
|
||||||
querySerializer: QuerySerializer
|
|
||||||
url: string
|
|
||||||
}) => {
|
|
||||||
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`
|
|
||||||
let url = (baseUrl ?? "") + pathUrl
|
|
||||||
if (path) {
|
|
||||||
url = defaultPathSerializer({ path, url })
|
|
||||||
}
|
|
||||||
let search = query ? querySerializer(query) : ""
|
|
||||||
if (search.startsWith("?")) {
|
|
||||||
search = search.substring(1)
|
|
||||||
}
|
|
||||||
if (search) {
|
|
||||||
url += `?${search}`
|
|
||||||
}
|
|
||||||
return url
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,21 +0,0 @@
|
||||||
export * from "./client.js"
|
|
||||||
export * from "./server.js"
|
|
||||||
|
|
||||||
import { createOpencodeClient } from "./client.js"
|
|
||||||
import { createOpencodeServer } from "./server.js"
|
|
||||||
import type { ServerOptions } from "./server.js"
|
|
||||||
|
|
||||||
export async function createOpencode(options?: ServerOptions) {
|
|
||||||
const server = await createOpencodeServer({
|
|
||||||
...options,
|
|
||||||
})
|
|
||||||
|
|
||||||
const client = createOpencodeClient({
|
|
||||||
baseUrl: server.url,
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
|
||||||
client,
|
|
||||||
server,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
import { type ChildProcess, spawnSync } from "node:child_process"
|
|
||||||
|
|
||||||
// Duplicated from `packages/opencode/src/util/process.ts` because the SDK cannot
|
|
||||||
// import `opencode` without creating a cycle (`opencode` depends on `@opencode-ai/sdk`).
|
|
||||||
export function stop(proc: ChildProcess) {
|
|
||||||
if (proc.exitCode !== null || proc.signalCode !== null) return
|
|
||||||
if (process.platform === "win32" && proc.pid) {
|
|
||||||
const out = spawnSync("taskkill", ["/pid", String(proc.pid), "/T", "/F"], { windowsHide: true })
|
|
||||||
if (!out.error && out.status === 0) return
|
|
||||||
}
|
|
||||||
proc.kill()
|
|
||||||
}
|
|
||||||
|
|
||||||
export function bindAbort(proc: ChildProcess, signal?: AbortSignal, onAbort?: () => void) {
|
|
||||||
if (!signal) return () => {}
|
|
||||||
const abort = () => {
|
|
||||||
clear()
|
|
||||||
stop(proc)
|
|
||||||
onAbort?.()
|
|
||||||
}
|
|
||||||
const clear = () => {
|
|
||||||
signal.removeEventListener("abort", abort)
|
|
||||||
proc.off("exit", clear)
|
|
||||||
proc.off("error", clear)
|
|
||||||
}
|
|
||||||
signal.addEventListener("abort", abort, { once: true })
|
|
||||||
proc.on("exit", clear)
|
|
||||||
proc.on("error", clear)
|
|
||||||
if (signal.aborted) abort()
|
|
||||||
return clear
|
|
||||||
}
|
|
||||||
|
|
@ -1,134 +0,0 @@
|
||||||
import launch from "cross-spawn"
|
|
||||||
import { type Config } from "./gen/types.gen.js"
|
|
||||||
import { stop, bindAbort } from "./process.js"
|
|
||||||
|
|
||||||
export type ServerOptions = {
|
|
||||||
hostname?: string
|
|
||||||
port?: number
|
|
||||||
signal?: AbortSignal
|
|
||||||
timeout?: number
|
|
||||||
config?: Config
|
|
||||||
}
|
|
||||||
|
|
||||||
export type TuiOptions = {
|
|
||||||
project?: string
|
|
||||||
model?: string
|
|
||||||
session?: string
|
|
||||||
agent?: string
|
|
||||||
signal?: AbortSignal
|
|
||||||
config?: Config
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function createOpencodeServer(options?: ServerOptions) {
|
|
||||||
options = Object.assign(
|
|
||||||
{
|
|
||||||
hostname: "127.0.0.1",
|
|
||||||
port: 4096,
|
|
||||||
timeout: 5000,
|
|
||||||
},
|
|
||||||
options ?? {},
|
|
||||||
)
|
|
||||||
|
|
||||||
const args = [`serve`, `--hostname=${options.hostname}`, `--port=${options.port}`]
|
|
||||||
if (options.config?.logLevel) args.push(`--log-level=${options.config.logLevel}`)
|
|
||||||
|
|
||||||
const proc = launch(`opencode`, args, {
|
|
||||||
env: {
|
|
||||||
...process.env,
|
|
||||||
OPENCODE_CONFIG_CONTENT: JSON.stringify(options.config ?? {}),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
let clear = () => {}
|
|
||||||
|
|
||||||
const url = await new Promise<string>((resolve, reject) => {
|
|
||||||
const id = setTimeout(() => {
|
|
||||||
clear()
|
|
||||||
stop(proc)
|
|
||||||
reject(new Error(`Timeout waiting for server to start after ${options.timeout}ms`))
|
|
||||||
}, options.timeout)
|
|
||||||
let output = ""
|
|
||||||
let resolved = false
|
|
||||||
proc.stdout?.on("data", (chunk) => {
|
|
||||||
if (resolved) return
|
|
||||||
output += chunk.toString()
|
|
||||||
const lines = output.split("\n")
|
|
||||||
for (const line of lines) {
|
|
||||||
if (line.startsWith("opencode server listening")) {
|
|
||||||
const match = line.match(/on\s+(https?:\/\/[^\s]+)/)
|
|
||||||
if (!match) {
|
|
||||||
clear()
|
|
||||||
stop(proc)
|
|
||||||
clearTimeout(id)
|
|
||||||
reject(new Error(`Failed to parse server url from output: ${line}`))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
clearTimeout(id)
|
|
||||||
resolved = true
|
|
||||||
resolve(match[1]!)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
proc.stderr?.on("data", (chunk) => {
|
|
||||||
output += chunk.toString()
|
|
||||||
})
|
|
||||||
proc.on("exit", (code) => {
|
|
||||||
clearTimeout(id)
|
|
||||||
let msg = `Server exited with code ${code}`
|
|
||||||
if (output.trim()) {
|
|
||||||
msg += `\nServer output: ${output}`
|
|
||||||
}
|
|
||||||
reject(new Error(msg))
|
|
||||||
})
|
|
||||||
proc.on("error", (error) => {
|
|
||||||
clearTimeout(id)
|
|
||||||
reject(error)
|
|
||||||
})
|
|
||||||
clear = bindAbort(proc, options.signal, () => {
|
|
||||||
clearTimeout(id)
|
|
||||||
reject(options.signal?.reason)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
|
||||||
url,
|
|
||||||
close() {
|
|
||||||
clear()
|
|
||||||
stop(proc)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createOpencodeTui(options?: TuiOptions) {
|
|
||||||
const args = []
|
|
||||||
|
|
||||||
if (options?.project) {
|
|
||||||
args.push(`--project=${options.project}`)
|
|
||||||
}
|
|
||||||
if (options?.model) {
|
|
||||||
args.push(`--model=${options.model}`)
|
|
||||||
}
|
|
||||||
if (options?.session) {
|
|
||||||
args.push(`--session=${options.session}`)
|
|
||||||
}
|
|
||||||
if (options?.agent) {
|
|
||||||
args.push(`--agent=${options.agent}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const proc = launch(`opencode`, args, {
|
|
||||||
stdio: "inherit",
|
|
||||||
env: {
|
|
||||||
...process.env,
|
|
||||||
OPENCODE_CONFIG_CONTENT: JSON.stringify(options?.config ?? {}),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const clear = bindAbort(proc, options?.signal)
|
|
||||||
|
|
||||||
return {
|
|
||||||
close() {
|
|
||||||
clear()
|
|
||||||
stop(proc)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
export * from "./gen/types.gen.js"
|
|
||||||
export type { FileSystemEntry as LocationFileSystemEntry } from "./gen/types.gen.js"
|
|
||||||
import type { UserMessage } from "./gen/types.gen.js"
|
|
||||||
|
|
||||||
/** @deprecated V1 snapshot compatibility. Use FileDiffInfo for current API responses. */
|
|
||||||
export type SnapshotFileDiff = NonNullable<NonNullable<UserMessage["summary"]>["diffs"]>[number]
|
|
||||||
|
|
||||||
import { createClient } from "./gen/client/client.gen.js"
|
|
||||||
import { type Config } from "./gen/client/types.gen.js"
|
|
||||||
import { OpencodeClient } from "./gen/sdk.gen.js"
|
|
||||||
import { wrapClientError } from "../error-interceptor.js"
|
|
||||||
export { type Config as OpencodeClientConfig, OpencodeClient }
|
|
||||||
|
|
||||||
function pick(value: string | null, fallback?: string, encode?: (value: string) => string) {
|
|
||||||
if (!value) return
|
|
||||||
if (!fallback) return value
|
|
||||||
if (value === fallback) return fallback
|
|
||||||
if (encode && value === encode(fallback)) return fallback
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
function rewrite(request: Request, values: { directory?: string; workspace?: string }) {
|
|
||||||
if (request.method !== "GET" && request.method !== "HEAD") return request
|
|
||||||
|
|
||||||
const url = new URL(request.url)
|
|
||||||
let changed = false
|
|
||||||
|
|
||||||
for (const [name, key] of [
|
|
||||||
["x-opencode-directory", "directory"],
|
|
||||||
["x-opencode-workspace", "workspace"],
|
|
||||||
] as const) {
|
|
||||||
const value = pick(
|
|
||||||
request.headers.get(name),
|
|
||||||
key === "directory" ? values.directory : values.workspace,
|
|
||||||
key === "directory" ? encodeURIComponent : undefined,
|
|
||||||
)
|
|
||||||
if (!value) continue
|
|
||||||
for (const query of url.pathname.startsWith("/api/") ? [key, `location[${key}]`] : [key]) {
|
|
||||||
if (!url.searchParams.has(query)) {
|
|
||||||
url.searchParams.set(query, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
changed = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!changed) return request
|
|
||||||
|
|
||||||
const next = new Request(url, request)
|
|
||||||
next.headers.delete("x-opencode-directory")
|
|
||||||
next.headers.delete("x-opencode-workspace")
|
|
||||||
return next
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createOpencodeClient(config?: Config & { directory?: string; experimental_workspaceID?: string }) {
|
|
||||||
if (!config?.fetch) {
|
|
||||||
const customFetch: any = (req: any) => {
|
|
||||||
// @ts-ignore
|
|
||||||
req.timeout = false
|
|
||||||
return fetch(req)
|
|
||||||
}
|
|
||||||
config = {
|
|
||||||
...config,
|
|
||||||
fetch: customFetch,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config?.directory) {
|
|
||||||
config.headers = {
|
|
||||||
...config.headers,
|
|
||||||
"x-opencode-directory": encodeURIComponent(config.directory),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config?.experimental_workspaceID) {
|
|
||||||
config.headers = {
|
|
||||||
...config.headers,
|
|
||||||
"x-opencode-workspace": config.experimental_workspaceID,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const client = createClient(config)
|
|
||||||
client.interceptors.request.use((request) =>
|
|
||||||
rewrite(request, {
|
|
||||||
directory: config?.directory,
|
|
||||||
workspace: config?.experimental_workspaceID,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
client.interceptors.response.use((response) => {
|
|
||||||
const contentType = response.headers.get("content-type")
|
|
||||||
if (contentType === "text/html")
|
|
||||||
throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)")
|
|
||||||
|
|
||||||
return response
|
|
||||||
})
|
|
||||||
client.interceptors.error.use(wrapClientError)
|
|
||||||
return new OpencodeClient({ client })
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
import type { Part, UserMessage } from "./client.js"
|
|
||||||
|
|
||||||
export const message = {
|
|
||||||
user(input: Omit<UserMessage, "role" | "time" | "id"> & { parts: Omit<Part, "id" | "sessionID" | "messageID">[] }): {
|
|
||||||
info: UserMessage
|
|
||||||
parts: Part[]
|
|
||||||
} {
|
|
||||||
const { parts: _parts, ...rest } = input
|
|
||||||
|
|
||||||
const info: UserMessage = {
|
|
||||||
...rest,
|
|
||||||
id: "asdasd",
|
|
||||||
time: {
|
|
||||||
created: Date.now(),
|
|
||||||
},
|
|
||||||
role: "user",
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
info,
|
|
||||||
parts: input.parts.map(
|
|
||||||
(part) =>
|
|
||||||
({
|
|
||||||
...part,
|
|
||||||
id: "asdasd",
|
|
||||||
messageID: info.id,
|
|
||||||
sessionID: info.sessionID,
|
|
||||||
}) as Part,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import { type ClientOptions, type Config, createClient, createConfig } from "./client/index.js"
|
|
||||||
import type { ClientOptions as ClientOptions2 } from "./types.gen.js"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The `createClientConfig()` function will be called on client initialization
|
|
||||||
* and the returned object will become the client's initial configuration.
|
|
||||||
*
|
|
||||||
* You may want to initialize your client this way instead of calling
|
|
||||||
* `setConfig()`. This is useful for example if you're using Next.js
|
|
||||||
* to ensure your client always has the correct values.
|
|
||||||
*/
|
|
||||||
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (
|
|
||||||
override?: Config<ClientOptions & T>,
|
|
||||||
) => Config<Required<ClientOptions> & T>
|
|
||||||
|
|
||||||
export const client = createClient(createConfig<ClientOptions2>({ baseUrl: "http://localhost:4096" }))
|
|
||||||
|
|
@ -1,285 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import { createSseClient } from "../core/serverSentEvents.gen.js"
|
|
||||||
import type { HttpMethod } from "../core/types.gen.js"
|
|
||||||
import { getValidRequestBody } from "../core/utils.gen.js"
|
|
||||||
import type { Client, Config, RequestOptions, ResolvedRequestOptions } from "./types.gen.js"
|
|
||||||
import {
|
|
||||||
buildUrl,
|
|
||||||
createConfig,
|
|
||||||
createInterceptors,
|
|
||||||
getParseAs,
|
|
||||||
mergeConfigs,
|
|
||||||
mergeHeaders,
|
|
||||||
setAuthParams,
|
|
||||||
} from "./utils.gen.js"
|
|
||||||
|
|
||||||
type ReqInit = Omit<RequestInit, "body" | "headers"> & {
|
|
||||||
body?: any
|
|
||||||
headers: ReturnType<typeof mergeHeaders>
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createClient = (config: Config = {}): Client => {
|
|
||||||
let _config = mergeConfigs(createConfig(), config)
|
|
||||||
|
|
||||||
const getConfig = (): Config => ({ ..._config })
|
|
||||||
|
|
||||||
const setConfig = (config: Config): Config => {
|
|
||||||
_config = mergeConfigs(_config, config)
|
|
||||||
return getConfig()
|
|
||||||
}
|
|
||||||
|
|
||||||
const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>()
|
|
||||||
|
|
||||||
const beforeRequest = async (options: RequestOptions) => {
|
|
||||||
const opts = {
|
|
||||||
..._config,
|
|
||||||
...options,
|
|
||||||
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
||||||
headers: mergeHeaders(_config.headers, options.headers),
|
|
||||||
serializedBody: undefined,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.security) {
|
|
||||||
await setAuthParams({
|
|
||||||
...opts,
|
|
||||||
security: opts.security,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.requestValidator) {
|
|
||||||
await opts.requestValidator(opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.body !== undefined && opts.bodySerializer) {
|
|
||||||
opts.serializedBody = opts.bodySerializer(opts.body)
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
||||||
if (opts.body === undefined || opts.serializedBody === "") {
|
|
||||||
opts.headers.delete("Content-Type")
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = buildUrl(opts)
|
|
||||||
|
|
||||||
return { opts, url }
|
|
||||||
}
|
|
||||||
|
|
||||||
const request: Client["request"] = async (options) => {
|
|
||||||
// @ts-expect-error
|
|
||||||
const { opts, url } = await beforeRequest(options)
|
|
||||||
const requestInit: ReqInit = {
|
|
||||||
redirect: "follow",
|
|
||||||
...opts,
|
|
||||||
body: getValidRequestBody(opts),
|
|
||||||
}
|
|
||||||
|
|
||||||
let request = new Request(url, requestInit)
|
|
||||||
|
|
||||||
for (const fn of interceptors.request.fns) {
|
|
||||||
if (fn) {
|
|
||||||
request = await fn(request, opts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// fetch must be assigned here, otherwise it would throw the error:
|
|
||||||
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
||||||
const _fetch = opts.fetch!
|
|
||||||
let response: Response
|
|
||||||
|
|
||||||
try {
|
|
||||||
response = await _fetch(request)
|
|
||||||
} catch (error) {
|
|
||||||
// Handle fetch exceptions (AbortError, network errors, etc.)
|
|
||||||
let finalError = error
|
|
||||||
|
|
||||||
for (const fn of interceptors.error.fns) {
|
|
||||||
if (fn) {
|
|
||||||
finalError = (await fn(error, undefined as any, request, opts)) as unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
finalError = finalError || ({} as unknown)
|
|
||||||
|
|
||||||
if (opts.throwOnError) {
|
|
||||||
throw finalError
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return error response
|
|
||||||
return opts.responseStyle === "data"
|
|
||||||
? undefined
|
|
||||||
: {
|
|
||||||
error: finalError,
|
|
||||||
request,
|
|
||||||
response: undefined as any,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const fn of interceptors.response.fns) {
|
|
||||||
if (fn) {
|
|
||||||
response = await fn(response, request, opts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = {
|
|
||||||
request,
|
|
||||||
response,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
const parseAs =
|
|
||||||
(opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json"
|
|
||||||
|
|
||||||
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
||||||
let emptyData: any
|
|
||||||
switch (parseAs) {
|
|
||||||
case "arrayBuffer":
|
|
||||||
case "blob":
|
|
||||||
case "text":
|
|
||||||
emptyData = await response[parseAs]()
|
|
||||||
break
|
|
||||||
case "formData":
|
|
||||||
emptyData = new FormData()
|
|
||||||
break
|
|
||||||
case "stream":
|
|
||||||
emptyData = response.body
|
|
||||||
break
|
|
||||||
case "json":
|
|
||||||
default:
|
|
||||||
emptyData = {}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
return opts.responseStyle === "data"
|
|
||||||
? emptyData
|
|
||||||
: {
|
|
||||||
data: emptyData,
|
|
||||||
...result,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let data: any
|
|
||||||
switch (parseAs) {
|
|
||||||
case "arrayBuffer":
|
|
||||||
case "blob":
|
|
||||||
case "formData":
|
|
||||||
case "text":
|
|
||||||
data = await response[parseAs]()
|
|
||||||
break
|
|
||||||
case "json": {
|
|
||||||
// Some servers return 200 with no Content-Length and empty body.
|
|
||||||
// response.json() would throw; read as text and parse if non-empty.
|
|
||||||
const text = await response.text()
|
|
||||||
data = text ? JSON.parse(text) : {}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case "stream":
|
|
||||||
return opts.responseStyle === "data"
|
|
||||||
? response.body
|
|
||||||
: {
|
|
||||||
data: response.body,
|
|
||||||
...result,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parseAs === "json") {
|
|
||||||
if (opts.responseValidator) {
|
|
||||||
await opts.responseValidator(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.responseTransformer) {
|
|
||||||
data = await opts.responseTransformer(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return opts.responseStyle === "data"
|
|
||||||
? data
|
|
||||||
: {
|
|
||||||
data,
|
|
||||||
...result,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const textError = await response.text()
|
|
||||||
let jsonError: unknown
|
|
||||||
|
|
||||||
try {
|
|
||||||
jsonError = JSON.parse(textError)
|
|
||||||
} catch {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
|
|
||||||
const error = jsonError ?? textError
|
|
||||||
let finalError = error
|
|
||||||
|
|
||||||
for (const fn of interceptors.error.fns) {
|
|
||||||
if (fn) {
|
|
||||||
finalError = (await fn(error, response, request, opts)) as string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
finalError = finalError || ({} as string)
|
|
||||||
|
|
||||||
if (opts.throwOnError) {
|
|
||||||
throw finalError
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: we probably want to return error and improve types
|
|
||||||
return opts.responseStyle === "data"
|
|
||||||
? undefined
|
|
||||||
: {
|
|
||||||
error: finalError,
|
|
||||||
...result,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) => request({ ...options, method })
|
|
||||||
|
|
||||||
const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
|
|
||||||
const { opts, url } = await beforeRequest(options)
|
|
||||||
return createSseClient({
|
|
||||||
...opts,
|
|
||||||
body: opts.body as BodyInit | null | undefined,
|
|
||||||
headers: opts.headers as unknown as Record<string, string>,
|
|
||||||
method,
|
|
||||||
onRequest: async (url, init) => {
|
|
||||||
let request = new Request(url, init)
|
|
||||||
for (const fn of interceptors.request.fns) {
|
|
||||||
if (fn) {
|
|
||||||
request = await fn(request, opts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return request
|
|
||||||
},
|
|
||||||
serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined,
|
|
||||||
url,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
buildUrl,
|
|
||||||
connect: makeMethodFn("CONNECT"),
|
|
||||||
delete: makeMethodFn("DELETE"),
|
|
||||||
get: makeMethodFn("GET"),
|
|
||||||
getConfig,
|
|
||||||
head: makeMethodFn("HEAD"),
|
|
||||||
interceptors,
|
|
||||||
options: makeMethodFn("OPTIONS"),
|
|
||||||
patch: makeMethodFn("PATCH"),
|
|
||||||
post: makeMethodFn("POST"),
|
|
||||||
put: makeMethodFn("PUT"),
|
|
||||||
request,
|
|
||||||
setConfig,
|
|
||||||
sse: {
|
|
||||||
connect: makeSseFn("CONNECT"),
|
|
||||||
delete: makeSseFn("DELETE"),
|
|
||||||
get: makeSseFn("GET"),
|
|
||||||
head: makeSseFn("HEAD"),
|
|
||||||
options: makeSseFn("OPTIONS"),
|
|
||||||
patch: makeSseFn("PATCH"),
|
|
||||||
post: makeSseFn("POST"),
|
|
||||||
put: makeSseFn("PUT"),
|
|
||||||
trace: makeSseFn("TRACE"),
|
|
||||||
},
|
|
||||||
trace: makeMethodFn("TRACE"),
|
|
||||||
} as Client
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
export type { Auth } from "../core/auth.gen.js"
|
|
||||||
export type { QuerySerializerOptions } from "../core/bodySerializer.gen.js"
|
|
||||||
export {
|
|
||||||
formDataBodySerializer,
|
|
||||||
jsonBodySerializer,
|
|
||||||
urlSearchParamsBodySerializer,
|
|
||||||
} from "../core/bodySerializer.gen.js"
|
|
||||||
export { buildClientParams } from "../core/params.gen.js"
|
|
||||||
export { serializeQueryKeyValue } from "../core/queryKeySerializer.gen.js"
|
|
||||||
export { createClient } from "./client.gen.js"
|
|
||||||
export type {
|
|
||||||
Client,
|
|
||||||
ClientOptions,
|
|
||||||
Config,
|
|
||||||
CreateClientConfig,
|
|
||||||
Options,
|
|
||||||
RequestOptions,
|
|
||||||
RequestResult,
|
|
||||||
ResolvedRequestOptions,
|
|
||||||
ResponseStyle,
|
|
||||||
TDataShape,
|
|
||||||
} from "./types.gen.js"
|
|
||||||
export { createConfig, mergeHeaders } from "./utils.gen.js"
|
|
||||||
|
|
@ -1,202 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { Auth } from "../core/auth.gen.js"
|
|
||||||
import type { ServerSentEventsOptions, ServerSentEventsResult } from "../core/serverSentEvents.gen.js"
|
|
||||||
import type { Client as CoreClient, Config as CoreConfig } from "../core/types.gen.js"
|
|
||||||
import type { Middleware } from "./utils.gen.js"
|
|
||||||
|
|
||||||
export type ResponseStyle = "data" | "fields"
|
|
||||||
|
|
||||||
export interface Config<T extends ClientOptions = ClientOptions>
|
|
||||||
extends Omit<RequestInit, "body" | "headers" | "method">,
|
|
||||||
CoreConfig {
|
|
||||||
/**
|
|
||||||
* Base URL for all requests made by this client.
|
|
||||||
*/
|
|
||||||
baseUrl?: T["baseUrl"]
|
|
||||||
/**
|
|
||||||
* Fetch API implementation. You can use this option to provide a custom
|
|
||||||
* fetch instance.
|
|
||||||
*
|
|
||||||
* @default globalThis.fetch
|
|
||||||
*/
|
|
||||||
fetch?: typeof fetch
|
|
||||||
/**
|
|
||||||
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
||||||
* options won't have any effect.
|
|
||||||
*
|
|
||||||
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
|
|
||||||
*/
|
|
||||||
next?: never
|
|
||||||
/**
|
|
||||||
* Return the response data parsed in a specified format. By default, `auto`
|
|
||||||
* will infer the appropriate method from the `Content-Type` response header.
|
|
||||||
* You can override this behavior with any of the {@link Body} methods.
|
|
||||||
* Select `stream` if you don't want to parse response data at all.
|
|
||||||
*
|
|
||||||
* @default 'auto'
|
|
||||||
*/
|
|
||||||
parseAs?: "arrayBuffer" | "auto" | "blob" | "formData" | "json" | "stream" | "text"
|
|
||||||
/**
|
|
||||||
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
||||||
*
|
|
||||||
* @default 'fields'
|
|
||||||
*/
|
|
||||||
responseStyle?: ResponseStyle
|
|
||||||
/**
|
|
||||||
* Throw an error instead of returning it in the response?
|
|
||||||
*
|
|
||||||
* @default false
|
|
||||||
*/
|
|
||||||
throwOnError?: T["throwOnError"]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RequestOptions<
|
|
||||||
TData = unknown,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
Url extends string = string,
|
|
||||||
> extends Config<{
|
|
||||||
responseStyle: TResponseStyle
|
|
||||||
throwOnError: ThrowOnError
|
|
||||||
}>,
|
|
||||||
Pick<
|
|
||||||
ServerSentEventsOptions<TData>,
|
|
||||||
"onSseError" | "onSseEvent" | "sseDefaultRetryDelay" | "sseMaxRetryAttempts" | "sseMaxRetryDelay"
|
|
||||||
> {
|
|
||||||
/**
|
|
||||||
* Any body that you want to add to your request.
|
|
||||||
*
|
|
||||||
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
||||||
*/
|
|
||||||
body?: unknown
|
|
||||||
path?: Record<string, unknown>
|
|
||||||
query?: Record<string, unknown>
|
|
||||||
/**
|
|
||||||
* Security mechanism(s) to use for the request.
|
|
||||||
*/
|
|
||||||
security?: ReadonlyArray<Auth>
|
|
||||||
url: Url
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ResolvedRequestOptions<
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
Url extends string = string,
|
|
||||||
> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
||||||
serializedBody?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type RequestResult<
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
> = ThrowOnError extends true
|
|
||||||
? Promise<
|
|
||||||
TResponseStyle extends "data"
|
|
||||||
? TData extends Record<string, unknown>
|
|
||||||
? TData[keyof TData]
|
|
||||||
: TData
|
|
||||||
: {
|
|
||||||
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData
|
|
||||||
request: Request
|
|
||||||
response: Response
|
|
||||||
}
|
|
||||||
>
|
|
||||||
: Promise<
|
|
||||||
TResponseStyle extends "data"
|
|
||||||
? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined
|
|
||||||
: (
|
|
||||||
| {
|
|
||||||
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData
|
|
||||||
error: undefined
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
data: undefined
|
|
||||||
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError
|
|
||||||
}
|
|
||||||
) & {
|
|
||||||
request: Request
|
|
||||||
response: Response
|
|
||||||
}
|
|
||||||
>
|
|
||||||
|
|
||||||
export interface ClientOptions {
|
|
||||||
baseUrl?: string
|
|
||||||
responseStyle?: ResponseStyle
|
|
||||||
throwOnError?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
type MethodFn = <
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
>(
|
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">,
|
|
||||||
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>
|
|
||||||
|
|
||||||
type SseFn = <
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
>(
|
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">,
|
|
||||||
) => Promise<ServerSentEventsResult<TData>>
|
|
||||||
|
|
||||||
type RequestFn = <
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
>(
|
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method"> &
|
|
||||||
Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, "method">,
|
|
||||||
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>
|
|
||||||
|
|
||||||
type BuildUrlFn = <
|
|
||||||
TData extends {
|
|
||||||
body?: unknown
|
|
||||||
path?: Record<string, unknown>
|
|
||||||
query?: Record<string, unknown>
|
|
||||||
url: string
|
|
||||||
},
|
|
||||||
>(
|
|
||||||
options: TData & Options<TData>,
|
|
||||||
) => string
|
|
||||||
|
|
||||||
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
||||||
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The `createClientConfig()` function will be called on client initialization
|
|
||||||
* and the returned object will become the client's initial configuration.
|
|
||||||
*
|
|
||||||
* You may want to initialize your client this way instead of calling
|
|
||||||
* `setConfig()`. This is useful for example if you're using Next.js
|
|
||||||
* to ensure your client always has the correct values.
|
|
||||||
*/
|
|
||||||
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
|
||||||
override?: Config<ClientOptions & T>,
|
|
||||||
) => Config<Required<ClientOptions> & T>
|
|
||||||
|
|
||||||
export interface TDataShape {
|
|
||||||
body?: unknown
|
|
||||||
headers?: unknown
|
|
||||||
path?: unknown
|
|
||||||
query?: unknown
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>
|
|
||||||
|
|
||||||
export type Options<
|
|
||||||
TData extends TDataShape = TDataShape,
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
TResponse = unknown,
|
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
|
||||||
> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, "body" | "path" | "query" | "url"> &
|
|
||||||
([TData] extends [never] ? unknown : Omit<TData, "url">)
|
|
||||||
|
|
@ -1,294 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import { getAuthToken } from "../core/auth.gen.js"
|
|
||||||
import type { QuerySerializerOptions } from "../core/bodySerializer.gen.js"
|
|
||||||
import { jsonBodySerializer } from "../core/bodySerializer.gen.js"
|
|
||||||
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam } from "../core/pathSerializer.gen.js"
|
|
||||||
import { getUrl } from "../core/utils.gen.js"
|
|
||||||
import type { Client, ClientOptions, Config, RequestOptions } from "./types.gen.js"
|
|
||||||
|
|
||||||
export const createQuerySerializer = <T = unknown>({ parameters = {}, ...args }: QuerySerializerOptions = {}) => {
|
|
||||||
const querySerializer = (queryParams: T) => {
|
|
||||||
const search: string[] = []
|
|
||||||
if (queryParams && typeof queryParams === "object") {
|
|
||||||
for (const name in queryParams) {
|
|
||||||
const value = queryParams[name]
|
|
||||||
|
|
||||||
if (value === undefined) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value === null) {
|
|
||||||
search.push(`${name}=null`)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = parameters[name] || args
|
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
const serializedArray = serializeArrayParam({
|
|
||||||
allowReserved: options.allowReserved,
|
|
||||||
explode: true,
|
|
||||||
name,
|
|
||||||
style: "form",
|
|
||||||
value,
|
|
||||||
...options.array,
|
|
||||||
})
|
|
||||||
if (serializedArray) search.push(serializedArray)
|
|
||||||
} else if (typeof value === "object") {
|
|
||||||
const serializedObject = serializeObjectParam({
|
|
||||||
allowReserved: options.allowReserved,
|
|
||||||
explode: true,
|
|
||||||
name,
|
|
||||||
style: "deepObject",
|
|
||||||
value: value as Record<string, unknown>,
|
|
||||||
...options.object,
|
|
||||||
})
|
|
||||||
if (serializedObject) search.push(serializedObject)
|
|
||||||
} else {
|
|
||||||
const serializedPrimitive = serializePrimitiveParam({
|
|
||||||
allowReserved: options.allowReserved,
|
|
||||||
name,
|
|
||||||
value: value as string,
|
|
||||||
})
|
|
||||||
if (serializedPrimitive) search.push(serializedPrimitive)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return search.join("&")
|
|
||||||
}
|
|
||||||
return querySerializer
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Infers parseAs value from provided Content-Type header.
|
|
||||||
*/
|
|
||||||
export const getParseAs = (contentType: string | null): Exclude<Config["parseAs"], "auto"> => {
|
|
||||||
if (!contentType) {
|
|
||||||
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
||||||
// which is effectively the same as the 'stream' option.
|
|
||||||
return "stream"
|
|
||||||
}
|
|
||||||
|
|
||||||
const cleanContent = contentType.split(";")[0]?.trim()
|
|
||||||
|
|
||||||
if (!cleanContent) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
||||||
return "json"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cleanContent === "multipart/form-data") {
|
|
||||||
return "formData"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
||||||
return "blob"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cleanContent.startsWith("text/")) {
|
|
||||||
return "text"
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const checkForExistence = (
|
|
||||||
options: Pick<RequestOptions, "auth" | "query"> & {
|
|
||||||
headers: Headers
|
|
||||||
},
|
|
||||||
name?: string,
|
|
||||||
): boolean => {
|
|
||||||
if (!name) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
export const setAuthParams = async ({
|
|
||||||
security,
|
|
||||||
...options
|
|
||||||
}: Pick<Required<RequestOptions>, "security"> &
|
|
||||||
Pick<RequestOptions, "auth" | "query"> & {
|
|
||||||
headers: Headers
|
|
||||||
}) => {
|
|
||||||
for (const auth of security) {
|
|
||||||
if (checkForExistence(options, auth.name)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = await getAuthToken(auth, options.auth)
|
|
||||||
|
|
||||||
if (!token) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const name = auth.name ?? "Authorization"
|
|
||||||
|
|
||||||
switch (auth.in) {
|
|
||||||
case "query":
|
|
||||||
if (!options.query) {
|
|
||||||
options.query = {}
|
|
||||||
}
|
|
||||||
options.query[name] = token
|
|
||||||
break
|
|
||||||
case "cookie":
|
|
||||||
options.headers.append("Cookie", `${name}=${token}`)
|
|
||||||
break
|
|
||||||
case "header":
|
|
||||||
default:
|
|
||||||
options.headers.set(name, token)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const buildUrl: Client["buildUrl"] = (options) =>
|
|
||||||
getUrl({
|
|
||||||
baseUrl: options.baseUrl as string,
|
|
||||||
path: options.path,
|
|
||||||
query: options.query,
|
|
||||||
querySerializer:
|
|
||||||
typeof options.querySerializer === "function"
|
|
||||||
? options.querySerializer
|
|
||||||
: createQuerySerializer(options.querySerializer),
|
|
||||||
url: options.url,
|
|
||||||
})
|
|
||||||
|
|
||||||
export const mergeConfigs = (a: Config, b: Config): Config => {
|
|
||||||
const config = { ...a, ...b }
|
|
||||||
if (config.baseUrl?.endsWith("/")) {
|
|
||||||
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1)
|
|
||||||
}
|
|
||||||
config.headers = mergeHeaders(a.headers, b.headers)
|
|
||||||
return config
|
|
||||||
}
|
|
||||||
|
|
||||||
const headersEntries = (headers: Headers): Array<[string, string]> => {
|
|
||||||
const entries: Array<[string, string]> = []
|
|
||||||
headers.forEach((value, key) => {
|
|
||||||
entries.push([key, value])
|
|
||||||
})
|
|
||||||
return entries
|
|
||||||
}
|
|
||||||
|
|
||||||
export const mergeHeaders = (...headers: Array<Required<Config>["headers"] | undefined>): Headers => {
|
|
||||||
const mergedHeaders = new Headers()
|
|
||||||
for (const header of headers) {
|
|
||||||
if (!header) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header)
|
|
||||||
|
|
||||||
for (const [key, value] of iterator) {
|
|
||||||
if (value === null) {
|
|
||||||
mergedHeaders.delete(key)
|
|
||||||
} else if (Array.isArray(value)) {
|
|
||||||
for (const v of value) {
|
|
||||||
mergedHeaders.append(key, v as string)
|
|
||||||
}
|
|
||||||
} else if (value !== undefined) {
|
|
||||||
// assume object headers are meant to be JSON stringified, i.e. their
|
|
||||||
// content value in OpenAPI specification is 'application/json'
|
|
||||||
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : (value as string))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mergedHeaders
|
|
||||||
}
|
|
||||||
|
|
||||||
type ErrInterceptor<Err, Res, Req, Options> = (
|
|
||||||
error: Err,
|
|
||||||
response: Res,
|
|
||||||
request: Req,
|
|
||||||
options: Options,
|
|
||||||
) => Err | Promise<Err>
|
|
||||||
|
|
||||||
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>
|
|
||||||
|
|
||||||
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>
|
|
||||||
|
|
||||||
class Interceptors<Interceptor> {
|
|
||||||
fns: Array<Interceptor | null> = []
|
|
||||||
|
|
||||||
clear(): void {
|
|
||||||
this.fns = []
|
|
||||||
}
|
|
||||||
|
|
||||||
eject(id: number | Interceptor): void {
|
|
||||||
const index = this.getInterceptorIndex(id)
|
|
||||||
if (this.fns[index]) {
|
|
||||||
this.fns[index] = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exists(id: number | Interceptor): boolean {
|
|
||||||
const index = this.getInterceptorIndex(id)
|
|
||||||
return Boolean(this.fns[index])
|
|
||||||
}
|
|
||||||
|
|
||||||
getInterceptorIndex(id: number | Interceptor): number {
|
|
||||||
if (typeof id === "number") {
|
|
||||||
return this.fns[id] ? id : -1
|
|
||||||
}
|
|
||||||
return this.fns.indexOf(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false {
|
|
||||||
const index = this.getInterceptorIndex(id)
|
|
||||||
if (this.fns[index]) {
|
|
||||||
this.fns[index] = fn
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
use(fn: Interceptor): number {
|
|
||||||
this.fns.push(fn)
|
|
||||||
return this.fns.length - 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Middleware<Req, Res, Err, Options> {
|
|
||||||
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>
|
|
||||||
request: Interceptors<ReqInterceptor<Req, Options>>
|
|
||||||
response: Interceptors<ResInterceptor<Res, Req, Options>>
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createInterceptors = <Req, Res, Err, Options>(): Middleware<Req, Res, Err, Options> => ({
|
|
||||||
error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(),
|
|
||||||
request: new Interceptors<ReqInterceptor<Req, Options>>(),
|
|
||||||
response: new Interceptors<ResInterceptor<Res, Req, Options>>(),
|
|
||||||
})
|
|
||||||
|
|
||||||
const defaultQuerySerializer = createQuerySerializer({
|
|
||||||
allowReserved: false,
|
|
||||||
array: {
|
|
||||||
explode: true,
|
|
||||||
style: "form",
|
|
||||||
},
|
|
||||||
object: {
|
|
||||||
explode: true,
|
|
||||||
style: "deepObject",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const defaultHeaders = {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
|
||||||
override: Config<Omit<ClientOptions, keyof T> & T> = {},
|
|
||||||
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
|
||||||
...jsonBodySerializer,
|
|
||||||
headers: defaultHeaders,
|
|
||||||
parseAs: "auto",
|
|
||||||
querySerializer: defaultQuerySerializer,
|
|
||||||
...override,
|
|
||||||
})
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
export type AuthToken = string | undefined
|
|
||||||
|
|
||||||
export interface Auth {
|
|
||||||
/**
|
|
||||||
* Which part of the request do we use to send the auth?
|
|
||||||
*
|
|
||||||
* @default 'header'
|
|
||||||
*/
|
|
||||||
in?: "header" | "query" | "cookie"
|
|
||||||
/**
|
|
||||||
* Header or query parameter name.
|
|
||||||
*
|
|
||||||
* @default 'Authorization'
|
|
||||||
*/
|
|
||||||
name?: string
|
|
||||||
scheme?: "basic" | "bearer"
|
|
||||||
type: "apiKey" | "http"
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getAuthToken = async (
|
|
||||||
auth: Auth,
|
|
||||||
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
|
||||||
): Promise<string | undefined> => {
|
|
||||||
const token = typeof callback === "function" ? await callback(auth) : callback
|
|
||||||
|
|
||||||
if (!token) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auth.scheme === "bearer") {
|
|
||||||
return `Bearer ${token}`
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auth.scheme === "basic") {
|
|
||||||
return `Basic ${btoa(token)}`
|
|
||||||
}
|
|
||||||
|
|
||||||
return token
|
|
||||||
}
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { ArrayStyle, ObjectStyle, SerializerOptions } from "./pathSerializer.gen.js"
|
|
||||||
|
|
||||||
export type QuerySerializer = (query: Record<string, unknown>) => string
|
|
||||||
|
|
||||||
export type BodySerializer = (body: any) => any
|
|
||||||
|
|
||||||
type QuerySerializerOptionsObject = {
|
|
||||||
allowReserved?: boolean
|
|
||||||
array?: Partial<SerializerOptions<ArrayStyle>>
|
|
||||||
object?: Partial<SerializerOptions<ObjectStyle>>
|
|
||||||
}
|
|
||||||
|
|
||||||
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
||||||
/**
|
|
||||||
* Per-parameter serialization overrides. When provided, these settings
|
|
||||||
* override the global array/object settings for specific parameter names.
|
|
||||||
*/
|
|
||||||
parameters?: Record<string, QuerySerializerOptionsObject>
|
|
||||||
}
|
|
||||||
|
|
||||||
const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => {
|
|
||||||
if (typeof value === "string" || value instanceof Blob) {
|
|
||||||
data.append(key, value)
|
|
||||||
} else if (value instanceof Date) {
|
|
||||||
data.append(key, value.toISOString())
|
|
||||||
} else {
|
|
||||||
data.append(key, JSON.stringify(value))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => {
|
|
||||||
if (typeof value === "string") {
|
|
||||||
data.append(key, value)
|
|
||||||
} else {
|
|
||||||
data.append(key, JSON.stringify(value))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const formDataBodySerializer = {
|
|
||||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): FormData => {
|
|
||||||
const data = new FormData()
|
|
||||||
|
|
||||||
Object.entries(body).forEach(([key, value]) => {
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
value.forEach((v) => serializeFormDataPair(data, key, v))
|
|
||||||
} else {
|
|
||||||
serializeFormDataPair(data, key, value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return data
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export const jsonBodySerializer = {
|
|
||||||
bodySerializer: <T>(body: T): string =>
|
|
||||||
JSON.stringify(body, (_key, value) => (typeof value === "bigint" ? value.toString() : value)),
|
|
||||||
}
|
|
||||||
|
|
||||||
export const urlSearchParamsBodySerializer = {
|
|
||||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): string => {
|
|
||||||
const data = new URLSearchParams()
|
|
||||||
|
|
||||||
Object.entries(body).forEach(([key, value]) => {
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v))
|
|
||||||
} else {
|
|
||||||
serializeUrlSearchParamsPair(data, key, value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return data.toString()
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -1,169 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
type Slot = "body" | "headers" | "path" | "query"
|
|
||||||
|
|
||||||
export type Field =
|
|
||||||
| {
|
|
||||||
in: Exclude<Slot, "body">
|
|
||||||
/**
|
|
||||||
* Field name. This is the name we want the user to see and use.
|
|
||||||
*/
|
|
||||||
key: string
|
|
||||||
/**
|
|
||||||
* Field mapped name. This is the name we want to use in the request.
|
|
||||||
* If omitted, we use the same value as `key`.
|
|
||||||
*/
|
|
||||||
map?: string
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
in: Extract<Slot, "body">
|
|
||||||
/**
|
|
||||||
* Key isn't required for bodies.
|
|
||||||
*/
|
|
||||||
key?: string
|
|
||||||
map?: string
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
/**
|
|
||||||
* Field name. This is the name we want the user to see and use.
|
|
||||||
*/
|
|
||||||
key: string
|
|
||||||
/**
|
|
||||||
* Field mapped name. This is the name we want to use in the request.
|
|
||||||
* If `in` is omitted, `map` aliases `key` to the transport layer.
|
|
||||||
*/
|
|
||||||
map: Slot
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Fields {
|
|
||||||
allowExtra?: Partial<Record<Slot, boolean>>
|
|
||||||
args?: ReadonlyArray<Field>
|
|
||||||
}
|
|
||||||
|
|
||||||
export type FieldsConfig = ReadonlyArray<Field | Fields>
|
|
||||||
|
|
||||||
const extraPrefixesMap: Record<string, Slot> = {
|
|
||||||
$body_: "body",
|
|
||||||
$headers_: "headers",
|
|
||||||
$path_: "path",
|
|
||||||
$query_: "query",
|
|
||||||
}
|
|
||||||
const extraPrefixes = Object.entries(extraPrefixesMap)
|
|
||||||
|
|
||||||
type KeyMap = Map<
|
|
||||||
string,
|
|
||||||
| {
|
|
||||||
in: Slot
|
|
||||||
map?: string
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
in?: never
|
|
||||||
map: Slot
|
|
||||||
}
|
|
||||||
>
|
|
||||||
|
|
||||||
const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
|
|
||||||
if (!map) {
|
|
||||||
map = new Map()
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const config of fields) {
|
|
||||||
if ("in" in config) {
|
|
||||||
if (config.key) {
|
|
||||||
map.set(config.key, {
|
|
||||||
in: config.in,
|
|
||||||
map: config.map,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else if ("key" in config) {
|
|
||||||
map.set(config.key, {
|
|
||||||
map: config.map,
|
|
||||||
})
|
|
||||||
} else if (config.args) {
|
|
||||||
buildKeyMap(config.args, map)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return map
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Params {
|
|
||||||
body: unknown
|
|
||||||
headers: Record<string, unknown>
|
|
||||||
path: Record<string, unknown>
|
|
||||||
query: Record<string, unknown>
|
|
||||||
}
|
|
||||||
|
|
||||||
const stripEmptySlots = (params: Params) => {
|
|
||||||
for (const [slot, value] of Object.entries(params)) {
|
|
||||||
if (value && typeof value === "object" && !Object.keys(value).length) {
|
|
||||||
delete params[slot as Slot]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsConfig) => {
|
|
||||||
const params: Params = {
|
|
||||||
body: {},
|
|
||||||
headers: {},
|
|
||||||
path: {},
|
|
||||||
query: {},
|
|
||||||
}
|
|
||||||
|
|
||||||
const map = buildKeyMap(fields)
|
|
||||||
|
|
||||||
let config: FieldsConfig[number] | undefined
|
|
||||||
|
|
||||||
for (const [index, arg] of args.entries()) {
|
|
||||||
if (fields[index]) {
|
|
||||||
config = fields[index]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!config) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("in" in config) {
|
|
||||||
if (config.key) {
|
|
||||||
const field = map.get(config.key)!
|
|
||||||
const name = field.map || config.key
|
|
||||||
if (field.in) {
|
|
||||||
;(params[field.in] as Record<string, unknown>)[name] = arg
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
params.body = arg
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
||||||
const field = map.get(key)
|
|
||||||
|
|
||||||
if (field) {
|
|
||||||
if (field.in) {
|
|
||||||
const name = field.map || key
|
|
||||||
;(params[field.in] as Record<string, unknown>)[name] = value
|
|
||||||
} else {
|
|
||||||
params[field.map] = value
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix))
|
|
||||||
|
|
||||||
if (extra) {
|
|
||||||
const [prefix, slot] = extra
|
|
||||||
;(params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value
|
|
||||||
} else if ("allowExtra" in config && config.allowExtra) {
|
|
||||||
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
||||||
if (allowed) {
|
|
||||||
;(params[slot as Slot] as Record<string, unknown>)[key] = value
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stripEmptySlots(params)
|
|
||||||
|
|
||||||
return params
|
|
||||||
}
|
|
||||||
|
|
@ -1,167 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {}
|
|
||||||
|
|
||||||
interface SerializePrimitiveOptions {
|
|
||||||
allowReserved?: boolean
|
|
||||||
name: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SerializerOptions<T> {
|
|
||||||
/**
|
|
||||||
* @default true
|
|
||||||
*/
|
|
||||||
explode: boolean
|
|
||||||
style: T
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ArrayStyle = "form" | "spaceDelimited" | "pipeDelimited"
|
|
||||||
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle
|
|
||||||
type MatrixStyle = "label" | "matrix" | "simple"
|
|
||||||
export type ObjectStyle = "form" | "deepObject"
|
|
||||||
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle
|
|
||||||
|
|
||||||
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|
||||||
value: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
|
||||||
switch (style) {
|
|
||||||
case "label":
|
|
||||||
return "."
|
|
||||||
case "matrix":
|
|
||||||
return ";"
|
|
||||||
case "simple":
|
|
||||||
return ","
|
|
||||||
default:
|
|
||||||
return "&"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
|
||||||
switch (style) {
|
|
||||||
case "form":
|
|
||||||
return ","
|
|
||||||
case "pipeDelimited":
|
|
||||||
return "|"
|
|
||||||
case "spaceDelimited":
|
|
||||||
return "%20"
|
|
||||||
default:
|
|
||||||
return ","
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
|
|
||||||
switch (style) {
|
|
||||||
case "label":
|
|
||||||
return "."
|
|
||||||
case "matrix":
|
|
||||||
return ";"
|
|
||||||
case "simple":
|
|
||||||
return ","
|
|
||||||
default:
|
|
||||||
return "&"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const serializeArrayParam = ({
|
|
||||||
allowReserved,
|
|
||||||
explode,
|
|
||||||
name,
|
|
||||||
style,
|
|
||||||
value,
|
|
||||||
}: SerializeOptions<ArraySeparatorStyle> & {
|
|
||||||
value: unknown[]
|
|
||||||
}) => {
|
|
||||||
if (!explode) {
|
|
||||||
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v as string))).join(
|
|
||||||
separatorArrayNoExplode(style),
|
|
||||||
)
|
|
||||||
switch (style) {
|
|
||||||
case "label":
|
|
||||||
return `.${joinedValues}`
|
|
||||||
case "matrix":
|
|
||||||
return `;${name}=${joinedValues}`
|
|
||||||
case "simple":
|
|
||||||
return joinedValues
|
|
||||||
default:
|
|
||||||
return `${name}=${joinedValues}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const separator = separatorArrayExplode(style)
|
|
||||||
const joinedValues = value
|
|
||||||
.map((v) => {
|
|
||||||
if (style === "label" || style === "simple") {
|
|
||||||
return allowReserved ? v : encodeURIComponent(v as string)
|
|
||||||
}
|
|
||||||
|
|
||||||
return serializePrimitiveParam({
|
|
||||||
allowReserved,
|
|
||||||
name,
|
|
||||||
value: v as string,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.join(separator)
|
|
||||||
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues
|
|
||||||
}
|
|
||||||
|
|
||||||
export const serializePrimitiveParam = ({ allowReserved, name, value }: SerializePrimitiveParam) => {
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof value === "object") {
|
|
||||||
throw new Error(
|
|
||||||
"Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`
|
|
||||||
}
|
|
||||||
|
|
||||||
export const serializeObjectParam = ({
|
|
||||||
allowReserved,
|
|
||||||
explode,
|
|
||||||
name,
|
|
||||||
style,
|
|
||||||
value,
|
|
||||||
valueOnly,
|
|
||||||
}: SerializeOptions<ObjectSeparatorStyle> & {
|
|
||||||
value: Record<string, unknown> | Date
|
|
||||||
valueOnly?: boolean
|
|
||||||
}) => {
|
|
||||||
if (value instanceof Date) {
|
|
||||||
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style !== "deepObject" && !explode) {
|
|
||||||
let values: string[] = []
|
|
||||||
Object.entries(value).forEach(([key, v]) => {
|
|
||||||
values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)]
|
|
||||||
})
|
|
||||||
const joinedValues = values.join(",")
|
|
||||||
switch (style) {
|
|
||||||
case "form":
|
|
||||||
return `${name}=${joinedValues}`
|
|
||||||
case "label":
|
|
||||||
return `.${joinedValues}`
|
|
||||||
case "matrix":
|
|
||||||
return `;${name}=${joinedValues}`
|
|
||||||
default:
|
|
||||||
return joinedValues
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const separator = separatorObjectExplode(style)
|
|
||||||
const joinedValues = Object.entries(value)
|
|
||||||
.map(([key, v]) =>
|
|
||||||
serializePrimitiveParam({
|
|
||||||
allowReserved,
|
|
||||||
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
||||||
value: v as string,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.join(separator)
|
|
||||||
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues
|
|
||||||
}
|
|
||||||
|
|
@ -1,111 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON-friendly union that mirrors what Pinia Colada can hash.
|
|
||||||
*/
|
|
||||||
export type JsonValue = null | string | number | boolean | JsonValue[] | { [key: string]: JsonValue }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
||||||
*/
|
|
||||||
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
|
|
||||||
if (value === undefined || typeof value === "function" || typeof value === "symbol") {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
if (typeof value === "bigint") {
|
|
||||||
return value.toString()
|
|
||||||
}
|
|
||||||
if (value instanceof Date) {
|
|
||||||
return value.toISOString()
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Safely stringifies a value and parses it back into a JsonValue.
|
|
||||||
*/
|
|
||||||
export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => {
|
|
||||||
try {
|
|
||||||
const json = JSON.stringify(input, queryKeyJsonReplacer)
|
|
||||||
if (json === undefined) {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
return JSON.parse(json) as JsonValue
|
|
||||||
} catch {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Detects plain objects (including objects with a null prototype).
|
|
||||||
*/
|
|
||||||
const isPlainObject = (value: unknown): value is Record<string, unknown> => {
|
|
||||||
if (value === null || typeof value !== "object") {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const prototype = Object.getPrototypeOf(value as object)
|
|
||||||
return prototype === Object.prototype || prototype === null
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns URLSearchParams into a sorted JSON object for deterministic keys.
|
|
||||||
*/
|
|
||||||
const serializeSearchParams = (params: URLSearchParams): JsonValue => {
|
|
||||||
const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b))
|
|
||||||
const result: Record<string, JsonValue> = {}
|
|
||||||
|
|
||||||
for (const [key, value] of entries) {
|
|
||||||
const existing = result[key]
|
|
||||||
if (existing === undefined) {
|
|
||||||
result[key] = value
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(existing)) {
|
|
||||||
;(existing as string[]).push(value)
|
|
||||||
} else {
|
|
||||||
result[key] = [existing, value]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
|
||||||
*/
|
|
||||||
export const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => {
|
|
||||||
if (value === null) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value === undefined || typeof value === "function" || typeof value === "symbol") {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof value === "bigint") {
|
|
||||||
return value.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Date) {
|
|
||||||
return value.toISOString()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
return stringifyToJsonValue(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams) {
|
|
||||||
return serializeSearchParams(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPlainObject(value)) {
|
|
||||||
return stringifyToJsonValue(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
@ -1,239 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { Config } from "./types.gen.js"
|
|
||||||
|
|
||||||
export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, "method"> &
|
|
||||||
Pick<Config, "method" | "responseTransformer" | "responseValidator"> & {
|
|
||||||
/**
|
|
||||||
* Fetch API implementation. You can use this option to provide a custom
|
|
||||||
* fetch instance.
|
|
||||||
*
|
|
||||||
* @default globalThis.fetch
|
|
||||||
*/
|
|
||||||
fetch?: typeof fetch
|
|
||||||
/**
|
|
||||||
* Implementing clients can call request interceptors inside this hook.
|
|
||||||
*/
|
|
||||||
onRequest?: (url: string, init: RequestInit) => Promise<Request>
|
|
||||||
/**
|
|
||||||
* Callback invoked when a network or parsing error occurs during streaming.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @param error The error that occurred.
|
|
||||||
*/
|
|
||||||
onSseError?: (error: unknown) => void
|
|
||||||
/**
|
|
||||||
* Callback invoked when an event is streamed from the server.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @param event Event streamed from the server.
|
|
||||||
* @returns Nothing (void).
|
|
||||||
*/
|
|
||||||
onSseEvent?: (event: StreamEvent<TData>) => void
|
|
||||||
serializedBody?: RequestInit["body"]
|
|
||||||
/**
|
|
||||||
* Default retry delay in milliseconds.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @default 3000
|
|
||||||
*/
|
|
||||||
sseDefaultRetryDelay?: number
|
|
||||||
/**
|
|
||||||
* Maximum number of retry attempts before giving up.
|
|
||||||
*/
|
|
||||||
sseMaxRetryAttempts?: number
|
|
||||||
/**
|
|
||||||
* Maximum retry delay in milliseconds.
|
|
||||||
*
|
|
||||||
* Applies only when exponential backoff is used.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @default 30000
|
|
||||||
*/
|
|
||||||
sseMaxRetryDelay?: number
|
|
||||||
/**
|
|
||||||
* Optional sleep function for retry backoff.
|
|
||||||
*
|
|
||||||
* Defaults to using `setTimeout`.
|
|
||||||
*/
|
|
||||||
sseSleepFn?: (ms: number) => Promise<void>
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface StreamEvent<TData = unknown> {
|
|
||||||
data: TData
|
|
||||||
event?: string
|
|
||||||
id?: string
|
|
||||||
retry?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
|
|
||||||
stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createSseClient = <TData = unknown>({
|
|
||||||
onRequest,
|
|
||||||
onSseError,
|
|
||||||
onSseEvent,
|
|
||||||
responseTransformer,
|
|
||||||
responseValidator,
|
|
||||||
sseDefaultRetryDelay,
|
|
||||||
sseMaxRetryAttempts,
|
|
||||||
sseMaxRetryDelay,
|
|
||||||
sseSleepFn,
|
|
||||||
url,
|
|
||||||
...options
|
|
||||||
}: ServerSentEventsOptions): ServerSentEventsResult<TData> => {
|
|
||||||
let lastEventId: string | undefined
|
|
||||||
|
|
||||||
const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms)))
|
|
||||||
|
|
||||||
const createStream = async function* () {
|
|
||||||
let retryDelay: number = sseDefaultRetryDelay ?? 3000
|
|
||||||
let attempt = 0
|
|
||||||
const signal = options.signal ?? new AbortController().signal
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
if (signal.aborted) break
|
|
||||||
|
|
||||||
attempt++
|
|
||||||
|
|
||||||
const headers =
|
|
||||||
options.headers instanceof Headers
|
|
||||||
? options.headers
|
|
||||||
: new Headers(options.headers as Record<string, string> | undefined)
|
|
||||||
|
|
||||||
if (lastEventId !== undefined) {
|
|
||||||
headers.set("Last-Event-ID", lastEventId)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const requestInit: RequestInit = {
|
|
||||||
redirect: "follow",
|
|
||||||
...options,
|
|
||||||
body: options.serializedBody,
|
|
||||||
headers,
|
|
||||||
signal,
|
|
||||||
}
|
|
||||||
let request = new Request(url, requestInit)
|
|
||||||
if (onRequest) {
|
|
||||||
request = await onRequest(url, requestInit)
|
|
||||||
}
|
|
||||||
// fetch must be assigned here, otherwise it would throw the error:
|
|
||||||
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
||||||
const _fetch = options.fetch ?? globalThis.fetch
|
|
||||||
const response = await _fetch(request)
|
|
||||||
|
|
||||||
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`)
|
|
||||||
|
|
||||||
if (!response.body) throw new Error("No body in SSE response")
|
|
||||||
|
|
||||||
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader()
|
|
||||||
|
|
||||||
let buffer = ""
|
|
||||||
|
|
||||||
const abortHandler = () => {
|
|
||||||
try {
|
|
||||||
reader.cancel()
|
|
||||||
} catch {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signal.addEventListener("abort", abortHandler)
|
|
||||||
|
|
||||||
try {
|
|
||||||
while (true) {
|
|
||||||
const { done, value } = await reader.read()
|
|
||||||
if (done) break
|
|
||||||
buffer += value
|
|
||||||
// Normalize line endings: CRLF -> LF, then CR -> LF
|
|
||||||
buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n")
|
|
||||||
|
|
||||||
const chunks = buffer.split("\n\n")
|
|
||||||
buffer = chunks.pop() ?? ""
|
|
||||||
|
|
||||||
for (const chunk of chunks) {
|
|
||||||
const lines = chunk.split("\n")
|
|
||||||
const dataLines: Array<string> = []
|
|
||||||
let eventName: string | undefined
|
|
||||||
|
|
||||||
for (const line of lines) {
|
|
||||||
if (line.startsWith("data:")) {
|
|
||||||
dataLines.push(line.replace(/^data:\s*/, ""))
|
|
||||||
} else if (line.startsWith("event:")) {
|
|
||||||
eventName = line.replace(/^event:\s*/, "")
|
|
||||||
} else if (line.startsWith("id:")) {
|
|
||||||
lastEventId = line.replace(/^id:\s*/, "")
|
|
||||||
} else if (line.startsWith("retry:")) {
|
|
||||||
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10)
|
|
||||||
if (!Number.isNaN(parsed)) {
|
|
||||||
retryDelay = parsed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let data: unknown
|
|
||||||
let parsedJson = false
|
|
||||||
|
|
||||||
if (dataLines.length) {
|
|
||||||
const rawData = dataLines.join("\n")
|
|
||||||
try {
|
|
||||||
data = JSON.parse(rawData)
|
|
||||||
parsedJson = true
|
|
||||||
} catch {
|
|
||||||
data = rawData
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parsedJson) {
|
|
||||||
if (responseValidator) {
|
|
||||||
await responseValidator(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (responseTransformer) {
|
|
||||||
data = await responseTransformer(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onSseEvent?.({
|
|
||||||
data,
|
|
||||||
event: eventName,
|
|
||||||
id: lastEventId,
|
|
||||||
retry: retryDelay,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (dataLines.length) {
|
|
||||||
yield data as any
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
signal.removeEventListener("abort", abortHandler)
|
|
||||||
reader.releaseLock()
|
|
||||||
}
|
|
||||||
|
|
||||||
break // exit loop on normal completion
|
|
||||||
} catch (error) {
|
|
||||||
// connection failed or aborted; retry after delay
|
|
||||||
onSseError?.(error)
|
|
||||||
|
|
||||||
if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
|
|
||||||
break // stop after firing error
|
|
||||||
}
|
|
||||||
|
|
||||||
// exponential backoff: double retry each attempt, cap at 30s
|
|
||||||
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000)
|
|
||||||
await sleep(backoff)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const stream = createStream()
|
|
||||||
|
|
||||||
return { stream }
|
|
||||||
}
|
|
||||||
|
|
@ -1,86 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { Auth, AuthToken } from "./auth.gen.js"
|
|
||||||
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from "./bodySerializer.gen.js"
|
|
||||||
|
|
||||||
export type HttpMethod = "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace"
|
|
||||||
|
|
||||||
export type Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
|
|
||||||
/**
|
|
||||||
* Returns the final request URL.
|
|
||||||
*/
|
|
||||||
buildUrl: BuildUrlFn
|
|
||||||
getConfig: () => Config
|
|
||||||
request: RequestFn
|
|
||||||
setConfig: (config: Config) => Config
|
|
||||||
} & {
|
|
||||||
[K in HttpMethod]: MethodFn
|
|
||||||
} & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } })
|
|
||||||
|
|
||||||
export interface Config {
|
|
||||||
/**
|
|
||||||
* Auth token or a function returning auth token. The resolved value will be
|
|
||||||
* added to the request payload as defined by its `security` array.
|
|
||||||
*/
|
|
||||||
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken
|
|
||||||
/**
|
|
||||||
* A function for serializing request body parameter. By default,
|
|
||||||
* {@link JSON.stringify()} will be used.
|
|
||||||
*/
|
|
||||||
bodySerializer?: BodySerializer | null
|
|
||||||
/**
|
|
||||||
* An object containing any HTTP headers that you want to pre-populate your
|
|
||||||
* `Headers` object with.
|
|
||||||
*
|
|
||||||
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
||||||
*/
|
|
||||||
headers?:
|
|
||||||
| RequestInit["headers"]
|
|
||||||
| Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>
|
|
||||||
/**
|
|
||||||
* The request method.
|
|
||||||
*
|
|
||||||
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
|
||||||
*/
|
|
||||||
method?: Uppercase<HttpMethod>
|
|
||||||
/**
|
|
||||||
* A function for serializing request query parameters. By default, arrays
|
|
||||||
* will be exploded in form style, objects will be exploded in deepObject
|
|
||||||
* style, and reserved characters are percent-encoded.
|
|
||||||
*
|
|
||||||
* This method will have no effect if the native `paramsSerializer()` Axios
|
|
||||||
* API function is used.
|
|
||||||
*
|
|
||||||
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
|
||||||
*/
|
|
||||||
querySerializer?: QuerySerializer | QuerySerializerOptions
|
|
||||||
/**
|
|
||||||
* A function validating request data. This is useful if you want to ensure
|
|
||||||
* the request conforms to the desired shape, so it can be safely sent to
|
|
||||||
* the server.
|
|
||||||
*/
|
|
||||||
requestValidator?: (data: unknown) => Promise<unknown>
|
|
||||||
/**
|
|
||||||
* A function transforming response data before it's returned. This is useful
|
|
||||||
* for post-processing data, e.g. converting ISO strings into Date objects.
|
|
||||||
*/
|
|
||||||
responseTransformer?: (data: unknown) => Promise<unknown>
|
|
||||||
/**
|
|
||||||
* A function validating response data. This is useful if you want to ensure
|
|
||||||
* the response conforms to the desired shape, so it can be safely passed to
|
|
||||||
* the transformers and returned to the user.
|
|
||||||
*/
|
|
||||||
responseValidator?: (data: unknown) => Promise<unknown>
|
|
||||||
}
|
|
||||||
|
|
||||||
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
|
|
||||||
? true
|
|
||||||
: [T] extends [never | undefined]
|
|
||||||
? [undefined] extends [T]
|
|
||||||
? false
|
|
||||||
: true
|
|
||||||
: false
|
|
||||||
|
|
||||||
export type OmitNever<T extends Record<string, unknown>> = {
|
|
||||||
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K]
|
|
||||||
}
|
|
||||||
|
|
@ -1,137 +0,0 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { BodySerializer, QuerySerializer } from "./bodySerializer.gen.js"
|
|
||||||
import {
|
|
||||||
type ArraySeparatorStyle,
|
|
||||||
serializeArrayParam,
|
|
||||||
serializeObjectParam,
|
|
||||||
serializePrimitiveParam,
|
|
||||||
} from "./pathSerializer.gen.js"
|
|
||||||
|
|
||||||
export interface PathSerializer {
|
|
||||||
path: Record<string, unknown>
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export const PATH_PARAM_RE = /\{[^{}]+\}/g
|
|
||||||
|
|
||||||
export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
||||||
let url = _url
|
|
||||||
const matches = _url.match(PATH_PARAM_RE)
|
|
||||||
if (matches) {
|
|
||||||
for (const match of matches) {
|
|
||||||
let explode = false
|
|
||||||
let name = match.substring(1, match.length - 1)
|
|
||||||
let style: ArraySeparatorStyle = "simple"
|
|
||||||
|
|
||||||
if (name.endsWith("*")) {
|
|
||||||
explode = true
|
|
||||||
name = name.substring(0, name.length - 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name.startsWith(".")) {
|
|
||||||
name = name.substring(1)
|
|
||||||
style = "label"
|
|
||||||
} else if (name.startsWith(";")) {
|
|
||||||
name = name.substring(1)
|
|
||||||
style = "matrix"
|
|
||||||
}
|
|
||||||
|
|
||||||
const value = path[name]
|
|
||||||
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
url = url.replace(match, serializeArrayParam({ explode, name, style, value }))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof value === "object") {
|
|
||||||
url = url.replace(
|
|
||||||
match,
|
|
||||||
serializeObjectParam({
|
|
||||||
explode,
|
|
||||||
name,
|
|
||||||
style,
|
|
||||||
value: value as Record<string, unknown>,
|
|
||||||
valueOnly: true,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style === "matrix") {
|
|
||||||
url = url.replace(
|
|
||||||
match,
|
|
||||||
`;${serializePrimitiveParam({
|
|
||||||
name,
|
|
||||||
value: value as string,
|
|
||||||
})}`,
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const replaceValue = encodeURIComponent(style === "label" ? `.${value as string}` : (value as string))
|
|
||||||
url = url.replace(match, replaceValue)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return url
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getUrl = ({
|
|
||||||
baseUrl,
|
|
||||||
path,
|
|
||||||
query,
|
|
||||||
querySerializer,
|
|
||||||
url: _url,
|
|
||||||
}: {
|
|
||||||
baseUrl?: string
|
|
||||||
path?: Record<string, unknown>
|
|
||||||
query?: Record<string, unknown>
|
|
||||||
querySerializer: QuerySerializer
|
|
||||||
url: string
|
|
||||||
}) => {
|
|
||||||
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`
|
|
||||||
let url = (baseUrl ?? "") + pathUrl
|
|
||||||
if (path) {
|
|
||||||
url = defaultPathSerializer({ path, url })
|
|
||||||
}
|
|
||||||
let search = query ? querySerializer(query) : ""
|
|
||||||
if (search.startsWith("?")) {
|
|
||||||
search = search.substring(1)
|
|
||||||
}
|
|
||||||
if (search) {
|
|
||||||
url += `?${search}`
|
|
||||||
}
|
|
||||||
return url
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getValidRequestBody(options: {
|
|
||||||
body?: unknown
|
|
||||||
bodySerializer?: BodySerializer | null
|
|
||||||
serializedBody?: unknown
|
|
||||||
}) {
|
|
||||||
const hasBody = options.body !== undefined
|
|
||||||
const isSerializedBody = hasBody && options.bodySerializer
|
|
||||||
|
|
||||||
if (isSerializedBody) {
|
|
||||||
if ("serializedBody" in options) {
|
|
||||||
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== ""
|
|
||||||
|
|
||||||
return hasSerializedBody ? options.serializedBody : null
|
|
||||||
}
|
|
||||||
|
|
||||||
// not all clients implement a serializedBody property (i.e. client-axios)
|
|
||||||
return options.body !== "" ? options.body : null
|
|
||||||
}
|
|
||||||
|
|
||||||
// plain/text body
|
|
||||||
if (hasBody) {
|
|
||||||
return options.body
|
|
||||||
}
|
|
||||||
|
|
||||||
// no body was provided
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,23 +0,0 @@
|
||||||
export * from "./client.js"
|
|
||||||
export * from "./server.js"
|
|
||||||
|
|
||||||
import { createOpencodeClient } from "./client.js"
|
|
||||||
import { createOpencodeServer } from "./server.js"
|
|
||||||
import type { ServerOptions } from "./server.js"
|
|
||||||
|
|
||||||
export * as data from "./data.js"
|
|
||||||
|
|
||||||
export async function createOpencode(options?: ServerOptions) {
|
|
||||||
const server = await createOpencodeServer({
|
|
||||||
...options,
|
|
||||||
})
|
|
||||||
|
|
||||||
const client = createOpencodeClient({
|
|
||||||
baseUrl: server.url,
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
|
||||||
client,
|
|
||||||
server,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,134 +0,0 @@
|
||||||
import launch from "cross-spawn"
|
|
||||||
import { type Config } from "./gen/types.gen.js"
|
|
||||||
import { stop, bindAbort } from "../process.js"
|
|
||||||
|
|
||||||
export type ServerOptions = {
|
|
||||||
hostname?: string
|
|
||||||
port?: number
|
|
||||||
signal?: AbortSignal
|
|
||||||
timeout?: number
|
|
||||||
config?: Config
|
|
||||||
}
|
|
||||||
|
|
||||||
export type TuiOptions = {
|
|
||||||
project?: string
|
|
||||||
model?: string
|
|
||||||
session?: string
|
|
||||||
agent?: string
|
|
||||||
signal?: AbortSignal
|
|
||||||
config?: Config
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function createOpencodeServer(options?: ServerOptions) {
|
|
||||||
options = Object.assign(
|
|
||||||
{
|
|
||||||
hostname: "127.0.0.1",
|
|
||||||
port: 4096,
|
|
||||||
timeout: 5000,
|
|
||||||
},
|
|
||||||
options ?? {},
|
|
||||||
)
|
|
||||||
|
|
||||||
const args = [`serve`, `--hostname=${options.hostname}`, `--port=${options.port}`]
|
|
||||||
if (options.config?.logLevel) args.push(`--log-level=${options.config.logLevel}`)
|
|
||||||
|
|
||||||
const proc = launch(`opencode`, args, {
|
|
||||||
env: {
|
|
||||||
...process.env,
|
|
||||||
OPENCODE_CONFIG_CONTENT: JSON.stringify(options.config ?? {}),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
let clear = () => {}
|
|
||||||
|
|
||||||
const url = await new Promise<string>((resolve, reject) => {
|
|
||||||
const id = setTimeout(() => {
|
|
||||||
clear()
|
|
||||||
stop(proc)
|
|
||||||
reject(new Error(`Timeout waiting for server to start after ${options.timeout}ms`))
|
|
||||||
}, options.timeout)
|
|
||||||
let output = ""
|
|
||||||
let resolved = false
|
|
||||||
proc.stdout?.on("data", (chunk) => {
|
|
||||||
if (resolved) return
|
|
||||||
output += chunk.toString()
|
|
||||||
const lines = output.split("\n")
|
|
||||||
for (const line of lines) {
|
|
||||||
if (line.startsWith("opencode server listening")) {
|
|
||||||
const match = line.match(/on\s+(https?:\/\/[^\s]+)/)
|
|
||||||
if (!match) {
|
|
||||||
clear()
|
|
||||||
stop(proc)
|
|
||||||
clearTimeout(id)
|
|
||||||
reject(new Error(`Failed to parse server url from output: ${line}`))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
clearTimeout(id)
|
|
||||||
resolved = true
|
|
||||||
resolve(match[1]!)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
proc.stderr?.on("data", (chunk) => {
|
|
||||||
output += chunk.toString()
|
|
||||||
})
|
|
||||||
proc.on("exit", (code) => {
|
|
||||||
clearTimeout(id)
|
|
||||||
let msg = `Server exited with code ${code}`
|
|
||||||
if (output.trim()) {
|
|
||||||
msg += `\nServer output: ${output}`
|
|
||||||
}
|
|
||||||
reject(new Error(msg))
|
|
||||||
})
|
|
||||||
proc.on("error", (error) => {
|
|
||||||
clearTimeout(id)
|
|
||||||
reject(error)
|
|
||||||
})
|
|
||||||
clear = bindAbort(proc, options.signal, () => {
|
|
||||||
clearTimeout(id)
|
|
||||||
reject(options.signal?.reason)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
|
||||||
url,
|
|
||||||
close() {
|
|
||||||
clear()
|
|
||||||
stop(proc)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createOpencodeTui(options?: TuiOptions) {
|
|
||||||
const args = []
|
|
||||||
|
|
||||||
if (options?.project) {
|
|
||||||
args.push(`--project=${options.project}`)
|
|
||||||
}
|
|
||||||
if (options?.model) {
|
|
||||||
args.push(`--model=${options.model}`)
|
|
||||||
}
|
|
||||||
if (options?.session) {
|
|
||||||
args.push(`--session=${options.session}`)
|
|
||||||
}
|
|
||||||
if (options?.agent) {
|
|
||||||
args.push(`--agent=${options.agent}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const proc = launch(`opencode`, args, {
|
|
||||||
stdio: "inherit",
|
|
||||||
env: {
|
|
||||||
...process.env,
|
|
||||||
OPENCODE_CONFIG_CONTENT: JSON.stringify(options?.config ?? {}),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const clear = bindAbort(proc, options?.signal)
|
|
||||||
|
|
||||||
return {
|
|
||||||
close() {
|
|
||||||
clear()
|
|
||||||
stop(proc)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
10
packages/sdk/js/sst-env.d.ts
vendored
10
packages/sdk/js/sst-env.d.ts
vendored
|
|
@ -1,10 +0,0 @@
|
||||||
/* This file is auto-generated by SST. Do not edit. */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/* deno-fmt-ignore-file */
|
|
||||||
/* biome-ignore-all lint: auto-generated */
|
|
||||||
|
|
||||||
/// <reference path="../../../sst-env.d.ts" />
|
|
||||||
|
|
||||||
import "sst"
|
|
||||||
export {}
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
import { expect, test } from "bun:test"
|
|
||||||
import type { V2SessionHistoryData } from "../src/v2/gen/types.gen"
|
|
||||||
|
|
||||||
test("uses numeric Session history positions", () => {
|
|
||||||
const input = {
|
|
||||||
path: { sessionID: "ses_test" },
|
|
||||||
query: { after: 1, limit: 50 },
|
|
||||||
url: "/api/session/{sessionID}/history",
|
|
||||||
} satisfies V2SessionHistoryData
|
|
||||||
|
|
||||||
expect(input.query.after).toBe(1)
|
|
||||||
})
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
||||||
"extends": "@tsconfig/node22/tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "dist",
|
|
||||||
"module": "nodenext",
|
|
||||||
"declaration": true,
|
|
||||||
"moduleResolution": "nodenext",
|
|
||||||
"lib": ["es2022", "dom", "dom.iterable"],
|
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src"
|
|
||||||
},
|
|
||||||
"include": ["src"]
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -41,7 +41,7 @@
|
||||||
"@kobalte/core": "catalog:",
|
"@kobalte/core": "catalog:",
|
||||||
"@opencode-ai/client": "file:../app/vendor/opencode-ai-client-1.17.13.tgz",
|
"@opencode-ai/client": "file:../app/vendor/opencode-ai-client-1.17.13.tgz",
|
||||||
"@opencode-ai/core": "workspace:*",
|
"@opencode-ai/core": "workspace:*",
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "1.18.5",
|
||||||
"@opencode-ai/ui": "workspace:*",
|
"@opencode-ai/ui": "workspace:*",
|
||||||
"@pierre/diffs": "catalog:",
|
"@pierre/diffs": "catalog:",
|
||||||
"@shikijs/stream": "catalog:",
|
"@shikijs/stream": "catalog:",
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
"typecheck": "tsgo --noEmit"
|
"typecheck": "tsgo --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "1.18.5",
|
||||||
"@slack/bolt": "^3.17.1"
|
"@slack/bolt": "^3.17.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -7,8 +7,8 @@
|
||||||
"dev": "bun run generate && blume dev --host --port 3000",
|
"dev": "bun run generate && blume dev --host --port 3000",
|
||||||
"build": "bun run generate && blume build && bun script/prepare-cloudflare.ts",
|
"build": "bun run generate && blume build && bun script/prepare-cloudflare.ts",
|
||||||
"deploy": "wrangler deploy --config dist/server/wrangler.json",
|
"deploy": "wrangler deploy --config dist/server/wrangler.json",
|
||||||
"generate": "bun script/generate-theme-tokens.ts",
|
"generate": "bun script/generate-theme-tokens.ts && bun script/generate-openapi.ts",
|
||||||
"check:generated": "bun script/generate-theme-tokens.ts --check",
|
"check:generated": "bun script/generate-theme-tokens.ts --check && bun script/generate-openapi.ts --check",
|
||||||
"typecheck": "blume check",
|
"typecheck": "blume check",
|
||||||
"validate": "blume validate",
|
"validate": "blume validate",
|
||||||
"doctor": "blume doctor"
|
"doctor": "blume doctor"
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
18
packages/www/script/generate-openapi.ts
Normal file
18
packages/www/script/generate-openapi.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { fileURLToPath } from "url"
|
||||||
|
|
||||||
|
const source = fileURLToPath(new URL("../../protocol/openapi.json", import.meta.url))
|
||||||
|
const targets = ["../openapi.json", "../public/openapi.json"].map((path) =>
|
||||||
|
fileURLToPath(new URL(path, import.meta.url)),
|
||||||
|
)
|
||||||
|
const document = await Bun.file(source).text()
|
||||||
|
|
||||||
|
if (process.argv.includes("--check")) {
|
||||||
|
const stale = (await Promise.all(targets.map((path) => Bun.file(path).text()))).some((value) => value !== document)
|
||||||
|
if (stale) {
|
||||||
|
console.error("Generated OpenAPI documents are stale. Run `bun run generate` from packages/www.")
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(targets.map((path) => Bun.write(path, document)))
|
||||||
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
import { $ } from "bun"
|
import { $ } from "bun"
|
||||||
|
|
||||||
await $`bun ./packages/sdk/js/script/build.ts`
|
await $`bun run generate`.cwd("packages/protocol")
|
||||||
|
|
||||||
await $`bun dev generate > ../sdk/openapi.json`.cwd("packages/opencode")
|
|
||||||
|
|
||||||
await $`bun run generate`.cwd("packages/www")
|
await $`bun run generate`.cwd("packages/www")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ async function prepareReleaseFiles() {
|
||||||
}
|
}
|
||||||
|
|
||||||
await $`bun install`
|
await $`bun install`
|
||||||
await $`./packages/sdk/js/script/build.ts`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Script.release && !Script.preview) {
|
if (Script.release && !Script.preview) {
|
||||||
|
|
@ -54,9 +53,6 @@ await $`bun ./packages/client/script/publish.ts`
|
||||||
console.log("\n=== cli ===\n")
|
console.log("\n=== cli ===\n")
|
||||||
await $`bun ./packages/cli/script/publish.ts`
|
await $`bun ./packages/cli/script/publish.ts`
|
||||||
|
|
||||||
console.log("\n=== sdk ===\n")
|
|
||||||
await $`bun ./packages/sdk/js/script/publish.ts`
|
|
||||||
|
|
||||||
console.log("\n=== plugin ===\n")
|
console.log("\n=== plugin ===\n")
|
||||||
await $`bun ./packages/plugin/script/publish.ts`
|
await $`bun ./packages/plugin/script/publish.ts`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ async function commits(from: string, to: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const log =
|
const log =
|
||||||
await $`git log ${base}..${head} --format=%H -- packages/opencode packages/sdk packages/plugin packages/desktop packages/app sdks/vscode packages/extensions github`.text()
|
await $`git log ${base}..${head} --format=%H -- packages/opencode packages/plugin packages/desktop packages/app sdks/vscode packages/extensions github`.text()
|
||||||
|
|
||||||
const list: Commit[] = []
|
const list: Commit[] = []
|
||||||
for (const hash of log.split("\n").filter(Boolean)) {
|
for (const hash of log.split("\n").filter(Boolean)) {
|
||||||
|
|
@ -136,7 +136,7 @@ async function commits(from: string, to: string) {
|
||||||
else if (file.startsWith("packages/opencode/")) areas.add("core")
|
else if (file.startsWith("packages/opencode/")) areas.add("core")
|
||||||
else if (file.startsWith("packages/desktop/src-tauri/")) areas.add("tauri")
|
else if (file.startsWith("packages/desktop/src-tauri/")) areas.add("tauri")
|
||||||
else if (file.startsWith("packages/desktop/") || file.startsWith("packages/app/")) areas.add("app")
|
else if (file.startsWith("packages/desktop/") || file.startsWith("packages/app/")) areas.add("app")
|
||||||
else if (file.startsWith("packages/sdk/") || file.startsWith("packages/plugin/")) areas.add("sdk")
|
else if (file.startsWith("packages/plugin/")) areas.add("sdk")
|
||||||
else if (file.startsWith("sdks/vscode/") || file.startsWith("github/")) areas.add("extensions/vscode")
|
else if (file.startsWith("sdks/vscode/") || file.startsWith("github/")) areas.add("extensions/vscode")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue