Refactor flattenSchema to simplify JSON schema for Google Generative … (#4711) * Refactor flattenSchema to simplify JSON schema for Google Generative AI API compatibility * Added unit test and github action * Add unit tests workflow and update test script in package.json * Downgrade eslint-plugin-jest to make min node version 18
Signed| @@ -56,6 +56,38 @@ jobs: | |||
| 56 | dist/ | 56 | dist/ |
| 57 | lib/ | 57 | lib/ |
| 58 | 58 | ||
| 59 | run-tests: | ||
| 60 | name: ✅ Run Unit Tests on PR | ||
| 61 | runs-on: ubuntu-latest | ||
| 62 | # Only needs to run when code is changed | ||
| 63 | if: always() && (github.event.action == 'opened' || github.event.action == 'synchronize') | ||
| 64 | |||
| 65 | steps: | ||
| 66 | - name: Checkout Repository | ||
| 67 | # Checkout | ||
| 68 | # https://github.com/marketplace/actions/checkout | ||
| 69 | uses: actions/checkout@v4.2.2 | ||
| 70 | with: | ||
| 71 | ref: ${{ github.event.pull_request.head.sha }} | ||
| 72 | repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
| 73 | |||
| 74 | - name: Setup Node.js | ||
| 75 | # Setup Node.js environment | ||
| 76 | # https://github.com/marketplace/actions/setup-node-js-environment | ||
| 77 | uses: actions/setup-node@v4.3.0 | ||
| 78 | with: | ||
| 79 | node-version: 20 | ||
| 80 | cache: 'npm' | ||
| 81 | |||
| 82 | - name: Install root dependencies | ||
| 83 | run: npm ci | ||
| 84 | |||
| 85 | - name: Install test dependencies | ||
| 86 | run: npm ci --prefix tests | ||
| 87 | |||
| 88 | - name: Run unit tests | ||
| 89 | run: npm run test:unit --prefix tests | ||
| 90 | |||
| 59 | label-by-size: | 91 | label-by-size: |
| 60 | name: 🏷️ Label PR by Size | 92 | name: 🏷️ Label PR by Size |
| 61 | # This job should run after all others, to prevent possible concurrency issues | 93 | # This job should run after all others, to prevent possible concurrency issues |
| @@ -133,6 +133,7 @@ | |||
| 133 | "@types/yargs": "^17.0.33", | 133 | "@types/yargs": "^17.0.33", |
| 134 | "@types/yauzl": "^2.10.3", | 134 | "@types/yauzl": "^2.10.3", |
| 135 | "eslint": "^8.57.1", | 135 | "eslint": "^8.57.1", |
| 136 | "eslint-plugin-jest": "^27.9.0", | ||
| 136 | "eslint-plugin-jsdoc": "^48.10.0" | 137 | "eslint-plugin-jsdoc": "^48.10.0" |
| 137 | }, | 138 | }, |
| 138 | "engines": { | 139 | "engines": { |
| @@ -186,17 +187,20 @@ | |||
| 186 | } | 187 | } |
| 187 | }, | 188 | }, |
| 188 | "node_modules/@eslint-community/eslint-utils": { | 189 | "node_modules/@eslint-community/eslint-utils": { |
| 189 | "version": "4.4.0", | 190 | "version": "4.9.0", |
| 190 | "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", | 191 | "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz", |
| 191 | "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", | 192 | "integrity": "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==", |
| 192 | "dev": true, | 193 | "dev": true, |
| 193 | "license": "MIT", | 194 | "license": "MIT", |
| 194 | "dependencies": { | 195 | "dependencies": { |
| 195 | "eslint-visitor-keys": "^3.3.0" | 196 | "eslint-visitor-keys": "^3.4.3" |
| 196 | }, | 197 | }, |
| 197 | "engines": { | 198 | "engines": { |
| 198 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" | 199 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" |
| 199 | }, | 200 | }, |
| 201 | "funding": { | ||
| 202 | "url": "https://opencollective.com/eslint" | ||
| 203 | }, | ||
| 200 | "peerDependencies": { | 204 | "peerDependencies": { |
| 201 | "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" | 205 | "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" |
| 202 | } | 206 | } |
| @@ -2105,6 +2109,13 @@ | |||
| 2105 | "@types/jquery": "*" | 2109 | "@types/jquery": "*" |
| 2106 | } | 2110 | } |
| 2107 | }, | 2111 | }, |
| 2112 | "node_modules/@types/semver": { | ||
| 2113 | "version": "7.7.1", | ||
| 2114 | "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.1.tgz", | ||
| 2115 | "integrity": "sha512-FmgJfu+MOcQ370SD0ev7EI8TlCAfKYU+B4m5T3yXc1CiRN94g/SZPtsCkk506aUDtlMnFZvasDwHHUcZUEaYuA==", | ||
| 2116 | "dev": true, | ||
| 2117 | "license": "MIT" | ||
| 2118 | }, | ||
| 2108 | "node_modules/@types/send": { | 2119 | "node_modules/@types/send": { |
| 2109 | "version": "0.17.4", | 2120 | "version": "0.17.4", |
| 2110 | "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz", | 2121 | "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz", |
| @@ -2188,6 +2199,160 @@ | |||
| 2188 | "@types/node": "*" | 2199 | "@types/node": "*" |
| 2189 | } | 2200 | } |
| 2190 | }, | 2201 | }, |
| 2202 | "node_modules/@typescript-eslint/scope-manager": { | ||
| 2203 | "version": "5.62.0", | ||
| 2204 | "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz", | ||
| 2205 | "integrity": "sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==", | ||
| 2206 | "dev": true, | ||
| 2207 | "license": "MIT", | ||
| 2208 | "dependencies": { | ||
| 2209 | "@typescript-eslint/types": "5.62.0", | ||
| 2210 | "@typescript-eslint/visitor-keys": "5.62.0" | ||
| 2211 | }, | ||
| 2212 | "engines": { | ||
| 2213 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" | ||
| 2214 | }, | ||
| 2215 | "funding": { | ||
| 2216 | "type": "opencollective", | ||
| 2217 | "url": "https://opencollective.com/typescript-eslint" | ||
| 2218 | } | ||
| 2219 | }, | ||
| 2220 | "node_modules/@typescript-eslint/types": { | ||
| 2221 | "version": "5.62.0", | ||
| 2222 | "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz", | ||
| 2223 | "integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==", | ||
| 2224 | "dev": true, | ||
| 2225 | "license": "MIT", | ||
| 2226 | "engines": { | ||
| 2227 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" | ||
| 2228 | }, | ||
| 2229 | "funding": { | ||
| 2230 | "type": "opencollective", | ||
| 2231 | "url": "https://opencollective.com/typescript-eslint" | ||
| 2232 | } | ||
| 2233 | }, | ||
| 2234 | "node_modules/@typescript-eslint/typescript-estree": { | ||
| 2235 | "version": "5.62.0", | ||
| 2236 | "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz", | ||
| 2237 | "integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==", | ||
| 2238 | "dev": true, | ||
| 2239 | "license": "BSD-2-Clause", | ||
| 2240 | "dependencies": { | ||
| 2241 | "@typescript-eslint/types": "5.62.0", | ||
| 2242 | "@typescript-eslint/visitor-keys": "5.62.0", | ||
| 2243 | "debug": "^4.3.4", | ||
| 2244 | "globby": "^11.1.0", | ||
| 2245 | "is-glob": "^4.0.3", | ||
| 2246 | "semver": "^7.3.7", | ||
| 2247 | "tsutils": "^3.21.0" | ||
| 2248 | }, | ||
| 2249 | "engines": { | ||
| 2250 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" | ||
| 2251 | }, | ||
| 2252 | "funding": { | ||
| 2253 | "type": "opencollective", | ||
| 2254 | "url": "https://opencollective.com/typescript-eslint" | ||
| 2255 | }, | ||
| 2256 | "peerDependenciesMeta": { | ||
| 2257 | "typescript": { | ||
| 2258 | "optional": true | ||
| 2259 | } | ||
| 2260 | } | ||
| 2261 | }, | ||
| 2262 | "node_modules/@typescript-eslint/typescript-estree/node_modules/debug": { | ||
| 2263 | "version": "4.4.3", | ||
| 2264 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", | ||
| 2265 | "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", | ||
| 2266 | "dev": true, | ||
| 2267 | "license": "MIT", | ||
| 2268 | "dependencies": { | ||
| 2269 | "ms": "^2.1.3" | ||
| 2270 | }, | ||
| 2271 | "engines": { | ||
| 2272 | "node": ">=6.0" | ||
| 2273 | }, | ||
| 2274 | "peerDependenciesMeta": { | ||
| 2275 | "supports-color": { | ||
| 2276 | "optional": true | ||
| 2277 | } | ||
| 2278 | } | ||
| 2279 | }, | ||
| 2280 | "node_modules/@typescript-eslint/typescript-estree/node_modules/ms": { | ||
| 2281 | "version": "2.1.3", | ||
| 2282 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", | ||
| 2283 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", | ||
| 2284 | "dev": true, | ||
| 2285 | "license": "MIT" | ||
| 2286 | }, | ||
| 2287 | "node_modules/@typescript-eslint/utils": { | ||
| 2288 | "version": "5.62.0", | ||
| 2289 | "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz", | ||
| 2290 | "integrity": "sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==", | ||
| 2291 | "dev": true, | ||
| 2292 | "license": "MIT", | ||
| 2293 | "dependencies": { | ||
| 2294 | "@eslint-community/eslint-utils": "^4.2.0", | ||
| 2295 | "@types/json-schema": "^7.0.9", | ||
| 2296 | "@types/semver": "^7.3.12", | ||
| 2297 | "@typescript-eslint/scope-manager": "5.62.0", | ||
| 2298 | "@typescript-eslint/types": "5.62.0", | ||
| 2299 | "@typescript-eslint/typescript-estree": "5.62.0", | ||
| 2300 | "eslint-scope": "^5.1.1", | ||
| 2301 | "semver": "^7.3.7" | ||
| 2302 | }, | ||
| 2303 | "engines": { | ||
| 2304 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" | ||
| 2305 | }, | ||
| 2306 | "funding": { | ||
| 2307 | "type": "opencollective", | ||
| 2308 | "url": "https://opencollective.com/typescript-eslint" | ||
| 2309 | }, | ||
| 2310 | "peerDependencies": { | ||
| 2311 | "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" | ||
| 2312 | } | ||
| 2313 | }, | ||
| 2314 | "node_modules/@typescript-eslint/utils/node_modules/eslint-scope": { | ||
| 2315 | "version": "5.1.1", | ||
| 2316 | "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", | ||
| 2317 | "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", | ||
| 2318 | "dev": true, | ||
| 2319 | "license": "BSD-2-Clause", | ||
| 2320 | "dependencies": { | ||
| 2321 | "esrecurse": "^4.3.0", | ||
| 2322 | "estraverse": "^4.1.1" | ||
| 2323 | }, | ||
| 2324 | "engines": { | ||
| 2325 | "node": ">=8.0.0" | ||
| 2326 | } | ||
| 2327 | }, | ||
| 2328 | "node_modules/@typescript-eslint/utils/node_modules/estraverse": { | ||
| 2329 | "version": "4.3.0", | ||
| 2330 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", | ||
| 2331 | "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", | ||
| 2332 | "dev": true, | ||
| 2333 | "license": "BSD-2-Clause", | ||
| 2334 | "engines": { | ||
| 2335 | "node": ">=4.0" | ||
| 2336 | } | ||
| 2337 | }, | ||
| 2338 | "node_modules/@typescript-eslint/visitor-keys": { | ||
| 2339 | "version": "5.62.0", | ||
| 2340 | "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz", | ||
| 2341 | "integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==", | ||
| 2342 | "dev": true, | ||
| 2343 | "license": "MIT", | ||
| 2344 | "dependencies": { | ||
| 2345 | "@typescript-eslint/types": "5.62.0", | ||
| 2346 | "eslint-visitor-keys": "^3.3.0" | ||
| 2347 | }, | ||
| 2348 | "engines": { | ||
| 2349 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" | ||
| 2350 | }, | ||
| 2351 | "funding": { | ||
| 2352 | "type": "opencollective", | ||
| 2353 | "url": "https://opencollective.com/typescript-eslint" | ||
| 2354 | } | ||
| 2355 | }, | ||
| 2191 | "node_modules/@ungap/structured-clone": { | 2356 | "node_modules/@ungap/structured-clone": { |
| 2192 | "version": "1.2.0", | 2357 | "version": "1.2.0", |
| 2193 | "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", | 2358 | "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", |
| @@ -2739,6 +2904,16 @@ | |||
| 2739 | "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", | 2904 | "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", |
| 2740 | "license": "MIT" | 2905 | "license": "MIT" |
| 2741 | }, | 2906 | }, |
| 2907 | "node_modules/array-union": { | ||
| 2908 | "version": "2.1.0", | ||
| 2909 | "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", | ||
| 2910 | "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", | ||
| 2911 | "dev": true, | ||
| 2912 | "license": "MIT", | ||
| 2913 | "engines": { | ||
| 2914 | "node": ">=8" | ||
| 2915 | } | ||
| 2916 | }, | ||
| 2742 | "node_modules/ast-types": { | 2917 | "node_modules/ast-types": { |
| 2743 | "version": "0.13.4", | 2918 | "version": "0.13.4", |
| 2744 | "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", | 2919 | "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", |
| @@ -2913,6 +3088,19 @@ | |||
| 2913 | "concat-map": "0.0.1" | 3088 | "concat-map": "0.0.1" |
| 2914 | } | 3089 | } |
| 2915 | }, | 3090 | }, |
| 3091 | "node_modules/braces": { | ||
| 3092 | "version": "3.0.3", | ||
| 3093 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", | ||
| 3094 | "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", | ||
| 3095 | "dev": true, | ||
| 3096 | "license": "MIT", | ||
| 3097 | "dependencies": { | ||
| 3098 | "fill-range": "^7.1.1" | ||
| 3099 | }, | ||
| 3100 | "engines": { | ||
| 3101 | "node": ">=8" | ||
| 3102 | } | ||
| 3103 | }, | ||
| 2916 | "node_modules/browserslist": { | 3104 | "node_modules/browserslist": { |
| 2917 | "version": "4.24.0", | 3105 | "version": "4.24.0", |
| 2918 | "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.0.tgz", | 3106 | "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.0.tgz", |
| @@ -3906,6 +4094,19 @@ | |||
| 3906 | "md5": "^2.3.0" | 4094 | "md5": "^2.3.0" |
| 3907 | } | 4095 | } |
| 3908 | }, | 4096 | }, |
| 4097 | "node_modules/dir-glob": { | ||
| 4098 | "version": "3.0.1", | ||
| 4099 | "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", | ||
| 4100 | "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", | ||
| 4101 | "dev": true, | ||
| 4102 | "license": "MIT", | ||
| 4103 | "dependencies": { | ||
| 4104 | "path-type": "^4.0.0" | ||
| 4105 | }, | ||
| 4106 | "engines": { | ||
| 4107 | "node": ">=8" | ||
| 4108 | } | ||
| 4109 | }, | ||
| 3909 | "node_modules/doctrine": { | 4110 | "node_modules/doctrine": { |
| 3910 | "version": "3.0.0", | 4111 | "version": "3.0.0", |
| 3911 | "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", | 4112 | "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", |
| @@ -4257,6 +4458,32 @@ | |||
| 4257 | "url": "https://opencollective.com/eslint" | 4458 | "url": "https://opencollective.com/eslint" |
| 4258 | } | 4459 | } |
| 4259 | }, | 4460 | }, |
| 4461 | "node_modules/eslint-plugin-jest": { | ||
| 4462 | "version": "27.9.0", | ||
| 4463 | "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.9.0.tgz", | ||
| 4464 | "integrity": "sha512-QIT7FH7fNmd9n4se7FFKHbsLKGQiw885Ds6Y/sxKgCZ6natwCsXdgPOADnYVxN2QrRweF0FZWbJ6S7Rsn7llug==", | ||
| 4465 | "dev": true, | ||
| 4466 | "license": "MIT", | ||
| 4467 | "dependencies": { | ||
| 4468 | "@typescript-eslint/utils": "^5.10.0" | ||
| 4469 | }, | ||
| 4470 | "engines": { | ||
| 4471 | "node": "^14.15.0 || ^16.10.0 || >=18.0.0" | ||
| 4472 | }, | ||
| 4473 | "peerDependencies": { | ||
| 4474 | "@typescript-eslint/eslint-plugin": "^5.0.0 || ^6.0.0 || ^7.0.0", | ||
| 4475 | "eslint": "^7.0.0 || ^8.0.0", | ||
| 4476 | "jest": "*" | ||
| 4477 | }, | ||
| 4478 | "peerDependenciesMeta": { | ||
| 4479 | "@typescript-eslint/eslint-plugin": { | ||
| 4480 | "optional": true | ||
| 4481 | }, | ||
| 4482 | "jest": { | ||
| 4483 | "optional": true | ||
| 4484 | } | ||
| 4485 | } | ||
| 4486 | }, | ||
| 4260 | "node_modules/eslint-plugin-jsdoc": { | 4487 | "node_modules/eslint-plugin-jsdoc": { |
| 4261 | "version": "48.10.0", | 4488 | "version": "48.10.0", |
| 4262 | "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-48.10.0.tgz", | 4489 | "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-48.10.0.tgz", |
| @@ -4609,6 +4836,23 @@ | |||
| 4609 | "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", | 4836 | "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", |
| 4610 | "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==" | 4837 | "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==" |
| 4611 | }, | 4838 | }, |
| 4839 | "node_modules/fast-glob": { | ||
| 4840 | "version": "3.3.3", | ||
| 4841 | "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", | ||
| 4842 | "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", | ||
| 4843 | "dev": true, | ||
| 4844 | "license": "MIT", | ||
| 4845 | "dependencies": { | ||
| 4846 | "@nodelib/fs.stat": "^2.0.2", | ||
| 4847 | "@nodelib/fs.walk": "^1.2.3", | ||
| 4848 | "glob-parent": "^5.1.2", | ||
| 4849 | "merge2": "^1.3.0", | ||
| 4850 | "micromatch": "^4.0.8" | ||
| 4851 | }, | ||
| 4852 | "engines": { | ||
| 4853 | "node": ">=8.6.0" | ||
| 4854 | } | ||
| 4855 | }, | ||
| 4612 | "node_modules/fast-json-stable-stringify": { | 4856 | "node_modules/fast-json-stable-stringify": { |
| 4613 | "version": "2.1.0", | 4857 | "version": "2.1.0", |
| 4614 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", | 4858 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", |
| @@ -4702,6 +4946,19 @@ | |||
| 4702 | "url": "https://github.com/sindresorhus/file-type?sponsor=1" | 4946 | "url": "https://github.com/sindresorhus/file-type?sponsor=1" |
| 4703 | } | 4947 | } |
| 4704 | }, | 4948 | }, |
| 4949 | "node_modules/fill-range": { | ||
| 4950 | "version": "7.1.1", | ||
| 4951 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", | ||
| 4952 | "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", | ||
| 4953 | "dev": true, | ||
| 4954 | "license": "MIT", | ||
| 4955 | "dependencies": { | ||
| 4956 | "to-regex-range": "^5.0.1" | ||
| 4957 | }, | ||
| 4958 | "engines": { | ||
| 4959 | "node": ">=8" | ||
| 4960 | } | ||
| 4961 | }, | ||
| 4705 | "node_modules/finalhandler": { | 4962 | "node_modules/finalhandler": { |
| 4706 | "version": "1.3.1", | 4963 | "version": "1.3.1", |
| 4707 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", | 4964 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", |
| @@ -5039,6 +5296,19 @@ | |||
| 5039 | "url": "https://github.com/sponsors/isaacs" | 5296 | "url": "https://github.com/sponsors/isaacs" |
| 5040 | } | 5297 | } |
| 5041 | }, | 5298 | }, |
| 5299 | "node_modules/glob-parent": { | ||
| 5300 | "version": "5.1.2", | ||
| 5301 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", | ||
| 5302 | "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", | ||
| 5303 | "dev": true, | ||
| 5304 | "license": "ISC", | ||
| 5305 | "dependencies": { | ||
| 5306 | "is-glob": "^4.0.1" | ||
| 5307 | }, | ||
| 5308 | "engines": { | ||
| 5309 | "node": ">= 6" | ||
| 5310 | } | ||
| 5311 | }, | ||
| 5042 | "node_modules/glob-to-regexp": { | 5312 | "node_modules/glob-to-regexp": { |
| 5043 | "version": "0.4.1", | 5313 | "version": "0.4.1", |
| 5044 | "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", | 5314 | "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", |
| @@ -5071,6 +5341,27 @@ | |||
| 5071 | "url": "https://github.com/sponsors/sindresorhus" | 5341 | "url": "https://github.com/sponsors/sindresorhus" |
| 5072 | } | 5342 | } |
| 5073 | }, | 5343 | }, |
| 5344 | "node_modules/globby": { | ||
| 5345 | "version": "11.1.0", | ||
| 5346 | "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", | ||
| 5347 | "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", | ||
| 5348 | "dev": true, | ||
| 5349 | "license": "MIT", | ||
| 5350 | "dependencies": { | ||
| 5351 | "array-union": "^2.1.0", | ||
| 5352 | "dir-glob": "^3.0.1", | ||
| 5353 | "fast-glob": "^3.2.9", | ||
| 5354 | "ignore": "^5.2.0", | ||
| 5355 | "merge2": "^1.4.1", | ||
| 5356 | "slash": "^3.0.0" | ||
| 5357 | }, | ||
| 5358 | "engines": { | ||
| 5359 | "node": ">=10" | ||
| 5360 | }, | ||
| 5361 | "funding": { | ||
| 5362 | "url": "https://github.com/sponsors/sindresorhus" | ||
| 5363 | } | ||
| 5364 | }, | ||
| 5074 | "node_modules/google-translate-api-browser": { | 5365 | "node_modules/google-translate-api-browser": { |
| 5075 | "version": "3.0.1", | 5366 | "version": "3.0.1", |
| 5076 | "resolved": "https://registry.npmjs.org/google-translate-api-browser/-/google-translate-api-browser-3.0.1.tgz", | 5367 | "resolved": "https://registry.npmjs.org/google-translate-api-browser/-/google-translate-api-browser-3.0.1.tgz", |
| @@ -5633,6 +5924,16 @@ | |||
| 5633 | "url": "https://github.com/sponsors/sindresorhus" | 5924 | "url": "https://github.com/sponsors/sindresorhus" |
| 5634 | } | 5925 | } |
| 5635 | }, | 5926 | }, |
| 5927 | "node_modules/is-number": { | ||
| 5928 | "version": "7.0.0", | ||
| 5929 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", | ||
| 5930 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", | ||
| 5931 | "dev": true, | ||
| 5932 | "license": "MIT", | ||
| 5933 | "engines": { | ||
| 5934 | "node": ">=0.12.0" | ||
| 5935 | } | ||
| 5936 | }, | ||
| 5636 | "node_modules/is-path-inside": { | 5937 | "node_modules/is-path-inside": { |
| 5637 | "version": "3.0.3", | 5938 | "version": "3.0.3", |
| 5638 | "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", | 5939 | "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", |
| @@ -6076,6 +6377,16 @@ | |||
| 6076 | "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", | 6377 | "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", |
| 6077 | "license": "MIT" | 6378 | "license": "MIT" |
| 6078 | }, | 6379 | }, |
| 6380 | "node_modules/merge2": { | ||
| 6381 | "version": "1.4.1", | ||
| 6382 | "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", | ||
| 6383 | "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", | ||
| 6384 | "dev": true, | ||
| 6385 | "license": "MIT", | ||
| 6386 | "engines": { | ||
| 6387 | "node": ">= 8" | ||
| 6388 | } | ||
| 6389 | }, | ||
| 6079 | "node_modules/methods": { | 6390 | "node_modules/methods": { |
| 6080 | "version": "1.1.2", | 6391 | "version": "1.1.2", |
| 6081 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", | 6392 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", |
| @@ -6085,6 +6396,20 @@ | |||
| 6085 | "node": ">= 0.6" | 6396 | "node": ">= 0.6" |
| 6086 | } | 6397 | } |
| 6087 | }, | 6398 | }, |
| 6399 | "node_modules/micromatch": { | ||
| 6400 | "version": "4.0.8", | ||
| 6401 | "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", | ||
| 6402 | "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", | ||
| 6403 | "dev": true, | ||
| 6404 | "license": "MIT", | ||
| 6405 | "dependencies": { | ||
| 6406 | "braces": "^3.0.3", | ||
| 6407 | "picomatch": "^2.3.1" | ||
| 6408 | }, | ||
| 6409 | "engines": { | ||
| 6410 | "node": ">=8.6" | ||
| 6411 | } | ||
| 6412 | }, | ||
| 6088 | "node_modules/mime": { | 6413 | "node_modules/mime": { |
| 6089 | "version": "1.6.0", | 6414 | "version": "1.6.0", |
| 6090 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", | 6415 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", |
| @@ -6765,6 +7090,16 @@ | |||
| 6765 | "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", | 7090 | "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", |
| 6766 | "license": "MIT" | 7091 | "license": "MIT" |
| 6767 | }, | 7092 | }, |
| 7093 | "node_modules/path-type": { | ||
| 7094 | "version": "4.0.0", | ||
| 7095 | "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", | ||
| 7096 | "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", | ||
| 7097 | "dev": true, | ||
| 7098 | "license": "MIT", | ||
| 7099 | "engines": { | ||
| 7100 | "node": ">=8" | ||
| 7101 | } | ||
| 7102 | }, | ||
| 6768 | "node_modules/peek-readable": { | 7103 | "node_modules/peek-readable": { |
| 6769 | "version": "4.1.0", | 7104 | "version": "4.1.0", |
| 6770 | "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-4.1.0.tgz", | 7105 | "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-4.1.0.tgz", |
| @@ -6802,6 +7137,19 @@ | |||
| 6802 | "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", | 7137 | "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", |
| 6803 | "license": "ISC" | 7138 | "license": "ISC" |
| 6804 | }, | 7139 | }, |
| 7140 | "node_modules/picomatch": { | ||
| 7141 | "version": "2.3.1", | ||
| 7142 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", | ||
| 7143 | "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", | ||
| 7144 | "dev": true, | ||
| 7145 | "license": "MIT", | ||
| 7146 | "engines": { | ||
| 7147 | "node": ">=8.6" | ||
| 7148 | }, | ||
| 7149 | "funding": { | ||
| 7150 | "url": "https://github.com/sponsors/jonschlinkert" | ||
| 7151 | } | ||
| 7152 | }, | ||
| 6805 | "node_modules/platform": { | 7153 | "node_modules/platform": { |
| 6806 | "version": "1.3.6", | 7154 | "version": "1.3.6", |
| 6807 | "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz", | 7155 | "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz", |
| @@ -7656,6 +8004,16 @@ | |||
| 7656 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", | 8004 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", |
| 7657 | "license": "MIT" | 8005 | "license": "MIT" |
| 7658 | }, | 8006 | }, |
| 8007 | "node_modules/slash": { | ||
| 8008 | "version": "3.0.0", | ||
| 8009 | "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", | ||
| 8010 | "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", | ||
| 8011 | "dev": true, | ||
| 8012 | "license": "MIT", | ||
| 8013 | "engines": { | ||
| 8014 | "node": ">=8" | ||
| 8015 | } | ||
| 8016 | }, | ||
| 7659 | "node_modules/slashes": { | 8017 | "node_modules/slashes": { |
| 7660 | "version": "3.0.12", | 8018 | "version": "3.0.12", |
| 7661 | "resolved": "https://registry.npmjs.org/slashes/-/slashes-3.0.12.tgz", | 8019 | "resolved": "https://registry.npmjs.org/slashes/-/slashes-3.0.12.tgz", |
| @@ -8028,6 +8386,19 @@ | |||
| 8028 | "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==", | 8386 | "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==", |
| 8029 | "license": "MIT" | 8387 | "license": "MIT" |
| 8030 | }, | 8388 | }, |
| 8389 | "node_modules/to-regex-range": { | ||
| 8390 | "version": "5.0.1", | ||
| 8391 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", | ||
| 8392 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", | ||
| 8393 | "dev": true, | ||
| 8394 | "license": "MIT", | ||
| 8395 | "dependencies": { | ||
| 8396 | "is-number": "^7.0.0" | ||
| 8397 | }, | ||
| 8398 | "engines": { | ||
| 8399 | "node": ">=8.0" | ||
| 8400 | } | ||
| 8401 | }, | ||
| 8031 | "node_modules/toidentifier": { | 8402 | "node_modules/toidentifier": { |
| 8032 | "version": "1.0.1", | 8403 | "version": "1.0.1", |
| 8033 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", | 8404 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", |
| @@ -8089,6 +8460,29 @@ | |||
| 8089 | "node": ">=0.6.x" | 8460 | "node": ">=0.6.x" |
| 8090 | } | 8461 | } |
| 8091 | }, | 8462 | }, |
| 8463 | "node_modules/tsutils": { | ||
| 8464 | "version": "3.21.0", | ||
| 8465 | "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", | ||
| 8466 | "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", | ||
| 8467 | "dev": true, | ||
| 8468 | "license": "MIT", | ||
| 8469 | "dependencies": { | ||
| 8470 | "tslib": "^1.8.1" | ||
| 8471 | }, | ||
| 8472 | "engines": { | ||
| 8473 | "node": ">= 6" | ||
| 8474 | }, | ||
| 8475 | "peerDependencies": { | ||
| 8476 | "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" | ||
| 8477 | } | ||
| 8478 | }, | ||
| 8479 | "node_modules/tsutils/node_modules/tslib": { | ||
| 8480 | "version": "1.14.1", | ||
| 8481 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", | ||
| 8482 | "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", | ||
| 8483 | "dev": true, | ||
| 8484 | "license": "0BSD" | ||
| 8485 | }, | ||
| 8092 | "node_modules/type-check": { | 8486 | "node_modules/type-check": { |
| 8093 | "version": "0.4.0", | 8487 | "version": "0.4.0", |
| 8094 | "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", | 8488 | "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", |
| @@ -8146,6 +8540,21 @@ | |||
| 8146 | "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", | 8540 | "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", |
| 8147 | "license": "MIT" | 8541 | "license": "MIT" |
| 8148 | }, | 8542 | }, |
| 8543 | "node_modules/typescript": { | ||
| 8544 | "version": "5.9.3", | ||
| 8545 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", | ||
| 8546 | "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", | ||
| 8547 | "dev": true, | ||
| 8548 | "license": "Apache-2.0", | ||
| 8549 | "peer": true, | ||
| 8550 | "bin": { | ||
| 8551 | "tsc": "bin/tsc", | ||
| 8552 | "tsserver": "bin/tsserver" | ||
| 8553 | }, | ||
| 8554 | "engines": { | ||
| 8555 | "node": ">=14.17" | ||
| 8556 | } | ||
| 8557 | }, | ||
| 8149 | "node_modules/uglify-js": { | 8558 | "node_modules/uglify-js": { |
| 8150 | "version": "3.19.3", | 8559 | "version": "3.19.3", |
| 8151 | "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", | 8560 | "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", |
| @@ -164,6 +164,7 @@ | |||
| 164 | "@types/yargs": "^17.0.33", | 164 | "@types/yargs": "^17.0.33", |
| 165 | "@types/yauzl": "^2.10.3", | 165 | "@types/yauzl": "^2.10.3", |
| 166 | "eslint": "^8.57.1", | 166 | "eslint": "^8.57.1", |
| 167 | "eslint-plugin-jsdoc": "^48.10.0" | 167 | "eslint-plugin-jsdoc": "^48.10.0", |
| 168 | "eslint-plugin-jest": "^27.9.0" | ||
| 168 | } | 169 | } |
| 169 | } | 170 | } |
| @@ -1240,63 +1240,58 @@ export function getRequestURL(request) { | |||
| 1240 | } | 1240 | } |
| 1241 | 1241 | ||
| 1242 | /** | 1242 | /** |
| 1243 | * Flattens a JSON schema by inlining all definitions and setting additionalProperties to false. | 1243 | * Flattens and simplifies a JSON schema to be compatible with the strict requirements |
| 1244 | * @param {object} schema The JSON schema to flatten. | 1244 | * of Google's Generative AI API. |
| 1245 | * @param {string} api The API source, used to determine how to handle certain properties. | 1245 | * @param {object} schema The JSON schema to process. |
| 1246 | * @returns {object} The flattened schema. | 1246 | * @param {string} api The API source. |
| 1247 | * @returns {object} The flattened and simplified schema. | ||
| 1247 | */ | 1248 | */ |
| 1248 | export function flattenSchema(schema, api) { | 1249 | export function flattenSchema(schema, api) { |
| 1249 | if (!schema || typeof schema !== 'object') { | 1250 | if (!schema || typeof schema !== 'object') { |
| 1250 | return schema; | 1251 | return schema; |
| 1251 | } | 1252 | } |
| 1252 | 1253 | ||
| 1253 | // Deep clone to avoid modifying the original object. | ||
| 1254 | const schemaCopy = structuredClone(schema); | 1254 | const schemaCopy = structuredClone(schema); |
| 1255 | const isGoogleApi = [CHAT_COMPLETION_SOURCES.VERTEXAI, CHAT_COMPLETION_SOURCES.MAKERSUITE].includes(api); | ||
| 1255 | 1256 | ||
| 1256 | const definitions = schemaCopy.$defs || {}; | 1257 | const definitions = schemaCopy.$defs || {}; |
| 1257 | delete schemaCopy.$defs; | 1258 | delete schemaCopy.$defs; |
| 1258 | 1259 | ||
| 1259 | function replaceRefs(obj) { | 1260 | function resolve(obj, parents = []) { |
| 1260 | if (obj === null || typeof obj !== 'object') { | 1261 | if (!obj || typeof obj !== 'object') { |
| 1261 | return obj; | 1262 | return obj; |
| 1262 | } | 1263 | } |
| 1263 | |||
| 1264 | if (Array.isArray(obj)) { | 1264 | if (Array.isArray(obj)) { |
| 1265 | for (let i = 0; i < obj.length; i++) { | 1265 | return obj.map(item => resolve(item, parents)); |
| 1266 | obj[i] = replaceRefs(obj[i]); | ||
| 1267 | } | ||
| 1268 | return obj; | ||
| 1269 | } | 1266 | } |
| 1270 | 1267 | ||
| 1271 | if (obj.$ref && typeof obj.$ref === 'string' && obj.$ref.startsWith('#/$defs/')) { | 1268 | // 1. Resolve $refs first |
| 1269 | if (obj.$ref?.startsWith('#/$defs/')) { | ||
| 1272 | const defName = obj.$ref.split('/').pop(); | 1270 | const defName = obj.$ref.split('/').pop(); |
| 1271 | if (parents.includes(defName)) return {}; // Prevent infinite recursion | ||
| 1273 | if (definitions[defName]) { | 1272 | if (definitions[defName]) { |
| 1274 | return replaceRefs(structuredClone(definitions[defName])); | 1273 | return resolve(structuredClone(definitions[defName]), [...parents, defName]); |
| 1275 | } | ||
| 1276 | } | ||
| 1277 | |||
| 1278 | if (api === CHAT_COMPLETION_SOURCES.MAKERSUITE || api === CHAT_COMPLETION_SOURCES.VERTEXAI) { | ||
| 1279 | delete obj.default; | ||
| 1280 | delete obj.additionalProperties; | ||
| 1281 | } else if ('properties' in obj) { | ||
| 1282 | if (obj.additionalProperties === undefined || obj.additionalProperties === true) { | ||
| 1283 | obj.additionalProperties = false; | ||
| 1284 | } | 1274 | } |
| 1275 | return {}; // Broken reference | ||
| 1285 | } | 1276 | } |
| 1286 | 1277 | ||
| 1278 | // 2. Process the object's properties | ||
| 1279 | const result = {}; | ||
| 1287 | for (const key in obj) { | 1280 | for (const key in obj) { |
| 1288 | if (Object.prototype.hasOwnProperty.call(obj, key)) { | 1281 | if (!Object.prototype.hasOwnProperty.call(obj, key)) continue; |
| 1289 | obj[key] = replaceRefs(obj[key]); | 1282 | |
| 1290 | } | 1283 | // For Google, filter unsupported top-level keywords |
| 1291 | } | 1284 | if (isGoogleApi && ['default', 'additionalProperties', 'exclusiveMinimum', 'propertyNames'].includes(key)) { |
| 1292 | return obj; | 1285 | continue; |
| 1293 | } | 1286 | } |
| 1294 | 1287 | ||
| 1295 | const flattenedSchema = replaceRefs(schemaCopy); | 1288 | result[key] = resolve(obj[key], parents); |
| 1289 | } | ||
| 1296 | 1290 | ||
| 1297 | if (flattenedSchema.$schema) { | 1291 | return result; |
| 1298 | delete flattenedSchema.$schema; | ||
| 1299 | } | 1292 | } |
| 1300 | 1293 | ||
| 1294 | const flattenedSchema = resolve(schemaCopy); | ||
| 1295 | delete flattenedSchema.$schema; | ||
| 1301 | return flattenedSchema; | 1296 | return flattenedSchema; |
| 1302 | } | 1297 | } |
| @@ -5,19 +5,24 @@ module.exports = { | |||
| 5 | ], | 5 | ], |
| 6 | extends: [ | 6 | extends: [ |
| 7 | 'eslint:recommended', | 7 | 'eslint:recommended', |
| 8 | 'plugin:jest/recommended', | ||
| 8 | ], | 9 | ], |
| 9 | env: { | 10 | env: { |
| 10 | es6: true, | 11 | es6: true, |
| 11 | node: true, | 12 | node: true, |
| 12 | "jest/globals": true, | 13 | 'jest/globals': true, |
| 13 | }, | 14 | }, |
| 14 | parserOptions: { | 15 | parserOptions: { |
| 15 | ecmaVersion: 'latest', | 16 | ecmaVersion: 'latest', |
| 17 | sourceType: 'module', | ||
| 16 | }, | 18 | }, |
| 17 | overrides: [ | 19 | overrides: [ |
| 18 | ], | 20 | ], |
| 19 | ignorePatterns: [ | 21 | ignorePatterns: [ |
| 20 | ], | 22 | ], |
| 23 | globals: { | ||
| 24 | page: 'readonly', | ||
| 25 | }, | ||
| 21 | rules: { | 26 | rules: { |
| 22 | 'no-unused-vars': ['error', { args: 'none' }], | 27 | 'no-unused-vars': ['error', { args: 'none' }], |
| 23 | 'no-control-regex': 'off', | 28 | 'no-control-regex': 'off', |
| @@ -34,4 +39,9 @@ module.exports = { | |||
| 34 | 'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }], | 39 | 'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }], |
| 35 | 'no-cond-assign': 'error', | 40 | 'no-cond-assign': 'error', |
| 36 | }, | 41 | }, |
| 42 | settings: { | ||
| 43 | jest: { | ||
| 44 | version: '29.7.0', | ||
| 45 | }, | ||
| 46 | }, | ||
| 37 | }; | 47 | }; |
| @@ -0,0 +1,11 @@ | |||
| 1 | { | ||
| 2 | "verbose": true, | ||
| 3 | "transform": {}, | ||
| 4 | "preset": "jest-puppeteer", | ||
| 5 | "setupFilesAfterEnv": [ | ||
| 6 | "<rootDir>/jest.setup.js" | ||
| 7 | ], | ||
| 8 | "testMatch": [ | ||
| 9 | "**/?(*.)+(e2e).js" | ||
| 10 | ] | ||
| 11 | } | ||
| @@ -1,9 +1,5 @@ | |||
| 1 | { | 1 | { |
| 2 | "verbose": true, | 2 | "verbose": true, |
| 3 | "transform": {}, | 3 | "transform": {}, |
| 4 | "extensionsToTreatAsEsm": [], | 4 | "testEnvironment": "node" |
| 5 | "preset": "jest-puppeteer", | ||
| 6 | "setupFilesAfterEnv": [ | ||
| 7 | "<rootDir>/jest.setup.js" | ||
| 8 | ] | ||
| 9 | } | 5 | } |
| @@ -9,7 +9,6 @@ | |||
| 9 | "dependencies": { | 9 | "dependencies": { |
| 10 | "@types/jest": "^29.5.12", | 10 | "@types/jest": "^29.5.12", |
| 11 | "eslint": "^8.57.0", | 11 | "eslint": "^8.57.0", |
| 12 | "eslint-plugin-jest": "^28.6.0", | ||
| 13 | "jest": "^29.7.0", | 12 | "jest": "^29.7.0", |
| 14 | "jest-puppeteer": "^10.0.1" | 13 | "jest-puppeteer": "^10.0.1" |
| 15 | } | 14 | } |
| @@ -1249,139 +1248,6 @@ | |||
| 1249 | "@types/node": "*" | 1248 | "@types/node": "*" |
| 1250 | } | 1249 | } |
| 1251 | }, | 1250 | }, |
| 1252 | "node_modules/@typescript-eslint/scope-manager": { | ||
| 1253 | "version": "7.16.0", | ||
| 1254 | "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.16.0.tgz", | ||
| 1255 | "integrity": "sha512-8gVv3kW6n01Q6TrI1cmTZ9YMFi3ucDT7i7aI5lEikk2ebk1AEjrwX8MDTdaX5D7fPXMBLvnsaa0IFTAu+jcfOw==", | ||
| 1256 | "license": "MIT", | ||
| 1257 | "dependencies": { | ||
| 1258 | "@typescript-eslint/types": "7.16.0", | ||
| 1259 | "@typescript-eslint/visitor-keys": "7.16.0" | ||
| 1260 | }, | ||
| 1261 | "engines": { | ||
| 1262 | "node": "^18.18.0 || >=20.0.0" | ||
| 1263 | }, | ||
| 1264 | "funding": { | ||
| 1265 | "type": "opencollective", | ||
| 1266 | "url": "https://opencollective.com/typescript-eslint" | ||
| 1267 | } | ||
| 1268 | }, | ||
| 1269 | "node_modules/@typescript-eslint/types": { | ||
| 1270 | "version": "7.16.0", | ||
| 1271 | "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.16.0.tgz", | ||
| 1272 | "integrity": "sha512-fecuH15Y+TzlUutvUl9Cc2XJxqdLr7+93SQIbcZfd4XRGGKoxyljK27b+kxKamjRkU7FYC6RrbSCg0ALcZn/xw==", | ||
| 1273 | "license": "MIT", | ||
| 1274 | "engines": { | ||
| 1275 | "node": "^18.18.0 || >=20.0.0" | ||
| 1276 | }, | ||
| 1277 | "funding": { | ||
| 1278 | "type": "opencollective", | ||
| 1279 | "url": "https://opencollective.com/typescript-eslint" | ||
| 1280 | } | ||
| 1281 | }, | ||
| 1282 | "node_modules/@typescript-eslint/typescript-estree": { | ||
| 1283 | "version": "7.16.0", | ||
| 1284 | "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.16.0.tgz", | ||
| 1285 | "integrity": "sha512-a5NTvk51ZndFuOLCh5OaJBELYc2O3Zqxfl3Js78VFE1zE46J2AaVuW+rEbVkQznjkmlzWsUI15BG5tQMixzZLw==", | ||
| 1286 | "license": "BSD-2-Clause", | ||
| 1287 | "dependencies": { | ||
| 1288 | "@typescript-eslint/types": "7.16.0", | ||
| 1289 | "@typescript-eslint/visitor-keys": "7.16.0", | ||
| 1290 | "debug": "^4.3.4", | ||
| 1291 | "globby": "^11.1.0", | ||
| 1292 | "is-glob": "^4.0.3", | ||
| 1293 | "minimatch": "^9.0.4", | ||
| 1294 | "semver": "^7.6.0", | ||
| 1295 | "ts-api-utils": "^1.3.0" | ||
| 1296 | }, | ||
| 1297 | "engines": { | ||
| 1298 | "node": "^18.18.0 || >=20.0.0" | ||
| 1299 | }, | ||
| 1300 | "funding": { | ||
| 1301 | "type": "opencollective", | ||
| 1302 | "url": "https://opencollective.com/typescript-eslint" | ||
| 1303 | }, | ||
| 1304 | "peerDependenciesMeta": { | ||
| 1305 | "typescript": { | ||
| 1306 | "optional": true | ||
| 1307 | } | ||
| 1308 | } | ||
| 1309 | }, | ||
| 1310 | "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { | ||
| 1311 | "version": "2.0.2", | ||
| 1312 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", | ||
| 1313 | "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", | ||
| 1314 | "license": "MIT", | ||
| 1315 | "dependencies": { | ||
| 1316 | "balanced-match": "^1.0.0" | ||
| 1317 | } | ||
| 1318 | }, | ||
| 1319 | "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { | ||
| 1320 | "version": "9.0.5", | ||
| 1321 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", | ||
| 1322 | "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", | ||
| 1323 | "license": "ISC", | ||
| 1324 | "dependencies": { | ||
| 1325 | "brace-expansion": "^2.0.1" | ||
| 1326 | }, | ||
| 1327 | "engines": { | ||
| 1328 | "node": ">=16 || 14 >=14.17" | ||
| 1329 | }, | ||
| 1330 | "funding": { | ||
| 1331 | "url": "https://github.com/sponsors/isaacs" | ||
| 1332 | } | ||
| 1333 | }, | ||
| 1334 | "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { | ||
| 1335 | "version": "7.6.2", | ||
| 1336 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", | ||
| 1337 | "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", | ||
| 1338 | "license": "ISC", | ||
| 1339 | "bin": { | ||
| 1340 | "semver": "bin/semver.js" | ||
| 1341 | }, | ||
| 1342 | "engines": { | ||
| 1343 | "node": ">=10" | ||
| 1344 | } | ||
| 1345 | }, | ||
| 1346 | "node_modules/@typescript-eslint/utils": { | ||
| 1347 | "version": "7.16.0", | ||
| 1348 | "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.16.0.tgz", | ||
| 1349 | "integrity": "sha512-PqP4kP3hb4r7Jav+NiRCntlVzhxBNWq6ZQ+zQwII1y/G/1gdIPeYDCKr2+dH6049yJQsWZiHU6RlwvIFBXXGNA==", | ||
| 1350 | "license": "MIT", | ||
| 1351 | "dependencies": { | ||
| 1352 | "@eslint-community/eslint-utils": "^4.4.0", | ||
| 1353 | "@typescript-eslint/scope-manager": "7.16.0", | ||
| 1354 | "@typescript-eslint/types": "7.16.0", | ||
| 1355 | "@typescript-eslint/typescript-estree": "7.16.0" | ||
| 1356 | }, | ||
| 1357 | "engines": { | ||
| 1358 | "node": "^18.18.0 || >=20.0.0" | ||
| 1359 | }, | ||
| 1360 | "funding": { | ||
| 1361 | "type": "opencollective", | ||
| 1362 | "url": "https://opencollective.com/typescript-eslint" | ||
| 1363 | }, | ||
| 1364 | "peerDependencies": { | ||
| 1365 | "eslint": "^8.56.0" | ||
| 1366 | } | ||
| 1367 | }, | ||
| 1368 | "node_modules/@typescript-eslint/visitor-keys": { | ||
| 1369 | "version": "7.16.0", | ||
| 1370 | "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.16.0.tgz", | ||
| 1371 | "integrity": "sha512-rMo01uPy9C7XxG7AFsxa8zLnWXTF8N3PYclekWSrurvhwiw1eW88mrKiAYe6s53AUY57nTRz8dJsuuXdkAhzCg==", | ||
| 1372 | "license": "MIT", | ||
| 1373 | "dependencies": { | ||
| 1374 | "@typescript-eslint/types": "7.16.0", | ||
| 1375 | "eslint-visitor-keys": "^3.4.3" | ||
| 1376 | }, | ||
| 1377 | "engines": { | ||
| 1378 | "node": "^18.18.0 || >=20.0.0" | ||
| 1379 | }, | ||
| 1380 | "funding": { | ||
| 1381 | "type": "opencollective", | ||
| 1382 | "url": "https://opencollective.com/typescript-eslint" | ||
| 1383 | } | ||
| 1384 | }, | ||
| 1385 | "node_modules/@ungap/structured-clone": { | 1251 | "node_modules/@ungap/structured-clone": { |
| 1386 | "version": "1.2.0", | 1252 | "version": "1.2.0", |
| 1387 | "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", | 1253 | "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", |
| @@ -1496,15 +1362,6 @@ | |||
| 1496 | "sprintf-js": "~1.0.2" | 1362 | "sprintf-js": "~1.0.2" |
| 1497 | } | 1363 | } |
| 1498 | }, | 1364 | }, |
| 1499 | "node_modules/array-union": { | ||
| 1500 | "version": "2.1.0", | ||
| 1501 | "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", | ||
| 1502 | "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", | ||
| 1503 | "license": "MIT", | ||
| 1504 | "engines": { | ||
| 1505 | "node": ">=8" | ||
| 1506 | } | ||
| 1507 | }, | ||
| 1508 | "node_modules/ast-types": { | 1365 | "node_modules/ast-types": { |
| 1509 | "version": "0.13.4", | 1366 | "version": "0.13.4", |
| 1510 | "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", | 1367 | "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", |
| @@ -2210,18 +2067,6 @@ | |||
| 2210 | "node": "^14.15.0 || ^16.10.0 || >=18.0.0" | 2067 | "node": "^14.15.0 || ^16.10.0 || >=18.0.0" |
| 2211 | } | 2068 | } |
| 2212 | }, | 2069 | }, |
| 2213 | "node_modules/dir-glob": { | ||
| 2214 | "version": "3.0.1", | ||
| 2215 | "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", | ||
| 2216 | "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", | ||
| 2217 | "license": "MIT", | ||
| 2218 | "dependencies": { | ||
| 2219 | "path-type": "^4.0.0" | ||
| 2220 | }, | ||
| 2221 | "engines": { | ||
| 2222 | "node": ">=8" | ||
| 2223 | } | ||
| 2224 | }, | ||
| 2225 | "node_modules/doctrine": { | 2070 | "node_modules/doctrine": { |
| 2226 | "version": "3.0.0", | 2071 | "version": "3.0.0", |
| 2227 | "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", | 2072 | "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", |
| @@ -2441,31 +2286,6 @@ | |||
| 2441 | "url": "https://opencollective.com/eslint" | 2286 | "url": "https://opencollective.com/eslint" |
| 2442 | } | 2287 | } |
| 2443 | }, | 2288 | }, |
| 2444 | "node_modules/eslint-plugin-jest": { | ||
| 2445 | "version": "28.6.0", | ||
| 2446 | "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.6.0.tgz", | ||
| 2447 | "integrity": "sha512-YG28E1/MIKwnz+e2H7VwYPzHUYU4aMa19w0yGcwXnnmJH6EfgHahTJ2un3IyraUxNfnz/KUhJAFXNNwWPo12tg==", | ||
| 2448 | "license": "MIT", | ||
| 2449 | "dependencies": { | ||
| 2450 | "@typescript-eslint/utils": "^6.0.0 || ^7.0.0" | ||
| 2451 | }, | ||
| 2452 | "engines": { | ||
| 2453 | "node": "^16.10.0 || ^18.12.0 || >=20.0.0" | ||
| 2454 | }, | ||
| 2455 | "peerDependencies": { | ||
| 2456 | "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0", | ||
| 2457 | "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0", | ||
| 2458 | "jest": "*" | ||
| 2459 | }, | ||
| 2460 | "peerDependenciesMeta": { | ||
| 2461 | "@typescript-eslint/eslint-plugin": { | ||
| 2462 | "optional": true | ||
| 2463 | }, | ||
| 2464 | "jest": { | ||
| 2465 | "optional": true | ||
| 2466 | } | ||
| 2467 | } | ||
| 2468 | }, | ||
| 2469 | "node_modules/eslint-scope": { | 2289 | "node_modules/eslint-scope": { |
| 2470 | "version": "7.2.2", | 2290 | "version": "7.2.2", |
| 2471 | "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", | 2291 | "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", |
| @@ -2786,34 +2606,6 @@ | |||
| 2786 | "license": "MIT", | 2606 | "license": "MIT", |
| 2787 | "peer": true | 2607 | "peer": true |
| 2788 | }, | 2608 | }, |
| 2789 | "node_modules/fast-glob": { | ||
| 2790 | "version": "3.3.2", | ||
| 2791 | "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", | ||
| 2792 | "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", | ||
| 2793 | "license": "MIT", | ||
| 2794 | "dependencies": { | ||
| 2795 | "@nodelib/fs.stat": "^2.0.2", | ||
| 2796 | "@nodelib/fs.walk": "^1.2.3", | ||
| 2797 | "glob-parent": "^5.1.2", | ||
| 2798 | "merge2": "^1.3.0", | ||
| 2799 | "micromatch": "^4.0.4" | ||
| 2800 | }, | ||
| 2801 | "engines": { | ||
| 2802 | "node": ">=8.6.0" | ||
| 2803 | } | ||
| 2804 | }, | ||
| 2805 | "node_modules/fast-glob/node_modules/glob-parent": { | ||
| 2806 | "version": "5.1.2", | ||
| 2807 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", | ||
| 2808 | "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", | ||
| 2809 | "license": "ISC", | ||
| 2810 | "dependencies": { | ||
| 2811 | "is-glob": "^4.0.1" | ||
| 2812 | }, | ||
| 2813 | "engines": { | ||
| 2814 | "node": ">= 6" | ||
| 2815 | } | ||
| 2816 | }, | ||
| 2817 | "node_modules/fast-json-stable-stringify": { | 2609 | "node_modules/fast-json-stable-stringify": { |
| 2818 | "version": "2.1.0", | 2610 | "version": "2.1.0", |
| 2819 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", | 2611 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", |
| @@ -3197,26 +2989,6 @@ | |||
| 3197 | "node": ">=4" | 2989 | "node": ">=4" |
| 3198 | } | 2990 | } |
| 3199 | }, | 2991 | }, |
| 3200 | "node_modules/globby": { | ||
| 3201 | "version": "11.1.0", | ||
| 3202 | "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", | ||
| 3203 | "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", | ||
| 3204 | "license": "MIT", | ||
| 3205 | "dependencies": { | ||
| 3206 | "array-union": "^2.1.0", | ||
| 3207 | "dir-glob": "^3.0.1", | ||
| 3208 | "fast-glob": "^3.2.9", | ||
| 3209 | "ignore": "^5.2.0", | ||
| 3210 | "merge2": "^1.4.1", | ||
| 3211 | "slash": "^3.0.0" | ||
| 3212 | }, | ||
| 3213 | "engines": { | ||
| 3214 | "node": ">=10" | ||
| 3215 | }, | ||
| 3216 | "funding": { | ||
| 3217 | "url": "https://github.com/sponsors/sindresorhus" | ||
| 3218 | } | ||
| 3219 | }, | ||
| 3220 | "node_modules/gopd": { | 2992 | "node_modules/gopd": { |
| 3221 | "version": "1.2.0", | 2993 | "version": "1.2.0", |
| 3222 | "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", | 2994 | "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", |
| @@ -4464,15 +4236,6 @@ | |||
| 4464 | "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", | 4236 | "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", |
| 4465 | "license": "MIT" | 4237 | "license": "MIT" |
| 4466 | }, | 4238 | }, |
| 4467 | "node_modules/merge2": { | ||
| 4468 | "version": "1.4.1", | ||
| 4469 | "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", | ||
| 4470 | "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", | ||
| 4471 | "license": "MIT", | ||
| 4472 | "engines": { | ||
| 4473 | "node": ">= 8" | ||
| 4474 | } | ||
| 4475 | }, | ||
| 4476 | "node_modules/micromatch": { | 4239 | "node_modules/micromatch": { |
| 4477 | "version": "4.0.8", | 4240 | "version": "4.0.8", |
| 4478 | "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", | 4241 | "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", |
| @@ -5574,18 +5337,6 @@ | |||
| 5574 | "tree-kill": "cli.js" | 5337 | "tree-kill": "cli.js" |
| 5575 | } | 5338 | } |
| 5576 | }, | 5339 | }, |
| 5577 | "node_modules/ts-api-utils": { | ||
| 5578 | "version": "1.3.0", | ||
| 5579 | "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", | ||
| 5580 | "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", | ||
| 5581 | "license": "MIT", | ||
| 5582 | "engines": { | ||
| 5583 | "node": ">=16" | ||
| 5584 | }, | ||
| 5585 | "peerDependencies": { | ||
| 5586 | "typescript": ">=4.2.0" | ||
| 5587 | } | ||
| 5588 | }, | ||
| 5589 | "node_modules/tslib": { | 5340 | "node_modules/tslib": { |
| 5590 | "version": "2.6.3", | 5341 | "version": "2.6.3", |
| 5591 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", | 5342 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", |
| @@ -5637,6 +5388,7 @@ | |||
| 5637 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", | 5388 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", |
| 5638 | "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", | 5389 | "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", |
| 5639 | "license": "Apache-2.0", | 5390 | "license": "Apache-2.0", |
| 5391 | "optional": true, | ||
| 5640 | "peer": true, | 5392 | "peer": true, |
| 5641 | "bin": { | 5393 | "bin": { |
| 5642 | "tsc": "bin/tsc", | 5394 | "tsc": "bin/tsc", |
| @@ -3,12 +3,13 @@ | |||
| 3 | "type": "module", | 3 | "type": "module", |
| 4 | "license": "AGPL-3.0", | 4 | "license": "AGPL-3.0", |
| 5 | "scripts": { | 5 | "scripts": { |
| 6 | "test": "jest" | 6 | "test": "npm run test:unit && npm run test:e2e", |
| 7 | "test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest.config.json", | ||
| 8 | "test:e2e": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest-e2e.config.json" | ||
| 7 | }, | 9 | }, |
| 8 | "dependencies": { | 10 | "dependencies": { |
| 9 | "@types/jest": "^29.5.12", | 11 | "@types/jest": "^29.5.12", |
| 10 | "eslint": "^8.57.0", | 12 | "eslint": "^8.57.0", |
| 11 | "eslint-plugin-jest": "^28.6.0", | ||
| 12 | "jest": "^29.7.0", | 13 | "jest": "^29.7.0", |
| 13 | "jest-puppeteer": "^10.0.1" | 14 | "jest-puppeteer": "^10.0.1" |
| 14 | } | 15 | } |
| @@ -0,0 +1,107 @@ | |||
| 1 | import { describe, it, expect } from '@jest/globals'; | ||
| 2 | import { CHAT_COMPLETION_SOURCES } from '../src/constants'; | ||
| 3 | import { flattenSchema } from '../src/util'; | ||
| 4 | |||
| 5 | describe('flattenSchema', () => { | ||
| 6 | it('should return the schema if it is not an object', () => { | ||
| 7 | const schema = 'it is not an object'; | ||
| 8 | expect(flattenSchema(schema, CHAT_COMPLETION_SOURCES.MAKERSUITE)).toBe(schema); | ||
| 9 | }); | ||
| 10 | |||
| 11 | it('should handle schema with $defs and $ref', () => { | ||
| 12 | const schema = { | ||
| 13 | $schema: 'http://json-schema.org/draft-07/schema#', | ||
| 14 | $defs: { | ||
| 15 | a: { type: 'string' }, | ||
| 16 | b: { | ||
| 17 | type: 'object', | ||
| 18 | properties: { | ||
| 19 | c: { $ref: '#/$defs/a' }, | ||
| 20 | }, | ||
| 21 | }, | ||
| 22 | }, | ||
| 23 | properties: { | ||
| 24 | d: { $ref: '#/$defs/b' }, | ||
| 25 | }, | ||
| 26 | }; | ||
| 27 | const expected = { | ||
| 28 | properties: { | ||
| 29 | d: { | ||
| 30 | type: 'object', | ||
| 31 | properties: { | ||
| 32 | c: { type: 'string' }, | ||
| 33 | }, | ||
| 34 | }, | ||
| 35 | }, | ||
| 36 | }; | ||
| 37 | expect(flattenSchema(schema, CHAT_COMPLETION_SOURCES.MAKERSUITE)).toEqual(expected); | ||
| 38 | }); | ||
| 39 | |||
| 40 | it('should filter unsupported properties for Google API schema', () => { | ||
| 41 | const schema = { | ||
| 42 | $defs: { | ||
| 43 | a: { | ||
| 44 | type: 'string', | ||
| 45 | default: 'test', | ||
| 46 | }, | ||
| 47 | }, | ||
| 48 | type: 'object', | ||
| 49 | properties: { | ||
| 50 | b: { $ref: '#/$defs/a' }, | ||
| 51 | c: { type: 'number' }, | ||
| 52 | }, | ||
| 53 | additionalProperties: false, | ||
| 54 | exclusiveMinimum: 0, | ||
| 55 | propertyNames: { | ||
| 56 | pattern: '^[A-Za-z_][A-Za-z0-9_]*$', | ||
| 57 | }, | ||
| 58 | }; | ||
| 59 | const expected = { | ||
| 60 | type: 'object', | ||
| 61 | properties: { | ||
| 62 | b: { | ||
| 63 | type: 'string', | ||
| 64 | }, | ||
| 65 | c: { type: 'number' }, | ||
| 66 | }, | ||
| 67 | }; | ||
| 68 | expect(flattenSchema(schema, CHAT_COMPLETION_SOURCES.MAKERSUITE)).toEqual(expected); | ||
| 69 | }); | ||
| 70 | |||
| 71 | it('should not filter properties for non-Google API schema', () => { | ||
| 72 | const schema = { | ||
| 73 | $defs: { | ||
| 74 | a: { | ||
| 75 | type: 'string', | ||
| 76 | default: 'test', | ||
| 77 | }, | ||
| 78 | }, | ||
| 79 | type: 'object', | ||
| 80 | properties: { | ||
| 81 | b: { $ref: '#/$defs/a' }, | ||
| 82 | c: { type: 'number' }, | ||
| 83 | }, | ||
| 84 | additionalProperties: false, | ||
| 85 | exclusiveMinimum: 0, | ||
| 86 | propertyNames: { | ||
| 87 | pattern: '^[A-Za-z_][A-Za-z0-9_]*$', | ||
| 88 | }, | ||
| 89 | }; | ||
| 90 | const expected = { | ||
| 91 | type: 'object', | ||
| 92 | properties: { | ||
| 93 | b: { | ||
| 94 | type: 'string', | ||
| 95 | default: 'test', | ||
| 96 | }, | ||
| 97 | c: { type: 'number' }, | ||
| 98 | }, | ||
| 99 | additionalProperties: false, | ||
| 100 | exclusiveMinimum: 0, | ||
| 101 | propertyNames: { | ||
| 102 | pattern: '^[A-Za-z_][A-Za-z0-9_]*$', | ||
| 103 | }, | ||
| 104 | }; | ||
| 105 | expect(flattenSchema(schema, 'some-other-api')).toEqual(expected); | ||
| 106 | }); | ||
| 107 | }); | ||