diff --git a/Directory.Build.props b/Directory.Build.props index d7ebca5..be60cef 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 3.2.0 + 3.3.0 3.1.0 12.0 enable diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 7faa085..b991ca3 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -2,6 +2,11 @@ These are the NuGet package releases. See also [npm Release Notes](ReleaseNotesNpm.md). +## 3.3.0 + +* Allow for request scoped services in fastify plugin. +* Make fastify plugin support "experimental" for now. + ## 3.2.0 * Support `float` field type. diff --git a/conformance/package-lock.json b/conformance/package-lock.json index 74552ef..40ba70c 100644 --- a/conformance/package-lock.json +++ b/conformance/package-lock.json @@ -10,18 +10,18 @@ "license": "UNLICENSED", "dependencies": { "facility-core": "file:../ts", - "fastify": "^4.25.1" + "fastify": "^5.2.1" }, "devDependencies": { "@types/chai": "^4.2.18", "@types/mocha": "^8.2.2", - "@types/node": "^12.20.15", + "@types/node": "^22.1.0", "@types/node-fetch": "^2.5.10", "chai": "^4.3.4", - "fastify-cli": "^5.9.0", + "fastify-cli": "^7.3.0", "mocha": "^10.0.0", "node-fetch": "^2.6.7", - "typescript": "^5.2.2" + "typescript": "^5.7.2" } }, "../../ts": { @@ -46,31 +46,84 @@ } }, "node_modules/@fastify/ajv-compiler": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/@fastify/ajv-compiler/-/ajv-compiler-3.5.0.tgz", - "integrity": "sha512-ebbEtlI7dxXF5ziNdr05mOY8NnDiPB1XvAlLHctRt/Rc+C3LCOVW5imUVX+mhvUhnNzmPBHewUkOFgGlCxgdAA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@fastify/ajv-compiler/-/ajv-compiler-4.0.2.tgz", + "integrity": "sha512-Rkiu/8wIjpsf46Rr+Fitd3HRP+VsxUFDDeag0hs9L0ksfnwx2g7SPQQTFL0E8Qv+rfXzQOxBJnjUB9ITUDjfWQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "dependencies": { - "ajv": "^8.11.0", - "ajv-formats": "^2.1.1", - "fast-uri": "^2.0.0" + "ajv": "^8.12.0", + "ajv-formats": "^3.0.1", + "fast-uri": "^3.0.0" } }, "node_modules/@fastify/deepmerge": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@fastify/deepmerge/-/deepmerge-1.3.0.tgz", - "integrity": "sha512-J8TOSBq3SoZbDhM9+R/u77hP93gz/rajSA+K2kGyijPpORPWUXHUpTaleoj+92As0S9uPRP7Oi8IqMf0u+ro6A==" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@fastify/deepmerge/-/deepmerge-2.0.1.tgz", + "integrity": "sha512-hx+wJQr9Ph1hY/dyzY0SxqjumMyqZDlIF6oe71dpRKDHUg7dFQfjG94qqwQ274XRjmUrwKiYadex8XplNHx3CA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ] }, "node_modules/@fastify/error": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/@fastify/error/-/error-3.4.1.tgz", - "integrity": "sha512-wWSvph+29GR783IhmvdwWnN4bUxTD01Vm5Xad4i7i1VuAOItLvbPAb69sb0IQ2N57yprvhNIwAP5B6xfKTmjmQ==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@fastify/error/-/error-4.0.0.tgz", + "integrity": "sha512-OO/SA8As24JtT1usTUTKgGH7uLvhfwZPwlptRi2Dp5P4KKmJI3gvsZ8MIHnNwDs4sLf/aai5LzTyl66xr7qMxA==" }, "node_modules/@fastify/fast-json-stringify-compiler": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@fastify/fast-json-stringify-compiler/-/fast-json-stringify-compiler-4.3.0.tgz", - "integrity": "sha512-aZAXGYo6m22Fk1zZzEUKBvut/CIIQe/BapEORnxiD5Qr0kPHqqI69NtEMCme74h+at72sPhbkb4ZrLd1W3KRLA==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@fastify/fast-json-stringify-compiler/-/fast-json-stringify-compiler-5.0.2.tgz", + "integrity": "sha512-YdR7gqlLg1xZAQa+SX4sMNzQHY5pC54fu9oC5aYSUqBhyn6fkLkrdtKlpVdCNPlwuUuXA1PjFTEmvMF6ZVXVGw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "dependencies": { + "fast-json-stringify": "^6.0.0" + } + }, + "node_modules/@fastify/forwarded": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@fastify/forwarded/-/forwarded-3.0.0.tgz", + "integrity": "sha512-kJExsp4JCms7ipzg7SJ3y8DwmePaELHxKYtg+tZow+k0znUTf3cb+npgyqm8+ATZOdmfgfydIebPDWM172wfyA==" + }, + "node_modules/@fastify/merge-json-schemas": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@fastify/merge-json-schemas/-/merge-json-schemas-0.1.1.tgz", + "integrity": "sha512-fERDVz7topgNjtXsJTTW1JKLy0rhuLRcquYqNR9rF7OcVpCa2OVW49ZPDIhaRRCaUuvVxI+N416xUoF76HNSXA==", + "dependencies": { + "fast-deep-equal": "^3.1.3" + } + }, + "node_modules/@fastify/proxy-addr": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@fastify/proxy-addr/-/proxy-addr-5.0.0.tgz", + "integrity": "sha512-37qVVA1qZ5sgH7KpHkkC4z9SK6StIsIcOmpjvMPXNb3vx2GQxhZocogVYbr2PbbeLCQxYIPDok307xEvRZOzGA==", "dependencies": { - "fast-json-stringify": "^5.7.0" + "@fastify/forwarded": "^3.0.0", + "ipaddr.js": "^2.1.0" } }, "node_modules/@types/chai": { @@ -86,10 +139,13 @@ "dev": true }, "node_modules/@types/node": { - "version": "12.20.55", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", - "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==", - "dev": true + "version": "22.10.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.5.tgz", + "integrity": "sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ==", + "dev": true, + "dependencies": { + "undici-types": "~6.20.0" + } }, "node_modules/@types/node-fetch": { "version": "2.6.9", @@ -105,6 +161,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dev": true, "dependencies": { "event-target-shim": "^5.0.0" }, @@ -118,14 +175,14 @@ "integrity": "sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA==" }, "node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dependencies": { - "fast-deep-equal": "^3.1.1", + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" + "require-from-string": "^2.0.2" }, "funding": { "type": "github", @@ -133,9 +190,9 @@ } }, "node_modules/ajv-formats": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", - "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", "dependencies": { "ajv": "^8.0.0" }, @@ -194,11 +251,6 @@ "node": ">= 8" } }, - "node_modules/archy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", - "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==" - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -229,13 +281,12 @@ } }, "node_modules/avvio": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/avvio/-/avvio-8.2.1.tgz", - "integrity": "sha512-TAlMYvOuwGyLK3PfBb5WKBXZmXz2fVCgv23d6zZFdle/q3gPjmxBaeuC0pY0Dzs5PWMSgfqqEZkrye19GlDTgw==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/avvio/-/avvio-9.1.0.tgz", + "integrity": "sha512-fYASnYi600CsH/j9EQov7lECAniYiBFiiAtBNuZYLA2leLe9qOvZzqYHFjtIj6gD2VMoMLP14834LFWvr4IfDw==", "dependencies": { - "archy": "^1.0.0", - "debug": "^4.0.0", - "fastq": "^1.6.1" + "@fastify/error": "^4.0.0", + "fastq": "^1.17.1" } }, "node_modules/balanced-match": { @@ -248,6 +299,7 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, "funding": [ { "type": "github", @@ -303,6 +355,7 @@ "version": "6.0.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "dev": true, "funding": [ { "type": "github", @@ -431,9 +484,9 @@ } }, "node_modules/close-with-grace": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/close-with-grace/-/close-with-grace-1.2.0.tgz", - "integrity": "sha512-Xga0jyAb4fX98u5pZAgqlbqHP8cHuy5M3Wto0k0L/36aP2C25Cjp51XfPw3Hz7dNC2L2/hF/PK/KJhO275L+VA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/close-with-grace/-/close-with-grace-2.1.0.tgz", + "integrity": "sha512-rME1AtzKc9dfpLr8XBVhXqhVZDvtaIA7FIpjPaO+DmDsomaTNtuEBZMoNDgIvjHYK5q8/Afxy34YTXInUBsT1A==", "dev": true }, "node_modules/color-convert": { @@ -485,11 +538,11 @@ "dev": true }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz", + "integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==", "engines": { - "node": ">= 0.6" + "node": ">=18" } }, "node_modules/dateformat": { @@ -505,6 +558,7 @@ "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, "dependencies": { "ms": "2.1.2" }, @@ -520,7 +574,8 @@ "node_modules/debug/node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true }, "node_modules/decamelize": { "version": "4.0.0", @@ -616,6 +671,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "dev": true, "engines": { "node": ">=6" } @@ -624,6 +680,7 @@ "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, "engines": { "node": ">=0.8.x" } @@ -632,15 +689,10 @@ "resolved": "../ts", "link": true }, - "node_modules/fast-content-type-parse": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-1.1.0.tgz", - "integrity": "sha512-fBHHqSTFLVnR61C+gltJuE5GkVQMV0S2nqUO8TJ+5Z3qAKG8vAx4FKai1s5jq/inV1+sREynIWSuQ6HgoSXpDQ==" - }, "node_modules/fast-copy": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-3.0.1.tgz", - "integrity": "sha512-Knr7NOtK3HWRYGtHoJrjkaWepqT8thIVGAwt0p0aUs1zqkAzXZV4vo9fFNwyb5fcqK1GKYFYxldQdIDVKhUAfA==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-3.0.2.tgz", + "integrity": "sha512-dl0O9Vhju8IrcLndv2eU4ldt1ftXMqqfgN4H1cpmGV7P6jeB9FwpN9a2c8DPGE1Ys88rNUJVYDHq73CGAGOPfQ==", "dev": true }, "node_modules/fast-decode-uri-component": { @@ -654,19 +706,24 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "node_modules/fast-json-stringify": { - "version": "5.9.1", - "resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-5.9.1.tgz", - "integrity": "sha512-NMrf+uU9UJnTzfxaumMDXK1NWqtPCfGoM9DYIE+ESlaTQqjlANFBy0VAbsm6FB88Mx0nceyi18zTo5kIEUlzxg==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-6.0.0.tgz", + "integrity": "sha512-FGMKZwniMTgZh7zQp9b6XnBVxUmKVahQLQeRQHqwYmPDqDhcEKZ3BaQsxelFFI5PY7nN71OEeiL47/zUWcYe1A==", "dependencies": { - "@fastify/deepmerge": "^1.0.0", - "ajv": "^8.10.0", - "ajv-formats": "^2.1.1", + "@fastify/merge-json-schemas": "^0.1.1", + "ajv": "^8.12.0", + "ajv-formats": "^3.0.1", "fast-deep-equal": "^3.1.3", - "fast-uri": "^2.1.0", + "fast-uri": "^2.3.0", "json-schema-ref-resolver": "^1.0.1", "rfdc": "^1.2.0" } }, + "node_modules/fast-json-stringify/node_modules/fast-uri": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-2.4.0.tgz", + "integrity": "sha512-ypuAmmMKInk5q7XcepxlnUWDLWv4GFtaJqAzWKqn62IpQ3pejtr5dTVbt3vwqVaMKmkNR55sTT+CqUKIaT21BA==" + }, "node_modules/fast-querystring": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/fast-querystring/-/fast-querystring-1.1.2.tgz", @@ -676,9 +733,9 @@ } }, "node_modules/fast-redact": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.3.0.tgz", - "integrity": "sha512-6T5V1QK1u4oF+ATxs1lWUmlEk6P2T9HqJG3e2DnHOdVgZy2rFJBoEnrIedcTXlkAHU/zKC+7KETJ+KGGKwxgMQ==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.5.0.tgz", + "integrity": "sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==", "engines": { "node": ">=6" } @@ -690,52 +747,70 @@ "dev": true }, "node_modules/fast-uri": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-2.3.0.tgz", - "integrity": "sha512-eel5UKGn369gGEWOqBShmFJWfq/xSJvsgDzgLYC845GneayWvXBf0lJCBn5qTABfewy1ZDPoaR5OZCP+kssfuw==" + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.5.tgz", + "integrity": "sha512-5JnBCWpFlMo0a3ciDy/JckMzzv1U9coZrIhedq+HXxxUfDTAiS0LA8OKVao4G9BxmCVck/jtA5r3KAtRWEyD8Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ] }, "node_modules/fastify": { - "version": "4.25.1", - "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.25.1.tgz", - "integrity": "sha512-D8d0rv61TwqoAS7lom2tvIlgVMlx88lLsiwXyWNjA7CU/LC/mx/Gp2WAlC0S/ABq19U+y/aRvYFG5xLUu2aMrg==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/fastify/-/fastify-5.2.1.tgz", + "integrity": "sha512-rslrNBF67eg8/Gyn7P2URV8/6pz8kSAscFL4EThZJ8JBMaXacVdVE4hmUcnPNKERl5o/xTiBSLfdowBRhVF1WA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "dependencies": { - "@fastify/ajv-compiler": "^3.5.0", - "@fastify/error": "^3.4.0", - "@fastify/fast-json-stringify-compiler": "^4.3.0", + "@fastify/ajv-compiler": "^4.0.0", + "@fastify/error": "^4.0.0", + "@fastify/fast-json-stringify-compiler": "^5.0.0", + "@fastify/proxy-addr": "^5.0.0", "abstract-logging": "^2.0.1", - "avvio": "^8.2.1", - "fast-content-type-parse": "^1.1.0", - "fast-json-stringify": "^5.8.0", - "find-my-way": "^7.7.0", - "light-my-request": "^5.11.0", - "pino": "^8.17.0", - "process-warning": "^3.0.0", - "proxy-addr": "^2.0.7", - "rfdc": "^1.3.0", - "secure-json-parse": "^2.7.0", - "semver": "^7.5.4", - "toad-cache": "^3.3.0" + "avvio": "^9.0.0", + "fast-json-stringify": "^6.0.0", + "find-my-way": "^9.0.0", + "light-my-request": "^6.0.0", + "pino": "^9.0.0", + "process-warning": "^4.0.0", + "rfdc": "^1.3.1", + "secure-json-parse": "^3.0.1", + "semver": "^7.6.0", + "toad-cache": "^3.7.0" } }, "node_modules/fastify-cli": { - "version": "5.9.0", - "resolved": "https://registry.npmjs.org/fastify-cli/-/fastify-cli-5.9.0.tgz", - "integrity": "sha512-CaIte5SwkLuvlzpdd1Al1VRVVwm2TQVV4bfVP4oz/Z54KVSo6pqNTgnxWOmyzdcNUbFnhJ3Z4vRjzvHoymP5cQ==", + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/fastify-cli/-/fastify-cli-7.3.0.tgz", + "integrity": "sha512-4QMW3VeCxysR0E/Hc1MA69G61LENeKdlaLymOUH5uFWPczKMC3Ngzr9A/zWfrzeSF47SOp/SZOLgdauRkGh8xg==", "dev": true, "dependencies": { - "@fastify/deepmerge": "^1.2.0", + "@fastify/deepmerge": "^2.0.0", "chalk": "^4.1.2", - "chokidar": "^3.5.2", - "close-with-grace": "^1.1.0", + "chokidar": "^4.0.0", + "close-with-grace": "^2.1.0", "commist": "^3.0.0", "dotenv": "^16.0.0", - "fastify": "^4.0.0", - "fastify-plugin": "^4.0.0", + "fastify": "^5.0.0", + "fastify-plugin": "^5.0.0", "generify": "^4.0.0", "help-me": "^4.0.1", "is-docker": "^2.0.0", - "make-promises-safe": "^5.1.0", - "pino-pretty": "^10.1.0", + "pino-pretty": "^11.2.0", "pkg-up": "^3.1.0", "resolve-from": "^5.0.0", "semver": "^7.3.5", @@ -745,6 +820,34 @@ "fastify": "cli.js" } }, + "node_modules/fastify-cli/node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dev": true, + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/fastify-cli/node_modules/readdirp": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.0.2.tgz", + "integrity": "sha512-yDMz9g+VaZkqBYS/ozoBJwaBhTbZo3UNYQHNRw1D3UFQB8oHB4uS/tAODO+ZLjGWmUbKnIlOWO+aaIiAxrUWHA==", + "dev": true, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/fastify-cli/node_modules/yargs-parser": { "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", @@ -755,15 +858,30 @@ } }, "node_modules/fastify-plugin": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-4.5.1.tgz", - "integrity": "sha512-stRHYGeuqpEZTL1Ef0Ovr2ltazUT9g844X5z/zEBFLG8RYlpDiOCIG+ATvYEp+/zmc7sN29mcIMp8gvYplYPIQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-5.0.1.tgz", + "integrity": "sha512-HCxs+YnRaWzCl+cWRYFnHmeRFyR5GVnJTAaCJQiYzQSDwK9MgJdyAsuL3nh0EWRCYMgQ5MeziymvmAhUHYHDUQ==", "dev": true }, + "node_modules/fastify/node_modules/secure-json-parse": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-3.0.2.tgz", + "integrity": "sha512-H6nS2o8bWfpFEV6U38sOSjS7bTbdgbCGU9wEM6W14P5H0QOsz94KCusifV44GpHDTu2nqZbuDNhTzu+mjDSw1w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ] + }, "node_modules/fastq": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", - "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.18.0.tgz", + "integrity": "sha512-QKHXPW0hD8g4UET03SdOdunzSouc9N4AuHdsX8XNcTsuz+yYFILVNIX4l9yHABMhiEI9Db0JTTIpu0wB+Y1QQw==", "dependencies": { "reusify": "^1.0.4" } @@ -781,13 +899,13 @@ } }, "node_modules/find-my-way": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-7.7.0.tgz", - "integrity": "sha512-+SrHpvQ52Q6W9f3wJoJBbAQULJuNEEQwBvlvYwACDhBTLOTMiQ0HYWh4+vC3OivGP2ENcTI1oKlFA2OepJNjhQ==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-9.1.0.tgz", + "integrity": "sha512-Y5jIsuYR4BwWDYYQ2A/RWWE6gD8a0FMgtU+HOq1WKku+Cwdz8M1v8wcAmRXXM1/iqtoqg06v+LjAxMYbCjViMw==", "dependencies": { "fast-deep-equal": "^3.1.3", "fast-querystring": "^1.0.0", - "safe-regex2": "^2.0.0" + "safe-regex2": "^4.0.0" }, "engines": { "node": ">=14" @@ -832,14 +950,6 @@ "node": ">= 6" } }, - "node_modules/forwarded": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", - "engines": { - "node": ">= 0.6" - } - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1035,6 +1145,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, "funding": [ { "type": "github", @@ -1067,11 +1178,11 @@ "dev": true }, "node_modules/ipaddr.js": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.2.0.tgz", + "integrity": "sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA==", "engines": { - "node": ">= 0.10" + "node": ">= 10" } }, "node_modules/is-binary-path": { @@ -1208,20 +1319,15 @@ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, "node_modules/light-my-request": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-5.11.0.tgz", - "integrity": "sha512-qkFCeloXCOMpmEdZ/MV91P8AT4fjwFXWaAFz3lUeStM8RcoM1ks4J/F8r1b3r6y/H4u3ACEJ1T+Gv5bopj7oDA==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-6.4.0.tgz", + "integrity": "sha512-U0UONITz4GVQodMPoygnqJan2RYfhyLsCzFBakJHWNfiQKyHzvp38YOxxLGs8lIDPwR6ngd4gmuZJQQJtRBu/A==", "dependencies": { - "cookie": "^0.5.0", - "process-warning": "^2.0.0", - "set-cookie-parser": "^2.4.1" + "cookie": "^1.0.1", + "process-warning": "^4.0.0", + "set-cookie-parser": "^2.6.0" } }, - "node_modules/light-my-request/node_modules/process-warning": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-2.3.2.tgz", - "integrity": "sha512-n9wh8tvBe5sFmsqlg+XQhaQLumwpqoAUruLwjCopgTmUBjJ/fjtBsJzKleCaIGBOMXYEhp1YfKl4d7rJ5ZKJGA==" - }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -1262,23 +1368,6 @@ "get-func-name": "^2.0.1" } }, - "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/make-promises-safe": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/make-promises-safe/-/make-promises-safe-5.1.0.tgz", - "integrity": "sha512-AfdZ49rtyhQR/6cqVKGoH7y4ql7XkS5HJI1lZm0/5N6CQosy1eYbBJ/qbhkKHzo17UH7M918Bysf6XB9f3kS1g==", - "dev": true - }, "node_modules/makeerror": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", @@ -1513,54 +1602,53 @@ } }, "node_modules/pino": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/pino/-/pino-8.17.1.tgz", - "integrity": "sha512-YoN7/NJgnsJ+fkADZqjhRt96iepWBndQHeClmSBH0sQWCb8zGD74t00SK4eOtKFi/f8TUmQnfmgglEhd2kI1RQ==", + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-9.6.0.tgz", + "integrity": "sha512-i85pKRCt4qMjZ1+L7sy2Ag4t1atFcdbEt76+7iRJn1g2BvsnRMGu9p8pivl9fs63M2kF/A0OacFZhTub+m/qMg==", "dependencies": { "atomic-sleep": "^1.0.0", "fast-redact": "^3.1.1", "on-exit-leak-free": "^2.1.0", - "pino-abstract-transport": "v1.1.0", - "pino-std-serializers": "^6.0.0", - "process-warning": "^2.0.0", + "pino-abstract-transport": "^2.0.0", + "pino-std-serializers": "^7.0.0", + "process-warning": "^4.0.0", "quick-format-unescaped": "^4.0.3", "real-require": "^0.2.0", "safe-stable-stringify": "^2.3.1", - "sonic-boom": "^3.7.0", - "thread-stream": "^2.0.0" + "sonic-boom": "^4.0.1", + "thread-stream": "^3.0.0" }, "bin": { "pino": "bin.js" } }, "node_modules/pino-abstract-transport": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-1.1.0.tgz", - "integrity": "sha512-lsleG3/2a/JIWUtf9Q5gUNErBqwIu1tUKTT3dUzaf5DySw9ra1wcqKjJjLX1VTY64Wk1eEOYsVGSaGfCK85ekA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-2.0.0.tgz", + "integrity": "sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==", "dependencies": { - "readable-stream": "^4.0.0", "split2": "^4.0.0" } }, "node_modules/pino-pretty": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-10.3.0.tgz", - "integrity": "sha512-JthvQW289q3454mhM3/38wFYGWPiBMR28T3CpDNABzoTQOje9UKS7XCJQSnjWF9LQGQkGd8D7h0oq+qwiM3jFA==", + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-11.3.0.tgz", + "integrity": "sha512-oXwn7ICywaZPHmu3epHGU2oJX4nPmKvHvB/bwrJHlGcbEWaVcotkpyVHMKLKmiVryWYByNp0jpgAcXpFJDXJzA==", "dev": true, "dependencies": { "colorette": "^2.0.7", "dateformat": "^4.6.3", - "fast-copy": "^3.0.0", + "fast-copy": "^3.0.2", "fast-safe-stringify": "^2.1.1", "help-me": "^5.0.0", "joycon": "^3.1.1", "minimist": "^1.2.6", "on-exit-leak-free": "^2.1.0", - "pino-abstract-transport": "^1.0.0", + "pino-abstract-transport": "^2.0.0", "pump": "^3.0.0", "readable-stream": "^4.0.0", "secure-json-parse": "^2.4.0", - "sonic-boom": "^3.0.0", + "sonic-boom": "^4.0.1", "strip-json-comments": "^3.1.1" }, "bin": { @@ -1574,14 +1662,9 @@ "dev": true }, "node_modules/pino-std-serializers": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-6.2.2.tgz", - "integrity": "sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA==" - }, - "node_modules/pino/node_modules/process-warning": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-2.3.2.tgz", - "integrity": "sha512-n9wh8tvBe5sFmsqlg+XQhaQLumwpqoAUruLwjCopgTmUBjJ/fjtBsJzKleCaIGBOMXYEhp1YfKl4d7rJ5ZKJGA==" + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.0.0.tgz", + "integrity": "sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==" }, "node_modules/pkg-up": { "version": "3.1.0", @@ -1660,26 +1743,25 @@ "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "dev": true, "engines": { "node": ">= 0.6.0" } }, "node_modules/process-warning": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-3.0.0.tgz", - "integrity": "sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==" - }, - "node_modules/proxy-addr": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", - "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", - "dependencies": { - "forwarded": "0.2.0", - "ipaddr.js": "1.9.1" - }, - "engines": { - "node": ">= 0.10" - } + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-4.0.1.tgz", + "integrity": "sha512-3c2LzQ3rY9d0hc1emcsHhfT9Jwz0cChib/QN89oME2R451w5fy3f0afAhERFZAwrbDU43wk12d0ORBpDVME50Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ] }, "node_modules/pump": { "version": "3.0.0", @@ -1691,14 +1773,6 @@ "once": "^1.3.1" } }, - "node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "engines": { - "node": ">=6" - } - }, "node_modules/quick-format-unescaped": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", @@ -1714,9 +1788,10 @@ } }, "node_modules/readable-stream": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.4.2.tgz", - "integrity": "sha512-Lk/fICSyIhodxy1IDK2HazkeGjSmezAWX2egdtJnYhtzKEsBPJowlI6F6LPb5tqIQILrMbx22S5o3GuJavPusA==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz", + "integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==", + "dev": true, "dependencies": { "abort-controller": "^3.0.0", "buffer": "^6.0.3", @@ -1775,11 +1850,11 @@ } }, "node_modules/ret": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.2.2.tgz", - "integrity": "sha512-M0b3YWQs7R3Z917WRQy1HHA7Ba7D8hvZg6UE5mLykJxQVE2ju0IXbGlaHPPlkY+WN7wFP+wUMXmBFA0aV6vYGQ==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.5.0.tgz", + "integrity": "sha512-I1XxrZSQ+oErkRR4jYbAyEEu2I0avBvvMM5JN+6EBprOGRCs63ENqZ3vjavq8fBw2+62G5LF5XelKwuJpcvcxw==", "engines": { - "node": ">=4" + "node": ">=10" } }, "node_modules/reusify": { @@ -1792,14 +1867,15 @@ } }, "node_modules/rfdc": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", - "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", + "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==" }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, "funding": [ { "type": "github", @@ -1816,17 +1892,27 @@ ] }, "node_modules/safe-regex2": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/safe-regex2/-/safe-regex2-2.0.0.tgz", - "integrity": "sha512-PaUSFsUaNNuKwkBijoAPHAK6/eM6VirvyPWlZ7BAQy4D+hCvh4B6lIG+nPdhbFfIbP+gTGBcrdsOaUs0F+ZBOQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/safe-regex2/-/safe-regex2-4.0.1.tgz", + "integrity": "sha512-goqsB+bSlOmVX+CiFX2PFc1OV88j5jvBqIM+DgqrucHnUguAUNtiNOs+aTadq2NqsLQ+TQ3UEVG3gtSFcdlkCg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "dependencies": { - "ret": "~0.2.0" + "ret": "~0.5.0" } }, "node_modules/safe-stable-stringify": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.3.tgz", - "integrity": "sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", "engines": { "node": ">=10" } @@ -1834,15 +1920,13 @@ "node_modules/secure-json-parse": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.7.0.tgz", - "integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==" + "integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==", + "dev": true }, "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "bin": { "semver": "bin/semver.js" }, @@ -1860,14 +1944,14 @@ } }, "node_modules/set-cookie-parser": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz", - "integrity": "sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==" + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz", + "integrity": "sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==" }, "node_modules/sonic-boom": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-3.7.0.tgz", - "integrity": "sha512-IudtNvSqA/ObjN97tfgNmOKyDOs4dNcg4cUUsHDebqsgb8wGBBwb31LIgShNO8fye0dFI52X1+tFoKKI6Rq1Gg==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.0.tgz", + "integrity": "sha512-INb7TM37/mAcsGmc9hyyI6+QR3rR1zVRu36B0NeGXKnOOLiZOfER5SA+N7X7k3yUYRzLWafduTDvJAfDswwEww==", "dependencies": { "atomic-sleep": "^1.0.0" } @@ -1884,6 +1968,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, "dependencies": { "safe-buffer": "~5.2.0" } @@ -1942,9 +2027,9 @@ } }, "node_modules/thread-stream": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-2.4.1.tgz", - "integrity": "sha512-d/Ex2iWd1whipbT681JmTINKw0ZwOUBZm7+Gjs64DHuX34mmw8vJL2bFAaNacaW72zYiTJxSHi5abUuOi5nsfg==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.1.0.tgz", + "integrity": "sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==", "dependencies": { "real-require": "^0.2.0" } @@ -1968,9 +2053,9 @@ } }, "node_modules/toad-cache": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/toad-cache/-/toad-cache-3.4.1.tgz", - "integrity": "sha512-T0m3MxP3wcqW0LaV3dF1mHBU294sgYSm4FOpa5eEJaYO7PqJZBOjZEQI1y4YaKNnih1FXCEYTWDS9osCoTUefg==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/toad-cache/-/toad-cache-3.7.0.tgz", + "integrity": "sha512-/m8M+2BJUpoJdgAHoG+baCwBT+tf2VraSfkBgl0Y00qIWt41DJ8R5B8nsEw0I58YwF5IZH6z24/2TobDKnqSWw==", "engines": { "node": ">=12" } @@ -1991,9 +2076,9 @@ } }, "node_modules/typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -2003,13 +2088,11 @@ "node": ">=14.17" } }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dependencies": { - "punycode": "^2.1.0" - } + "node_modules/undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "dev": true }, "node_modules/util-deprecate": { "version": "1.0.2", @@ -2080,11 +2163,6 @@ "node": ">=10" } }, - "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", diff --git a/conformance/package.json b/conformance/package.json index 9f58ec8..beba4c2 100644 --- a/conformance/package.json +++ b/conformance/package.json @@ -16,16 +16,16 @@ "devDependencies": { "@types/chai": "^4.2.18", "@types/mocha": "^8.2.2", - "@types/node": "^12.20.15", + "@types/node": "^22.1.0", "@types/node-fetch": "^2.5.10", "chai": "^4.3.4", - "fastify-cli": "^5.9.0", + "fastify-cli": "^7.3.0", "mocha": "^10.0.0", "node-fetch": "^2.6.7", - "typescript": "^5.2.2" + "typescript": "^5.7.2" }, "dependencies": { "facility-core": "file:../ts", - "fastify": "^4.25.1" + "fastify": "^5.2.1" } } diff --git a/conformance/src/fastify/app.ts b/conformance/src/fastify/app.ts index 6612dea..4dfe94f 100644 --- a/conformance/src/fastify/app.ts +++ b/conformance/src/fastify/app.ts @@ -6,7 +6,8 @@ import { jsConformanceApiPlugin } from "./jsConformanceApiPlugin.js"; const app: FastifyPluginAsync = async (fastify): Promise => { const conformanceApiPluginOptions: ConformanceApiPluginOptions = { - api: new ConformanceApiService(conformanceTestsJson.tests), + serviceOrFactory: () => + new ConformanceApiService(conformanceTestsJson.tests), caseInsenstiveQueryStringKeys: true, includeErrorDetails: true, }; diff --git a/conformance/src/fastify/conformanceApiPlugin.ts b/conformance/src/fastify/conformanceApiPlugin.ts index e831ad0..dc070c6 100644 --- a/conformance/src/fastify/conformanceApiPlugin.ts +++ b/conformance/src/fastify/conformanceApiPlugin.ts @@ -1,45 +1,25 @@ // DO NOT EDIT: generated by fsdgenjs /* eslint-disable */ -import { FastifyPluginAsync, RegisterOptions } from 'fastify'; -import { IServiceResult, IServiceError } from 'facility-core'; +import type * as fastifyTypes from 'fastify'; +import type { IServiceResult, IServiceError } from 'facility-core'; -const standardErrorCodes: { [code: string]: number } = { - 'NotModified': 304, - 'InvalidRequest': 400, - 'NotAuthenticated': 401, - 'NotAuthorized': 403, - 'NotFound': 404, - 'Conflict': 409, - 'RequestTooLarge': 413, - 'TooManyRequests': 429, - 'InternalError': 500, - 'ServiceUnavailable': 503, - 'NotAdmin': 403, - 'TooHappy': 500, -}; +export type ConformanceApiPluginOptions = fastifyTypes.RegisterOptions & { + /** The `IConformanceApi` service implementation. Can be a service instance or a factory function which is called on each request. */ + serviceOrFactory: IConformanceApi | ((req: fastifyTypes.FastifyRequest) => IConformanceApi); -function parseBoolean(value: string | undefined) { - if (typeof value === 'string') { - const lowerValue = value.toLowerCase(); - if (lowerValue === 'true') { - return true; - } - if (lowerValue === 'false') { - return false; - } - } - return undefined; -} - -export type ConformanceApiPluginOptions = RegisterOptions & { - api: IConformanceApi; + /** Whether to make query string keys case insensitive. Defalts to false. */ caseInsenstiveQueryStringKeys?: boolean; + + /** Whether to include error details in the response. Defaults to false. */ includeErrorDetails?: boolean; } -export const conformanceApiPlugin: FastifyPluginAsync = async (fastify, opts) => { - const { api, caseInsenstiveQueryStringKeys, includeErrorDetails } = opts; +/** EXPERIMENTAL: The generated code for this plugin is subject to change/removal without a major version bump. */ +export const conformanceApiPlugin: fastifyTypes.FastifyPluginAsync = async (fastify, opts) => { + const { serviceOrFactory, caseInsenstiveQueryStringKeys, includeErrorDetails } = opts; + + const getService = typeof serviceOrFactory === 'function' ? serviceOrFactory : () => serviceOrFactory; for (const jsonSchema of jsonSchemas) { fastify.addSchema(jsonSchema); @@ -70,7 +50,7 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; - const result = await api.getApiInfo(request); + const result = await getService(req).getApiInfo(request as IGetApiInfoRequest); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -125,12 +105,12 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; const query = req.query as Record; if (typeof query['q'] === 'string') request.query = query['q']; - const result = await api.getWidgets(request); + const result = await getService(req).getWidgets(request as IGetWidgetsRequest); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -156,11 +136,11 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; request.widget = req.body as never; - const result = await api.createWidget(request); + const result = await getService(req).createWidget(request as ICreateWidgetRequest); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -192,7 +172,7 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; const params = req.params as Record; if (typeof params['id'] === 'string') request.id = parseInt(params['id'], 10); @@ -200,7 +180,7 @@ export const conformanceApiPlugin: FastifyPluginAsync; if (typeof headers['if-none-match'] === 'string') request.ifNotETag = headers['if-none-match']; - const result = await api.getWidget(request); + const result = await getService(req).getWidget(request as IGetWidgetRequest); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -237,7 +217,7 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; const params = req.params as Record; if (typeof params['id'] === 'string') request.id = parseInt(params['id'], 10); @@ -245,7 +225,7 @@ export const conformanceApiPlugin: FastifyPluginAsync; if (typeof headers['if-match'] === 'string') request.ifETag = headers['if-match']; - const result = await api.deleteWidget(request); + const result = await getService(req).deleteWidget(request as IDeleteWidgetRequest); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -281,11 +261,11 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; request.ids = req.body as never; - const result = await api.getWidgetBatch(request); + const result = await getService(req).getWidgetBatch(request as IGetWidgetBatchRequest); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -319,13 +299,13 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; const body = req.body as Record; request.field = body.field; request.matrix = body.matrix; - const result = await api.mirrorFields(request); + const result = await getService(req).mirrorFields(request as IMirrorFieldsRequest); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -351,7 +331,7 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; const query = req.query as Record; if (typeof query['string'] === 'string') request.string = query['string']; @@ -364,7 +344,7 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; const params = req.params as Record; if (typeof params['string'] === 'string') request.string = params['string']; @@ -403,7 +383,7 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; const headers = req.headers as Record; if (typeof headers['string'] === 'string') request.string = headers['string']; @@ -442,7 +422,7 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; const params = req.params as Record; if (typeof params['path'] === 'string') request.path = params['path']; @@ -499,7 +479,7 @@ export const conformanceApiPlugin: FastifyPluginAsync; request.normal = body.normal; - const result = await api.mixed(request); + const result = await getService(req).mixed(request as IMixedRequest); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -542,7 +522,7 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; const query = req.query as Record; if (typeof query['query'] === 'string') request.query = query['query']; @@ -558,7 +538,7 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; const headers = req.headers as Record; if (typeof headers['content-type'] === 'string') request.type = headers['content-type']; request.content = req.body as never; - const result = await api.mirrorBytes(request); + const result = await getService(req).mirrorBytes(request as IMirrorBytesRequest); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -621,14 +601,14 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; const headers = req.headers as Record; if (typeof headers['content-type'] === 'string') request.type = headers['content-type']; request.content = req.body as never; - const result = await api.mirrorText(request); + const result = await getService(req).mirrorText(request as IMirrorTextRequest); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -658,11 +638,11 @@ export const conformanceApiPlugin: FastifyPluginAsync = {}; request.content = req.body as never; - const result = await api.bodyTypes(request); + const result = await getService(req).bodyTypes(request as IBodyTypesRequest); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -829,6 +809,34 @@ const jsonSchemas = [ } as const, ] as const; +const standardErrorCodes: { [code: string]: number } = { + 'NotModified': 304, + 'InvalidRequest': 400, + 'NotAuthenticated': 401, + 'NotAuthorized': 403, + 'NotFound': 404, + 'Conflict': 409, + 'RequestTooLarge': 413, + 'TooManyRequests': 429, + 'InternalError': 500, + 'ServiceUnavailable': 503, + 'NotAdmin': 403, + 'TooHappy': 500, +}; + +function parseBoolean(value: string | undefined) { + if (typeof value === 'string') { + const lowerValue = value.toLowerCase(); + if (lowerValue === 'true') { + return true; + } + if (lowerValue === 'false') { + return false; + } + } + return undefined; +} + /** API for a Facility test server. */ export interface IConformanceApi { /** Gets API information. */ diff --git a/conformance/src/fastify/jsConformanceApiPlugin.js b/conformance/src/fastify/jsConformanceApiPlugin.js index 5e33a0c..ec8b190 100644 --- a/conformance/src/fastify/jsConformanceApiPlugin.js +++ b/conformance/src/fastify/jsConformanceApiPlugin.js @@ -2,37 +2,11 @@ /* eslint-disable */ 'use strict'; - -const standardErrorCodes = { - 'NotModified': 304, - 'InvalidRequest': 400, - 'NotAuthenticated': 401, - 'NotAuthorized': 403, - 'NotFound': 404, - 'Conflict': 409, - 'RequestTooLarge': 413, - 'TooManyRequests': 429, - 'InternalError': 500, - 'ServiceUnavailable': 503, - 'NotAdmin': 403, - 'TooHappy': 500, -}; - -function parseBoolean(value) { - if (typeof value === 'string') { - const lowerValue = value.toLowerCase(); - if (lowerValue === 'true') { - return true; - } - if (lowerValue === 'false') { - return false; - } - } - return undefined; -} - +/** EXPERIMENTAL: The generated code for this plugin is subject to change/removal without a major version bump. */ export const jsConformanceApiPlugin = async (fastify, opts) => { - const { api, caseInsenstiveQueryStringKeys, includeErrorDetails } = opts; + const { serviceOrFactory, caseInsenstiveQueryStringKeys, includeErrorDetails } = opts; + + const getService = typeof serviceOrFactory === 'function' ? serviceOrFactory : () => serviceOrFactory; for (const jsonSchema of jsonSchemas) { fastify.addSchema(jsonSchema); @@ -87,7 +61,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { handler: async function (req, res) { const request = {}; - const result = await api.getApiInfo(request); + const result = await getService(req).getApiInfo(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -123,7 +97,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { const query = req.query; if (typeof query['q'] === 'string') request.query = query['q']; - const result = await api.getWidgets(request); + const result = await getService(req).getWidgets(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -153,7 +127,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { request.widget = req.body; - const result = await api.createWidget(request); + const result = await getService(req).createWidget(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -193,7 +167,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { const headers = req.headers; if (typeof headers['if-none-match'] === 'string') request.ifNotETag = headers['if-none-match']; - const result = await api.getWidget(request); + const result = await getService(req).getWidget(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -238,7 +212,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { const headers = req.headers; if (typeof headers['if-match'] === 'string') request.ifETag = headers['if-match']; - const result = await api.deleteWidget(request); + const result = await getService(req).deleteWidget(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -278,7 +252,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { request.ids = req.body; - const result = await api.getWidgetBatch(request); + const result = await getService(req).getWidgetBatch(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -318,7 +292,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { request.field = body.field; request.matrix = body.matrix; - const result = await api.mirrorFields(request); + const result = await getService(req).mirrorFields(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -357,7 +331,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { if (typeof query['enum'] === 'string') request.enum = query['enum']; if (typeof query['datetime'] === 'string') request.datetime = query['datetime']; - const result = await api.checkQuery(request); + const result = await getService(req).checkQuery(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -396,7 +370,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { if (typeof params['enum'] === 'string') request.enum = params['enum']; if (typeof params['datetime'] === 'string') request.datetime = params['datetime']; - const result = await api.checkPath(request); + const result = await getService(req).checkPath(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -435,7 +409,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { if (typeof headers['enum'] === 'string') request.enum = headers['enum']; if (typeof headers['datetime'] === 'string') request.datetime = headers['datetime']; - const result = await api.mirrorHeaders(request); + const result = await getService(req).mirrorHeaders(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -492,7 +466,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { const body = req.body; request.normal = body.normal; - const result = await api.mixed(request); + const result = await getService(req).mixed(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -551,7 +525,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { request.hasWidget = body.hasWidget; request.point = body.point; - const result = await api.required(request); + const result = await getService(req).required(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -584,7 +558,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { request.content = req.body; - const result = await api.mirrorBytes(request); + const result = await getService(req).mirrorBytes(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -621,7 +595,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { request.content = req.body; - const result = await api.mirrorText(request); + const result = await getService(req).mirrorText(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -655,7 +629,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { request.content = req.body; - const result = await api.bodyTypes(request); + const result = await getService(req).bodyTypes(request); if (result.error) { const status = result.error.code && standardErrorCodes[result.error.code]; @@ -821,3 +795,31 @@ const jsonSchemas = [ enum: [ 'yes', 'no', 'maybe' ], }, ]; + +const standardErrorCodes = { + 'NotModified': 304, + 'InvalidRequest': 400, + 'NotAuthenticated': 401, + 'NotAuthorized': 403, + 'NotFound': 404, + 'Conflict': 409, + 'RequestTooLarge': 413, + 'TooManyRequests': 429, + 'InternalError': 500, + 'ServiceUnavailable': 503, + 'NotAdmin': 403, + 'TooHappy': 500, +}; + +function parseBoolean(value) { + if (typeof value === 'string') { + const lowerValue = value.toLowerCase(); + if (lowerValue === 'true') { + return true; + } + if (lowerValue === 'false') { + return false; + } + } + return undefined; +} diff --git a/src/Facility.CodeGen.JavaScript/JavaScriptGenerator.cs b/src/Facility.CodeGen.JavaScript/JavaScriptGenerator.cs index 6dc7766..1432cc7 100644 --- a/src/Facility.CodeGen.JavaScript/JavaScriptGenerator.cs +++ b/src/Facility.CodeGen.JavaScript/JavaScriptGenerator.cs @@ -567,49 +567,40 @@ private CodeGenOutput GenerateFastifyPluginOutput(ServiceInfo service) { WriteFileHeader(code); - if (!TypeScript) - code.WriteLine("'use strict';"); - - code.WriteLine(); - - var fastifyImports = new List(); - if (TypeScript) - { - fastifyImports.Add("FastifyPluginAsync"); - fastifyImports.Add("RegisterOptions"); - } - - WriteImports(code, fastifyImports, "fastify"); - - var facilityImports = new List(); if (TypeScript) { - facilityImports.Add("IServiceResult"); - facilityImports.Add("IServiceError"); - } - WriteImports(code, facilityImports, "facility-core"); - - code.WriteLine(); - WriteStandardErrorCodesVariable("standardErrorCodes", code, httpServiceInfo.ErrorSets); - - code.WriteLine(); - WriteParseBooleanFunction("parseBoolean", code); + code.WriteLine(); + code.WriteLine("import type * as fastifyTypes from 'fastify';"); + code.WriteLine("import type { IServiceResult, IServiceError } from 'facility-core';"); - if (TypeScript) - { code.WriteLine(); - using (code.Block($"export type {capModuleName}PluginOptions = RegisterOptions & {{", "}")) + using (code.Block($"export type {capModuleName}PluginOptions = fastifyTypes.RegisterOptions & {{", "}")) { - code.WriteLine($"api: I{capModuleName};"); + WriteJsDoc(code, $"The `I{capModuleName}` service implementation. Can be a service instance or a factory function which is called on each request."); + code.WriteLine($"serviceOrFactory: I{capModuleName} | ((req: fastifyTypes.FastifyRequest) => I{capModuleName});"); + + code.WriteLine(); + WriteJsDoc(code, "Whether to make query string keys case insensitive. Defalts to false."); code.WriteLine("caseInsenstiveQueryStringKeys?: boolean;"); + + code.WriteLine(); + WriteJsDoc(code, "Whether to include error details in the response. Defaults to false."); code.WriteLine("includeErrorDetails?: boolean;"); } } + else + { + code.WriteLine("'use strict';"); + } code.WriteLine(); - using (code.Block($"export const {camelCaseModuleName}Plugin" + IfTypeScript($": FastifyPluginAsync<{capModuleName}PluginOptions>") + " = async (fastify, opts) => {", "}")) + WriteJsDoc(code, "EXPERIMENTAL: The generated code for this plugin is subject to change/removal without a major version bump."); + using (code.Block($"export const {camelCaseModuleName}Plugin" + IfTypeScript($": fastifyTypes.FastifyPluginAsync<{capModuleName}PluginOptions>") + " = async (fastify, opts) => {", "}")) { - code.WriteLine("const { api, caseInsenstiveQueryStringKeys, includeErrorDetails } = opts;"); + code.WriteLine("const { serviceOrFactory, caseInsenstiveQueryStringKeys, includeErrorDetails } = opts;"); + + code.WriteLine(); + code.WriteLine("const getService = typeof serviceOrFactory === 'function' ? serviceOrFactory : () => serviceOrFactory;"); code.WriteLine(); using (code.Block("for (const jsonSchema of jsonSchemas) {", "}")) @@ -656,7 +647,7 @@ private CodeGenOutput GenerateFastifyPluginOutput(ServiceInfo service) code.WriteLine("const lowerKey = key.toLowerCase();"); using (code.Block("if (lowerKey !== key) {", "}")) { - code.WriteLine("query[lowerKey] = query[key];"); + code.WriteLine($"query[lowerKey] = query[key]{IfTypeScript(" as string")};"); code.WriteLine("delete query[key];"); } } @@ -710,7 +701,7 @@ private CodeGenOutput GenerateFastifyPluginOutput(ServiceInfo service) } using (code.Block("handler: async function (req, res) {", "}")) { - code.WriteLine("const request" + IfTypeScript($": I{capMethodName}Request") + " = {};"); + code.WriteLine("const request" + IfTypeScript($": Partial") + " = {};"); if (httpMethodInfo.PathFields.Count != 0) { code.WriteLine(); @@ -756,7 +747,7 @@ private CodeGenOutput GenerateFastifyPluginOutput(ServiceInfo service) } code.WriteLine(); - code.WriteLine($"const result = await api.{methodName}(request);"); + code.WriteLine($"const result = await getService(req).{methodName}(request{IfTypeScript($" as I{capMethodName}Request")});"); code.WriteLine(); using (code.Block("if (result.error) {", "}")) @@ -832,6 +823,12 @@ private CodeGenOutput GenerateFastifyPluginOutput(ServiceInfo service) WriteJsonSchemaDtos(code, service); + code.WriteLine(); + WriteStandardErrorCodesVariable("standardErrorCodes", code, httpServiceInfo.ErrorSets); + + code.WriteLine(); + WriteParseBooleanFunction("parseBoolean", code); + if (TypeScript) WriteTypes(code, httpServiceInfo); }); diff --git a/src/fsdgenjs/FsdGenJavaScriptApp.cs b/src/fsdgenjs/FsdGenJavaScriptApp.cs index 8d9c62f..7f12b28 100644 --- a/src/fsdgenjs/FsdGenJavaScriptApp.cs +++ b/src/fsdgenjs/FsdGenJavaScriptApp.cs @@ -24,7 +24,7 @@ public sealed class FsdGenJavaScriptApp : CodeGeneratorApp " --express", " Generates Express service.", " --fastify", - " Generates a Fastify plugin. When specified, only the server plugin is generated, not the client.", + " Generates a Fastify plugin. When specified, only the server plugin is generated, not the client. EXPERIMENTAL: This option is subject to change/removal without a major version bump.", " --disable-eslint", " Disables ESLint via code comment.", " --file-name-suffix",