feat(server): S3 driver core — aws-lite client seam, stat/delete, driver-owned deadlines

This commit is contained in:
jubnl
2026-08-19 20:36:56 +02:00
parent bc4d70986f
commit c3c0a4cd01
4 changed files with 840 additions and 0 deletions
+501
View File
@@ -389,6 +389,404 @@
"integrity": "sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==",
"license": "MIT"
},
"node_modules/@aws-lite/client": {
"version": "0.23.7",
"resolved": "https://registry.npmjs.org/@aws-lite/client/-/client-0.23.7.tgz",
"integrity": "sha512-Qo/lq96DS8UOg1yFccolMuKG1hKnNStXVYhzVl4tZk/7m+OtANVk2JB8iuYJISc4DF7Dm3Qy+e91L6BGJ1dfkw==",
"license": "Apache-2.0",
"workspaces": [
"plugins/acm",
"plugins/acm/types",
"plugins/apigateway",
"plugins/apigateway/types",
"plugins/apigatewaymanagementapi",
"plugins/apigatewaymanagementapi/types",
"plugins/apigatewayv2",
"plugins/apigatewayv2/types",
"plugins/cloudformation",
"plugins/cloudformation/types",
"plugins/cloudfront",
"plugins/cloudfront/types",
"plugins/cloudwatch-logs",
"plugins/cloudwatch-logs/types",
"plugins/dynamodb",
"plugins/dynamodb/types",
"plugins/iam",
"plugins/iam/types",
"plugins/lambda",
"plugins/lambda/types",
"plugins/organizations",
"plugins/organizations/types",
"plugins/rds-data",
"plugins/rds-data/types",
"plugins/route53",
"plugins/route53/types",
"plugins/s3",
"plugins/s3/types",
"plugins/sns",
"plugins/sns/types",
"plugins/sqs",
"plugins/sqs/types",
"plugins/ssm",
"plugins/ssm/types",
"plugins/sts",
"plugins/sts/types"
],
"dependencies": {
"aws4": "^1.13.2"
},
"engines": {
"node": ">=16"
}
},
"node_modules/@aws-lite/s3": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/@aws-lite/s3/-/s3-0.2.7.tgz",
"integrity": "sha512-NPQZXMcHIwrcyZWrHUeoyjl3353xIoYA/6XoUu4KJs2NQKqF6xx5YO+7nXE05vSSygNSgUHetaue/x2vr2430A==",
"license": "Apache-2.0",
"engines": {
"node": ">=16"
}
},
"node_modules/@aws-lite/s3-types": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/@aws-lite/s3-types/-/s3-types-0.2.8.tgz",
"integrity": "sha512-e+wf4m83Qk9d+4e/on3d6dSkqC2eueL6LM7iLpZQ+U4f6Ey5tRuvirqbj8iOQcUGxJpP7UiVXAv+P61WIql/OA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/client-s3": "3"
},
"engines": {
"node": ">=16"
}
},
"node_modules/@aws-sdk/checksums": {
"version": "3.1000.28",
"resolved": "https://registry.npmjs.org/@aws-sdk/checksums/-/checksums-3.1000.28.tgz",
"integrity": "sha512-VCpnmyHQ1IH49ni3LXnQj7DPr7rmcJmzYeiCkYdCcfgNtkvOj38cdcL9lapBWoItZWFACJPFJlymqC7/gem3Gw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/client-s3": {
"version": "3.1113.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.1113.0.tgz",
"integrity": "sha512-NRqdtohoMRyWkEeeznfG1KPN08dclCbl+HFuLPB2v8qPcgoNmTFlLKl9ELiR6hsGXQ4Ur3qvRnoJVEk8ND74pg==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/checksums": "^3.1000.28",
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/credential-provider-node": "^3.972.80",
"@aws-sdk/middleware-sdk-s3": "^3.972.74",
"@aws-sdk/signature-v4-multi-region": "^3.996.45",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/fetch-http-handler": "^5.6.13",
"@smithy/node-http-handler": "^4.9.13",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/core": {
"version": "3.977.8",
"resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.977.8.tgz",
"integrity": "sha512-7+Kcrkvrk9lM/m7jRhHpT4jCdvzGHsuaSRbF8TdzzkY1mRzp/Ogwf9c7H29k4gGhey0BBWhCWr16+t0J61gwmg==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/types": "^3.974.4",
"@aws-sdk/xml-builder": "^3.972.39",
"@aws/lambda-invoke-store": "^0.3.0",
"@smithy/core": "^3.31.1",
"@smithy/signature-v4": "^5.6.12",
"@smithy/types": "^4.16.1",
"bowser": "^2.11.0",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/credential-provider-env": {
"version": "3.972.69",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.69.tgz",
"integrity": "sha512-AreCFzcB4kH2HF9031Ot0jSJr3KXvRg6e8uDeub20JEVdZU3Bv0sTq1plc7VsT3KiqutlzH7l0j50UcCWHUioA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/credential-provider-http": {
"version": "3.972.71",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.71.tgz",
"integrity": "sha512-A8ObcqVmDMnk4F9NozZ7JwmUu9Q4xyBJkmyq1C5U+wNM9ht9J7+EuuyabsLWXZnOoTqFaJuYBYTKf5CTipkEjA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/fetch-http-handler": "^5.6.13",
"@smithy/node-http-handler": "^4.9.13",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/credential-provider-ini": {
"version": "3.973.14",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.973.14.tgz",
"integrity": "sha512-7c+Wti2LsERNWMfm7ySz3/6RPopFW3Nmn7s63Xpcq6R/tRuY5hpvkHA2xVgi5ukJbvok9l0IDtVEvqTtg+X7dw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/credential-provider-env": "^3.972.69",
"@aws-sdk/credential-provider-http": "^3.972.71",
"@aws-sdk/credential-provider-login": "^3.972.76",
"@aws-sdk/credential-provider-process": "^3.972.69",
"@aws-sdk/credential-provider-sso": "^3.973.13",
"@aws-sdk/credential-provider-web-identity": "^3.972.75",
"@aws-sdk/nested-clients": "^3.997.43",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/credential-provider-imds": "^4.4.16",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/credential-provider-login": {
"version": "3.972.76",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.76.tgz",
"integrity": "sha512-LVixwOnEJfrrfKHeZjBA8pIMTZjNDq8ak8VpcoWUuCJDrSnBNU8POJksULMgvN089P0MXtQYH2Zs627/MK1K0g==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/nested-clients": "^3.997.43",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/credential-provider-node": {
"version": "3.972.80",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.80.tgz",
"integrity": "sha512-bE2qh8ww4iClO1jHsBXdOE8FUgzDbdxbyorNjSCoPSkQd51k3jODItuPZfuwcLHZqDXsH+bI4AMHhqtuyR7mSg==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/credential-provider-env": "^3.972.69",
"@aws-sdk/credential-provider-http": "^3.972.71",
"@aws-sdk/credential-provider-ini": "^3.973.14",
"@aws-sdk/credential-provider-process": "^3.972.69",
"@aws-sdk/credential-provider-sso": "^3.973.13",
"@aws-sdk/credential-provider-web-identity": "^3.972.75",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/credential-provider-imds": "^4.4.16",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/credential-provider-process": {
"version": "3.972.69",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.69.tgz",
"integrity": "sha512-9kpTNdZTrcqXTfhxM7fgl9Z68ek3Fu5oe3Yf+A/pJGibEqpgZxz2tSY7SinmyCIU2PJ+ygY4FPoBBnLpocMtrQ==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/credential-provider-sso": {
"version": "3.973.13",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.973.13.tgz",
"integrity": "sha512-Oc81qauMPzUoTnAS2YKpNwY6sY/LUyQTEeaf6yP197WMxkEBQfcKLR1MFpD7+pNTubXnfkH6gwpji+Gc7iyD2Q==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/nested-clients": "^3.997.43",
"@aws-sdk/token-providers": "3.1111.0",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/credential-provider-web-identity": {
"version": "3.972.75",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.75.tgz",
"integrity": "sha512-YPN6uoGDgjjjeVFZrcOeCJqmB6zpXoeeNgIjqe+DexJaWqdjVfCCe+VAZwli9Z2h8KhFW8oxkO39emQ1tyz/Mw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/nested-clients": "^3.997.43",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/middleware-sdk-s3": {
"version": "3.972.74",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-s3/-/middleware-sdk-s3-3.972.74.tgz",
"integrity": "sha512-2lzoV2z2QO5KJZYGOCnIZ1WVQgzMECvwuzr1xb034a++8QW4U4eGrmC2u4yg1xvNv4TLL/Uv5DLyuAiw0b9z7Q==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/signature-v4-multi-region": "^3.996.45",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/nested-clients": {
"version": "3.997.43",
"resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.43.tgz",
"integrity": "sha512-bit+VpqWNyi3wHxFoTsTliNXimCSL2r2OeDTm7ZrG+YsTZ2D7ofDJ6r/t9PVBn80i6/v0X2h9Tgw6QP2MAKfPw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/signature-v4-multi-region": "^3.996.45",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/fetch-http-handler": "^5.6.13",
"@smithy/node-http-handler": "^4.9.13",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/signature-v4-multi-region": {
"version": "3.996.45",
"resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.45.tgz",
"integrity": "sha512-bBuyztukzXq6plzFGHAWiQt0QXo+HL8b8lX5cFTzkez/74PtS1c0qPFCIVuHkyoT+miH2qOjAcm1/yoro2ESPA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/types": "^3.974.4",
"@smithy/signature-v4": "^5.6.12",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/token-providers": {
"version": "3.1111.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1111.0.tgz",
"integrity": "sha512-JfljgoVtl+s3Qy21n9a7Z48uCQaOXcN74KJ3TEQfPoB293GrXFSt6HSQJF1sTZ8c/5QedEvd3NjJQMO4u9qa5A==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/core": "^3.977.8",
"@aws-sdk/nested-clients": "^3.997.43",
"@aws-sdk/types": "^3.974.4",
"@smithy/core": "^3.31.1",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/types": {
"version": "3.974.4",
"resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.974.4.tgz",
"integrity": "sha512-dSFDNG00MEz0/xl5gxL62giLd1iYyJsTxZ1I1DOj6lC+bbgLB4TRsYClJg3b62dhXT1uATzsTNXPnC+33EJV3A==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws-sdk/xml-builder": {
"version": "3.972.39",
"resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.39.tgz",
"integrity": "sha512-FTti8DS5MMWXNUWiRwXAJeYS+0GHHiMy0+7XOhcwk63ILHmfS2UFy2z/HNpZCSOJJ3P3dnWY6hfYNW3DF0nXUA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@aws/lambda-invoke-store": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@aws/lambda-invoke-store/-/lambda-invoke-store-0.3.0.tgz",
"integrity": "sha512-sl4Bm6yiMNYrZKkqqDFWN0UfnWhlS8ivKxrYl+6t0gCLrqr8y3B2IqZZbFRkfaVVp7C/baApyh71P+LeE1A2sQ==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/@babel/code-frame": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz",
@@ -6701,6 +7099,93 @@
"node": ">=20.0.0"
}
},
"node_modules/@smithy/core": {
"version": "3.33.2",
"resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.33.2.tgz",
"integrity": "sha512-CUGXpnPkVdjUCbix+83sWLW9VFgQOm44MDOx/ihITJMAnOZKvL8YYIc7DR9pP/tZ8CIRvMiON/TucvygqbHO3w==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@smithy/types": "^4.17.2",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/@smithy/credential-provider-imds": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-4.5.2.tgz",
"integrity": "sha512-A9uSdn72ozbRUSit0eib0TW7nXuNPlaeM0zcGkJ+nE6tFcSDbnmtwoxbTCFBukVQcszDAyvsd7+rTduPTXpygg==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@smithy/core": "^3.33.2",
"@smithy/types": "^4.17.2",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/@smithy/fetch-http-handler": {
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.7.2.tgz",
"integrity": "sha512-nZyWTmSpJEXl6VtWVMBJve/7x12DZu6sIX1z1a+ZMaHlQQRs9Zpu6NbTe/gmxYXVRpkjxyDYpZ5gx2IM6f/Wkw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@smithy/core": "^3.33.2",
"@smithy/types": "^4.17.2",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/@smithy/node-http-handler": {
"version": "4.11.2",
"resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.11.2.tgz",
"integrity": "sha512-avwAh9HM3h2lcfjvP3zYIZGf+XVgLQ91wOJ2qoFbNpW1UZeZb33aGlhTZvtkANHfcGhJroRY64525OjfgOg30g==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@smithy/core": "^3.33.2",
"@smithy/types": "^4.17.2",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/@smithy/signature-v4": {
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-5.7.2.tgz",
"integrity": "sha512-P7Ki6px6OOrxVtx8K7nLmyx4SlXUW/uTKDdMG44UHefmPGSRMBKe2v+TM59WdLcpUIrBrnuCsIqiM2MbsZjmhw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@smithy/core": "^3.33.2",
"@smithy/types": "^4.17.2",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/@smithy/types": {
"version": "4.17.2",
"resolved": "https://registry.npmjs.org/@smithy/types/-/types-4.17.2.tgz",
"integrity": "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"tslib": "^2.6.2"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/@standard-schema/spec": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",
@@ -8595,6 +9080,12 @@
"node": ">=6.0.0"
}
},
"node_modules/aws4": {
"version": "1.13.2",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz",
"integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==",
"license": "MIT"
},
"node_modules/axios": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.18.0.tgz",
@@ -8952,6 +9443,13 @@
"node": ">= 0.8"
}
},
"node_modules/bowser": {
"version": "2.14.1",
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.14.1.tgz",
"integrity": "sha512-tzPjzCxygAKWFOJP011oxFHs57HzIhOEracIgAePE4pqB3LikALKnSzUyU4MGs9/iCEUuHlAJTjTc5M+u7YEGg==",
"dev": true,
"license": "MIT"
},
"node_modules/brace-expansion": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
@@ -21216,6 +21714,8 @@
"name": "@trek/server",
"version": "3.4.1",
"dependencies": {
"@aws-lite/client": "^0.23.7",
"@aws-lite/s3": "^0.2.7",
"@modelcontextprotocol/sdk": "^1.30.0",
"@nestjs/common": "^11.1.24",
"@nestjs/config": "^4.0.4",
@@ -21262,6 +21762,7 @@
"zod": "^4.3.6"
},
"devDependencies": {
"@aws-lite/s3-types": "^0.2.8",
"@eslint/js": "^10.0.1",
"@nestjs/testing": "^11.1.24",
"@swc/core": "^1.15.40",
+3
View File
@@ -25,6 +25,8 @@
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"@aws-lite/client": "^0.23.7",
"@aws-lite/s3": "^0.2.7",
"@modelcontextprotocol/sdk": "^1.30.0",
"@nestjs/common": "^11.1.24",
"@nestjs/config": "^4.0.4",
@@ -81,6 +83,7 @@
"file-type": "^21.3.4"
},
"devDependencies": {
"@aws-lite/s3-types": "^0.2.8",
"@eslint/js": "^10.0.1",
"@nestjs/testing": "^11.1.24",
"@swc/core": "^1.15.40",
@@ -0,0 +1,201 @@
import awsLite from '@aws-lite/client';
import type { Readable } from 'node:stream';
import { assertValidKey, assertValidPrefix } from '../storage-keys';
import {
StorageBackendError,
StorageNotFoundError,
type ByteRange,
type LocalTempFile,
type ObjectStat,
type PutOptions,
type StorageDriver,
} from '../storage.types';
/**
* S3-compatible driver over @aws-lite/client + @aws-lite/s3 (spec:
* docs/superpowers/specs/2026-08-17-s3-storage-driver-design.md). The client
* is a driver-internal detail — nothing outside this file imports aws-lite.
* aws-lite exposes no request timeout or abort signal, so the driver owns the
* deadline: per client call for single-request operations, inactivity-based
* for multipart Upload (destroying the interposed PassThrough drives Upload's
* own error path — in-flight parts drain, then AbortMultipartUpload fires).
*/
/** One multipart chunk (aws-lite Upload default) — also the peek threshold. */
export const MULTIPART_THRESHOLD = 10 * 1024 * 1024;
export interface S3ClientOptions {
endpoint: string;
region: string;
accessKeyId: string;
secretAccessKey: string;
retries: number;
keepAlive: boolean;
}
/** The S3 surface the driver consumes — structural, so tests inject a plain object. */
export interface S3Api {
PutObject(input: Record<string, unknown>): Promise<unknown>;
Upload(input: Record<string, unknown>): Promise<unknown>;
GetObject(input: Record<string, unknown>): Promise<{
Body?: Readable;
ContentLength?: number;
ContentRange?: string;
LastModified?: Date;
}>;
HeadObject(input: Record<string, unknown>): Promise<{ ContentLength?: number; LastModified?: Date }>;
DeleteObject(input: Record<string, unknown>): Promise<unknown>;
ListObjectsV2(input: Record<string, unknown>): Promise<
AsyncIterable<{ Contents?: Array<{ Key?: string; Size?: number; LastModified?: Date }> }>
>;
}
// `Omit<S3ClientOptions, 'keepAlive'>` rather than a bare `S3ClientOptions &`:
// intersecting with the required `keepAlive: boolean` would make the
// `keepAlive?: boolean` below a no-op (TS keeps the property required when
// either side of an `&` requires it).
export type S3DriverOptions = Omit<S3ClientOptions, 'keepAlive'> & {
id: string;
bucket: string;
keyPrefix: string;
timeoutMs: number;
keepAlive?: boolean;
clientFactory?: (opts: S3ClientOptions) => Promise<S3Api>;
};
/** Bare GetObject content-sniffs; streamResponsePayload is mandatory (spec, Client). */
export async function defaultClientFactory(opts: S3ClientOptions): Promise<S3Api> {
// AwsLiteClient's ambient .S3 augmentation (@aws-lite/s3-types) isn't picked
// up by tsc without an explicit reference, so this is the one sanctioned
// `as unknown as` boundary — no other cast in this file.
const client = (await awsLite({
accessKeyId: opts.accessKeyId,
secretAccessKey: opts.secretAccessKey,
region: opts.region,
endpoint: opts.endpoint,
retries: opts.retries,
keepAlive: opts.keepAlive,
plugins: [await import('@aws-lite/s3')],
})) as unknown as { S3: S3Api };
return client.S3;
}
function statusCode(err: unknown): number | undefined {
return (err as { statusCode?: number }).statusCode;
}
function errorCode(err: unknown): string | undefined {
const code = (err as { code?: unknown }).code;
return typeof code === 'string' ? code : undefined;
}
/** aws-lite 404s: statusCode 404, code 'NoSuchKey' (GetObject) or 'NotFound' (HeadObject, bodiless). */
function isNotFound(err: unknown): boolean {
const code = errorCode(err);
return statusCode(err) === 404 || code === 'NoSuchKey' || code === 'NotFound';
}
export class S3Driver implements StorageDriver {
readonly id: string;
private readonly bucket: string;
private readonly keyPrefix: string;
private readonly timeoutMs: number;
private readonly clientOptions: S3ClientOptions;
private readonly clientFactory: (opts: S3ClientOptions) => Promise<S3Api>;
private clientPromise: Promise<S3Api> | null = null;
constructor(opts: S3DriverOptions) {
this.id = opts.id;
this.bucket = opts.bucket;
this.keyPrefix = normalizeKeyPrefix(opts.keyPrefix);
this.timeoutMs = opts.timeoutMs;
this.clientFactory = opts.clientFactory ?? defaultClientFactory;
this.clientOptions = {
endpoint: opts.endpoint,
region: opts.region,
accessKeyId: opts.accessKeyId,
secretAccessKey: opts.secretAccessKey,
retries: opts.retries,
keepAlive: opts.keepAlive ?? true,
};
}
/** No local filesystem — callers fall back to storage.tempDir(). */
getSpoolDir(): null {
return null;
}
async put(_key: string, _source: Readable | LocalTempFile, _opts?: PutOptions): Promise<void> {
throw new StorageBackendError('not implemented');
}
async getStream(_key: string, _range?: ByteRange): Promise<{ stream: Readable; stat: ObjectStat }> {
throw new StorageBackendError('not implemented');
}
async stat(key: string): Promise<ObjectStat | null> {
assertValidKey(key);
const s3 = await this.client();
try {
const res = await this.deadlined(s3.HeadObject({ Bucket: this.bucket, Key: this.keyPrefix + key }), `stat '${key}'`);
return { key, size: res.ContentLength ?? 0, mtimeMs: res.LastModified?.getTime() ?? 0 };
} catch (err) {
if (isNotFound(err)) return null;
throw this.wrap(err, `stat failed for '${key}'`);
}
}
async delete(key: string): Promise<void> {
assertValidKey(key);
const s3 = await this.client();
try {
await this.deadlined(s3.DeleteObject({ Bucket: this.bucket, Key: this.keyPrefix + key }), `delete '${key}'`);
} catch (err) {
if (isNotFound(err)) return; // idempotent — S3 204s on missing keys; some compatibles 404
throw this.wrap(err, `delete failed for '${key}'`);
}
}
list(_prefix: string): AsyncIterable<ObjectStat> {
throw new StorageBackendError('not implemented');
}
private client(): Promise<S3Api> {
// Cached across calls; a failed init clears the cache so the next call retries.
this.clientPromise ??= this.clientFactory(this.clientOptions).catch((err) => {
this.clientPromise = null;
throw new StorageBackendError(`s3 client init failed on '${this.id}'`, err);
});
return this.clientPromise;
}
private deadlined<T>(op: Promise<T>, what: string): Promise<T> {
let timer: NodeJS.Timeout | undefined;
const expiry = new Promise<never>((_, reject) => {
timer = setTimeout(
// Cannot abort the socket (aws-lite has no signal) — the call is
// rejected and a hung request lingers until the socket dies.
() => reject(new StorageBackendError(`${what} timed out after ${this.timeoutMs}ms on '${this.id}'`)),
this.timeoutMs,
);
timer.unref?.();
});
return Promise.race([op, expiry]).finally(() => clearTimeout(timer)) as Promise<T>;
}
private wrap(err: unknown, message: string): Error {
if (err instanceof StorageBackendError || err instanceof StorageNotFoundError) return err;
return new StorageBackendError(`${message} on '${this.id}'`, err);
}
}
/**
* '' stays ''; anything else becomes one or more slash-joined segments with a
* trailing slash, or throws StorageInvalidKeyError. app-config/env.ts's
* s3Preconditions validates the same slash-stripped shape at boot — keep the
* two strip-regexes identical (`/^\/+|\/+$/g`).
*/
function normalizeKeyPrefix(raw: string): string {
const trimmed = raw.replace(/^\/+|\/+$/g, '');
if (trimmed === '') return '';
assertValidPrefix(`${trimmed}/`);
return `${trimmed}/`;
}
@@ -0,0 +1,135 @@
import { describe, it, expect, vi } from 'vitest';
import {
S3Driver,
MULTIPART_THRESHOLD,
defaultClientFactory,
type S3Api,
type S3DriverOptions,
} from '../../../../src/nest/storage/drivers/s3.driver';
import {
StorageBackendError,
StorageInvalidKeyError,
StorageNotFoundError,
} from '../../../../src/nest/storage/storage.types';
/** Mock client: every method rejects unless a test overrides it. */
function makeMockApi(overrides: Partial<S3Api> = {}): S3Api {
const unexpected = (name: string) => vi.fn().mockRejectedValue(new Error(`unexpected ${name}`));
return {
PutObject: unexpected('PutObject'),
Upload: unexpected('Upload'),
GetObject: unexpected('GetObject'),
HeadObject: unexpected('HeadObject'),
DeleteObject: unexpected('DeleteObject'),
ListObjectsV2: unexpected('ListObjectsV2'),
...overrides,
} as S3Api;
}
function makeDriver(api: S3Api, opts: Partial<S3DriverOptions> = {}): S3Driver {
return new S3Driver({
id: 's3-test',
endpoint: 'http://127.0.0.1:9000',
region: 'us-east-1',
bucket: 'trek',
keyPrefix: '',
accessKeyId: 'ak',
secretAccessKey: 'sk',
retries: 1,
timeoutMs: 200,
clientFactory: async () => api,
...opts,
});
}
/** aws-lite error shape: real Error + statusCode/code metadata. */
function awsError(statusCode: number | undefined, code?: string): Error {
const err = new Error(`@aws-lite/client: S3: ${code ?? 'boom'}`) as Error & {
statusCode?: number;
code?: string;
};
err.statusCode = statusCode;
if (code) err.code = code;
return err;
}
describe('S3Driver construction', () => {
it('normalizes the key prefix to "" or "segments/" form', async () => {
const api = makeMockApi({ HeadObject: vi.fn().mockResolvedValue({ ContentLength: 1, LastModified: new Date(1000) }) });
await makeDriver(api, { keyPrefix: '/trek/prod/' }).stat('a/x.bin');
expect(api.HeadObject).toHaveBeenCalledWith(expect.objectContaining({ Key: 'trek/prod/a/x.bin' }));
});
it('rejects an invalid key prefix at construction', () => {
expect(() => makeDriver(makeMockApi(), { keyPrefix: '../evil' })).toThrow(StorageInvalidKeyError);
});
it('makes no client call at construction (boot must not touch the network)', () => {
const factory = vi.fn();
void new S3Driver({
id: 's3-test', endpoint: 'http://127.0.0.1:9000', region: 'us-east-1', bucket: 'trek',
keyPrefix: '', accessKeyId: 'ak', secretAccessKey: 'sk', retries: 1, timeoutMs: 200,
clientFactory: factory,
});
expect(factory).not.toHaveBeenCalled();
});
});
describe('S3Driver stat/delete', () => {
it('maps HeadObject to ObjectStat', async () => {
const api = makeMockApi({ HeadObject: vi.fn().mockResolvedValue({ ContentLength: 42, LastModified: new Date(5000) }) });
expect(await makeDriver(api).stat('a/x.bin')).toEqual({ key: 'a/x.bin', size: 42, mtimeMs: 5000 });
});
it('stats a 404/NotFound as null', async () => {
const api = makeMockApi({ HeadObject: vi.fn().mockRejectedValue(awsError(404, 'NotFound')) });
expect(await makeDriver(api).stat('a/x.bin')).toBeNull();
});
it('wraps network errors (no statusCode) in StorageBackendError with cause', async () => {
const cause = awsError(undefined);
const api = makeMockApi({ HeadObject: vi.fn().mockRejectedValue(cause) });
await expect(makeDriver(api).stat('a/x.bin')).rejects.toMatchObject({
name: 'StorageBackendError',
cause,
});
});
it('deletes idempotently — a 404 resolves', async () => {
const api = makeMockApi({ DeleteObject: vi.fn().mockRejectedValue(awsError(404, 'NoSuchKey')) });
await expect(makeDriver(api).delete('a/x.bin')).resolves.toBeUndefined();
});
it('validates keys before any client call', async () => {
const api = makeMockApi();
const driver = makeDriver(api);
for (const bad of ['../x', '/abs', 'a\\b', '.tmp/x']) {
await expect(driver.stat(bad)).rejects.toBeInstanceOf(StorageInvalidKeyError);
await expect(driver.delete(bad)).rejects.toBeInstanceOf(StorageInvalidKeyError);
}
expect(api.HeadObject).not.toHaveBeenCalled();
expect(api.DeleteObject).not.toHaveBeenCalled();
});
it('expires a hung call after timeoutMs with StorageBackendError', async () => {
const api = makeMockApi({ HeadObject: vi.fn().mockReturnValue(new Promise(() => {})) });
await expect(makeDriver(api, { timeoutMs: 50 }).stat('a/x.bin')).rejects.toBeInstanceOf(StorageBackendError);
});
it('caches the client across calls and retries a failed factory', async () => {
const api = makeMockApi({ HeadObject: vi.fn().mockResolvedValue({ ContentLength: 1, LastModified: new Date(0) }) });
const factory = vi
.fn()
.mockRejectedValueOnce(new Error('init boom'))
.mockResolvedValue(api);
const driver = makeDriver(api, { clientFactory: factory });
await expect(driver.stat('a/x.bin')).rejects.toBeInstanceOf(StorageBackendError);
await driver.stat('a/x.bin'); // second call retries the factory
await driver.stat('a/x.bin');
expect(factory).toHaveBeenCalledTimes(2);
});
});
describe('defaultClientFactory', () => {
it('builds a real aws-lite client exposing the S3 surface (no network at init)', async () => {
const s3 = await defaultClientFactory({
endpoint: 'http://127.0.0.1:1', region: 'us-east-1',
accessKeyId: 'ak', secretAccessKey: 'sk', retries: 0, keepAlive: false,
});
for (const method of ['PutObject', 'Upload', 'GetObject', 'HeadObject', 'DeleteObject', 'ListObjectsV2'] as const) {
expect(typeof s3[method]).toBe('function');
}
});
});