From 26f986041fbe37ce6d1012760b2040020199349a Mon Sep 17 00:00:00 2001 From: jankapunkt Date: Tue, 20 Oct 2026 10:20:37 +0200 Subject: [PATCH 1/8] tests: add coverage --- .gitignore | 4 + README.md | 32 +- coverage-support/collect.js | 32 ++ coverage-support/run.cjs | 54 +++ package-lock.json | 755 ++++++++++++++++++++++++++++++++++++ package.js | 14 +- package.json | 16 + validated-method-tests.js | 4 +- 8 files changed, 903 insertions(+), 8 deletions(-) create mode 100644 .gitignore create mode 100644 coverage-support/collect.js create mode 100644 coverage-support/run.cjs create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd75927 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +coverage-source/ +.nyc_output/ +coverage/ diff --git a/README.md b/README.md index 8ef2dc7..0586aae 100644 --- a/README.md +++ b/README.md @@ -343,6 +343,36 @@ FlowRouter.go('listsShow', { _id: listId }); ### Running tests +```shell +npm ci +npm run test # runs once +npm run test:watch # reruns on changes ``` -meteor test-packages --driver-package practicalmeteor:mocha ./ + +### Package test coverage + +Install the development tools and run the same package tests with manual +[Istanbul instrumentation](https://github.com/istanbuljs/istanbuljs/tree/main/packages/istanbul-lib-instrument): + +```shell +npm ci +npm run test:coverage ``` + +The runner instruments a temporary copy of `validated-method.js` before Meteor +compiles it, then runs +`meteor test-packages --once --driver-package meteortesting:mocha ./`. +Only coverage runs select this copy; ordinary package consumers use the original +source. Test-only Mocha hooks save counters in `.nyc_output/`. The runner merges +the counters and writes `coverage/index.html`, `coverage/lcov.info`, and +`coverage/coverage-final.json`, with locations referring to the original source. +It preserves a failing test command's exit status and removes the generated source. +Run only one coverage process at a time in this checkout. + +For browser coverage, configure the test driver's browser support (for example, +`TEST_BROWSER_DRIVER=puppeteer npm run test:coverage` with Puppeteer available to +the driver). The client hook awaits transfer of its counters to the test server +before finishing. Without a browser, the runner explicitly reports server-only +coverage; client branches remain uncovered. Reports are also generated after +test failures if the hooks collected counters. Startup failures produce an error +instead of an empty coverage report. diff --git a/coverage-support/collect.js b/coverage-support/collect.js new file mode 100644 index 0000000..7f12bd3 --- /dev/null +++ b/coverage-support/collect.js @@ -0,0 +1,32 @@ +import { Meteor } from 'meteor/meteor'; + +// Loaded only into the local test package during an instrumented run. +const methodName = '__validatedMethodCoverageReport'; +if (Meteor.isServer) { + const fs = Npm.require('fs'); + const path = Npm.require('path'); + const write = (name, coverage) => { + if (!coverage || !Object.keys(coverage).length) { + throw new Error(`Missing ${name} coverage counters`); + } + fs.writeFileSync( + path.join(process.env.VALIDATED_METHOD_COVERAGE, `${name}.json`), + JSON.stringify(coverage), + ); + }; + Meteor.methods({ + [methodName](coverage) { + write('client', coverage); + // Include server execution caused by client tests, regardless of suite order. + write('server', globalThis.__validatedMethodCoverage__); + }, + }); + after(function () { + write('server', globalThis.__validatedMethodCoverage__); + }); +} else { + after(async function () { + this.timeout(10000); + await Meteor.callAsync(methodName, globalThis.__validatedMethodCoverage__); + }); +} diff --git a/coverage-support/run.cjs b/coverage-support/run.cjs new file mode 100644 index 0000000..919c6d4 --- /dev/null +++ b/coverage-support/run.cjs @@ -0,0 +1,54 @@ +const fs = require('node:fs'); +const path = require('node:path'); +const { spawnSync } = require('node:child_process'); +const { createInstrumenter } = require('istanbul-lib-instrument'); +const { createCoverageMap } = require('istanbul-lib-coverage'); +const { createContext } = require('istanbul-lib-report'); +const reports = require('istanbul-reports'); + +const root = path.resolve(__dirname, '..'); +const generated = path.join(root, 'coverage-source'); +const raw = path.join(root, '.nyc_output'); +const output = path.join(root, 'coverage'); +const source = path.join(root, 'validated-method.js'); +for (const dir of [generated, raw, output]) { + fs.rmSync(dir, { recursive: true, force: true }); + fs.mkdirSync(dir, { recursive: true }); +} +const instrumenter = createInstrumenter({ + esModules: true, + coverageVariable: '__validatedMethodCoverage__', + coverageGlobalScope: 'globalThis', + coverageGlobalScopeFunc: false, +}); +fs.writeFileSync(path.join(generated, 'validated-method.js'), + instrumenter.instrumentSync(fs.readFileSync(source, 'utf8'), source)); + +try { + const result = spawnSync('meteor', + ['test-packages', '--once', '--driver-package', 'meteortesting:mocha', './'], { + cwd: root, + stdio: 'inherit', + env: { ...process.env, VALIDATED_METHOD_COVERAGE: raw }, + }); + if (result.error) throw result.error; + const files = fs.readdirSync(raw).filter(file => file.endsWith('.json')); + if (!files.includes('server.json')) { + throw new Error('No server coverage collected; the package test harness did not finish.'); + } + const map = createCoverageMap({}); + for (const file of files) { + map.merge(JSON.parse(fs.readFileSync(path.join(raw, file), 'utf8'))); + } + const context = createContext({ dir: output, coverageMap: map }); + for (const reporter of ['text', 'html', 'lcovonly', 'json']) { + reports.create(reporter).execute(context); + } + console.log(`Coverage reports: ${output}`); + if (!files.includes('client.json')) { + console.warn('Server-only coverage: no browser coverage was received.'); + } + process.exitCode = result.status === null ? 1 : result.status; +} finally { + fs.rmSync(generated, { recursive: true, force: true }); +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..8572e94 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,755 @@ +{ + "name": "validated-method", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "chai": "^6.3.0", + "istanbul-lib-coverage": "3.2.2", + "istanbul-lib-instrument": "6.0.3", + "istanbul-lib-report": "3.0.1", + "istanbul-reports": "3.2.0", + "simpl-schema": "^1.13.1" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", + "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz", + "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helpers": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz", + "integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@babel/types": "^7.29.8", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", + "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", + "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", + "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", + "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", + "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.29.10", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.10.tgz", + "integrity": "sha512-EMCx3AGZ3WfAl6ht7AyQoPm2Lh+BGYEMdc4Q6Hf7uSCDOZFuLq44qNwL+iaim8VlyYhRAo4X43+weadK8ZB4Yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.8" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", + "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.10", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.10.tgz", + "integrity": "sha512-B3lYAs2nkKskbgQ1nfy8Ma9ao9Q1rntTAQHrzzyDuj+TSO+X3le6PfWwqDvodsb+OumE10eMFfuMCTQSQ5iuIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.8", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.9", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.8", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz", + "integrity": "sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.30", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.30.tgz", + "integrity": "sha512-YJs6Pz17RMNv8HoyKREtCY38E3BV1nPkWVmIb+XN1uHC1Vqt3KZCH/uJH9ZKRoiKb/icZ6tvehyee6RZNbFfRA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/browserslist": { + "version": "4.29.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.4.tgz", + "integrity": "sha512-2TcbbiwXEq+N0kD36tykpCfyyQigUXmuwNQbnPp4Xk4PX9JOqVIKjJlIDjpH7uY6tmRGoAd+apeT1p60T8wsdA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.29", + "caniuse-lite": "^1.0.30001816", + "electron-to-chromium": "^1.5.459", + "node-releases": "^2.0.59", + "update-browserslist-db": "^1.3.4" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001817", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001817.tgz", + "integrity": "sha512-uZ1JG80BwhtMalIAGPxPfmNhHyd/B/nTdr3hITWlRamSyAdUStP1Gop01e7SD5q6J90ixJvWDbvmiFVfDgn4bw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/chai": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz", + "integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.460", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.460.tgz", + "integrity": "sha512-rRaVC7bNUyGsL+GMtmZfv3AfgG6za7gE9v5bT0PIbjEerddA0IQ+tCK05NFAXqCpNlrxBZqbFqquyxHRQONHTA==", + "dev": true, + "license": "ISC" + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", + "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@babel/core": "^7.23.9", + "@babel/parser": "^7.23.9", + "@istanbuljs/schema": "^0.1.3", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", + "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha512-xYHt68QRoYGjeeM/XOE1uJtvXQAgvszfBhjV4yvsQH0u2i9I6cI6c6/eG4Hh3UAOVn0y/xAXwmTzEay49Q//HA==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.template": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.18.1.tgz", + "integrity": "sha512-5urZrLnV/VD6zHK5KsVtZgt7H19v51mIzoS0aBNH8yp3I8tbswrEjOABOPY8m8uB7NuibubLrMX+Y0PXsU9X+w==", + "deprecated": "This package is deprecated. Use https://socket.dev/npm/package/eta instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash._reinterpolate": "^3.0.0", + "lodash.templatesettings": "^4.0.0" + } + }, + "node_modules/lodash.templatesettings": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz", + "integrity": "sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash._reinterpolate": "^3.0.0" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/message-box": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/message-box/-/message-box-0.2.7.tgz", + "integrity": "sha512-C4ccA5nHb58kTS+pLrgF/JWtr7fAIkHxRDceH7tdy5fMA783nUfbYwZ7H2XLvSeYfcnWIYCig5dWW+icK9X/Ag==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash.template": "^4.5.0" + } + }, + "node_modules/mongo-object": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/mongo-object/-/mongo-object-0.1.4.tgz", + "integrity": "sha512-QtYk0gupWEn2+iB+DDRt1L+WbcNYvJRaHdih/dcqthOa1DbnREUGSs2WGcW478GNYpElflo/yybZXu0sTiRXHg==", + "dev": true, + "license": "MIT" + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-releases": { + "version": "2.0.59", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.59.tgz", + "integrity": "sha512-5qr2okC4ItAI0hG5SaV0HoYMpnM/Y6+Oqr7AmPYy/2uEoGvS+GbSKLeRxSS1uAdu59yz0ouzcuXievSgg///WA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/simpl-schema": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/simpl-schema/-/simpl-schema-1.13.1.tgz", + "integrity": "sha512-20Qc2X13TvLJYY37eapvJ5CWyYYSScX2BJV5RcP4A15efA4k8c0XEsp9F/RofQi/IMrp7PzyxTXyjwlG7EFhCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "clone": "^2.1.2", + "message-box": "^0.2.7", + "mongo-object": "^0.1.4" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.4.tgz", + "integrity": "sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + } + } +} diff --git a/package.js b/package.js index bb3bd93..1bd46a7 100644 --- a/package.js +++ b/package.js @@ -6,7 +6,7 @@ Package.describe({ }); Package.onUse(function (api) { - api.versionsFrom('1.7'); + api.versionsFrom(['1.7', '2.3', '3.0']); api.use([ 'ecmascript', @@ -14,19 +14,23 @@ Package.onUse(function (api) { 'ddp', ]); - api.mainModule('validated-method.js'); + api.mainModule(process.env.VALIDATED_METHOD_COVERAGE + ? 'coverage-source/validated-method.js' + : 'validated-method.js'); api.export('ValidatedMethod'); }); Package.onTest(function (api) { api.use([ 'ecmascript', - 'practicalmeteor:mocha@2.4.5_6', - 'practicalmeteor:chai@2.1.0_1', - 'aldeed:simple-schema@1.5.4', + 'meteortesting:mocha@3.0.0', + //'aldeed:simple-schema@3.0.0', // modern support 'mdg:validated-method', 'random' ]); + if (process.env.VALIDATED_METHOD_COVERAGE) { + api.addFiles('coverage-support/collect.js'); + } api.mainModule('validated-method-tests.js'); }); diff --git a/package.json b/package.json new file mode 100644 index 0000000..7c8fa95 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "private": true, + "scripts": { + "test": "meteor test-packages --once --driver-package meteortesting:mocha ./", + "test:watch": "meteor test-packages --driver-package meteortesting:mocha ./", + "test:coverage": "node coverage-support/run.cjs" + }, + "devDependencies": { + "chai": "^6.3.0", + "istanbul-lib-coverage": "3.2.2", + "istanbul-lib-instrument": "6.0.3", + "istanbul-lib-report": "3.0.1", + "istanbul-reports": "3.2.0", + "simpl-schema": "^1.13.1" + } +} diff --git a/validated-method-tests.js b/validated-method-tests.js index fa20838..c918723 100644 --- a/validated-method-tests.js +++ b/validated-method-tests.js @@ -1,7 +1,7 @@ import { Meteor } from 'meteor/meteor'; import { ValidatedMethod } from 'meteor/mdg:validated-method'; -import { SimpleSchema } from 'meteor/aldeed:simple-schema'; -import { assert } from 'meteor/practicalmeteor:chai'; +import SimpleSchema from 'simpl-schema'; +import { assert } from 'chai'; const plainMethod = new ValidatedMethod({ name: 'plainMethod', From 366dcaf7f2e34b0cd5905ac1e4243ebcca76461f Mon Sep 17 00:00:00 2001 From: jankapunkt Date: Tue, 20 Oct 2026 10:26:10 +0200 Subject: [PATCH 2/8] fix(tests): make tests running again --- validated-method-tests.js | 56 ++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/validated-method-tests.js b/validated-method-tests.js index c918723..63d182a 100644 --- a/validated-method-tests.js +++ b/validated-method-tests.js @@ -117,46 +117,58 @@ describe('mdg:method', () => { }); }); - it('allows methods to be called asynchronously', (done) => { - asyncMethod.callAsync({ param: 3000 }) - .then(result => { - assert.equal(result, 'result,result2,3000'); - done(); - }); + it('allows methods to be called asynchronously', async () => { + const result = await asyncMethod.callAsync({ param: 3000 }); + assert.equal(result, 'result,result2,3000'); }); [methodWithArgs, methodWithSchemaMixin].forEach((method) => { - it('checks schema ' + method.name, (done) => { - method.call({}, (error, result) => { - // 2 invalid fields - assert.equal(error.errors.length, 2); + it('checks schema ' + method.name, async () => { + const error = await new Promise(resolve => { + method.call({}, error => resolve(error)); + }); + // 2 invalid fields + assert.equal(error.details.length, 2); + const result = await new Promise((resolve, reject) => { method.call({ int: 5, string: "what", }, (error, result) => { - // All good! - assert.equal(result, 'result'); - - done(); + if (error) return reject(error); + resolve(result); }); }); + // All good! + assert.equal(result, 'result'); }); }); - it('throws error if no callback passed', (done) => { - methodThrowsImmediately.call({}, (err) => { - // If you pass a callback, you get the error in the callback - assert.ok(err); + it('passes errors to callbacks', async () => { + const error = await new Promise(resolve => { + methodThrowsImmediately.call({}, error => resolve(error)); + }); + assert.instanceOf(error, Meteor.Error); + assert.equal(error.error, 'error'); + }); - // If no callback, the error is thrown + it('propagates errors if no callback is passed', async () => { + if (Meteor.isServer) { + // Meteor 3 server calls reject their returned promise. + await methodThrowsImmediately.call({}).then( + () => assert.fail('Expected the method call to reject'), + error => { + assert.instanceOf(error, Meteor.Error); + assert.equal(error.error, 'error'); + } + ); + } else { + // Client stub errors still throw synchronously. assert.throws(() => { methodThrowsImmediately.call({}); }, /error/); - - done(); - }); + } }); it('throws error if a mixin does not return the options object', () => { From 712c57e668df8e979324508ebcf3a87eec316c08 Mon Sep 17 00:00:00 2001 From: jankapunkt Date: Tue, 20 Oct 2026 10:54:22 +0200 Subject: [PATCH 3/8] tests: improve coverage --- validated-method-tests.js | 265 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 265 insertions(+) diff --git a/validated-method-tests.js b/validated-method-tests.js index 63d182a..b666e0c 100644 --- a/validated-method-tests.js +++ b/validated-method-tests.js @@ -222,3 +222,268 @@ describe('mdg:method', () => { }); }); }); + +if (Meteor.isServer) { + describe('ValidatedMethod server contracts', () => { + function fixture(overrides = {}) { + const registrations = []; + const connection = { + methods(methods) { registrations.push(methods); }, + }; + const options = { + name: 'serverContract', + validate: null, + run() { return 'result'; }, + connection, + ...overrides, + }; + return { options, connection, registrations }; + } + + async function rejectsWith(promise, expected) { + await promise.then( + () => assert.fail('Expected rejection'), + error => assert.strictEqual(error, expected) + ); + } + + it('registers once on a custom connection and preserves invocation context', () => { + const args = { value: 42 }; + const context = { userId: 'user', name: 'oldName' }; + const result = {}; + const calls = []; + const f = fixture({ + validate(received) { + assert.strictEqual(this, context); + assert.strictEqual(received, args); + assert.equal(this.name, 'serverContract'); + assert.equal(this.userId, 'user'); + calls.push('validate'); + }, + run(received) { + assert.strictEqual(this, context); + assert.strictEqual(received, args); + assert.equal(this.name, 'serverContract'); + assert.equal(this.userId, 'user'); + calls.push('run'); + return result; + }, + }); + new ValidatedMethod(f.options); + assert.lengthOf(f.registrations, 1); + assert.deepEqual(Object.keys(f.registrations[0]), ['serverContract']); + assert.strictEqual(f.registrations[0].serverContract.call(context, args), result); + assert.deepEqual(calls, ['validate', 'run']); + }); + + for (const [label, connection] of [ + ['primitive', true], ['function', function () {}], ['missing methods', {}], + ]) { + it('rejects an invalid connection: ' + label, () => { + const f = fixture({ connection }); + assert.throws(() => new ValidatedMethod(f.options), /Invalid connection type/); + assert.isEmpty(f.registrations); + }); + } + + for (const [label, applyOptions, expected] of [ + ['defaults', undefined, { returnStubValue: true, throwStubExceptions: true }], + ['overrides', { returnStubValue: false, throwStubExceptions: false, wait: true }, + { returnStubValue: false, throwStubExceptions: false, wait: true }], + ]) { + it('forwards call arguments, callback, result and option ' + label, () => { + const f = fixture({ applyOptions }); + const args = { value: 1 }; + const callback = () => {}; + const result = {}; + let captured; + f.connection.apply = function (...received) { + assert.strictEqual(this, f.connection); + captured = received; + return result; + }; + const method = new ValidatedMethod(f.options); + assert.strictEqual(method.call(args, callback), result); + assert.deepEqual(captured, [method.name, [args], expected, callback]); + assert.strictEqual(captured[1][0], args); + assert.strictEqual(captured[2], method.applyOptions); + assert.strictEqual(captured[3], callback); + }); + } + + it('forwards callback-only calls with an empty argument object', () => { + const f = fixture(); + const callback = () => {}; + let captured; + f.connection.apply = (...args) => { captured = args; }; + const method = new ValidatedMethod(f.options); + method.call(callback); + assert.deepEqual(captured, [method.name, [{}], method.applyOptions, callback]); + }); + + it('delivers a synchronous transport error to the callback exactly once', () => { + const f = fixture(); + const error = new Error('transport'); + f.connection.apply = () => { throw error; }; + const method = new ValidatedMethod(f.options); + const received = []; + assert.doesNotThrow(() => method.call({}, err => received.push(err))); + assert.lengthOf(received, 1); + assert.strictEqual(received[0], error); + }); + + it('rethrows the identical synchronous transport error without a callback', () => { + const f = fixture(); + const error = new Error('transport'); + f.connection.apply = () => { throw error; }; + const method = new ValidatedMethod(f.options); + assert.strictEqual(assert.throws(() => method.call({})), error); + }); + + for (const [label, value] of [ + ['false', false], ['null', null], ['zero', 0], ['object', {}], + ['promise', Promise.resolve()], + ]) { + it('rejects a validator returning ' + label + ' before running', () => { + let runs = 0; + const f = fixture({ validate() { return value; }, run() { runs++; } }); + const method = new ValidatedMethod(f.options); + assert.throws(() => method._execute({}, {}), /Returning from validate/); + assert.equal(runs, 0); + }); + } + + it('preserves a validation exception and does not run', () => { + const error = new Error('validation'); + let runs = 0; + const f = fixture({ validate() { throw error; }, run() { runs++; } }); + const method = new ValidatedMethod(f.options); + assert.strictEqual(assert.throws(() => method._execute({}, {})), error); + assert.equal(runs, 0); + }); + + for (const [label, result] of [['value', {}], ['promise', Promise.resolve('result')]]) { + it('returns the identical run ' + label + ' after undefined validation', async () => { + const calls = []; + const f = fixture({ + validate() { calls.push('validate'); }, + run() { calls.push('run'); return result; }, + }); + const method = new ValidatedMethod(f.options); + const actual = method._execute(); + assert.strictEqual(actual, result); + assert.deepEqual(calls, ['validate', 'run']); + await actual; + }); + } + + for (const [label, overrides] of [ + ['missing name', { name: undefined }], ['invalid name', { name: 5 }], + ['non-array mixins', { mixins: {} }], ['non-function mixin', { mixins: [1] }], + ['missing validate', { validate: undefined }], ['invalid validate', { validate: true }], + ['missing run', { run: undefined }], ['invalid run', { run: true }], + ['invalid applyOptions', { applyOptions: true }], + ]) { + it('rejects ' + label + ' before registration', () => { + const f = fixture(overrides); + const error = assert.throws(() => new ValidatedMethod(f.options)); + assert.equal(error.errorType, 'Match.Error'); + assert.isEmpty(f.registrations); + }); + } + + it('accepts validate: null and executes the registered method', () => { + const f = fixture(); + new ValidatedMethod(f.options); + assert.lengthOf(f.registrations, 1); + assert.equal(f.registrations[0].serverContract.call({}), 'result'); + }); + + it('passes replacement options through mixins in order', () => { + const calls = []; + let replacement; + const custom = {}; + const f = fixture({ + custom, + mixins: [ + options => { + calls.push('first'); + replacement = { ...options, name: 'transformedContract' }; + return replacement; + }, + options => { + calls.push('second'); + assert.strictEqual(options, replacement); + options.validate = function () { calls.push('validate'); }; + options.run = function () { calls.push('run'); return this.custom; }; + return options; + }, + ], + }); + const method = new ValidatedMethod(f.options); + assert.strictEqual(method.custom, custom); + assert.deepEqual(Object.keys(f.registrations[0]), ['transformedContract']); + assert.strictEqual(method._execute({ custom }), custom); + assert.deepEqual(calls, ['first', 'second', 'validate', 'run']); + }); + + it('stops mixin processing and registration after an invalid return', () => { + let laterCalls = 0; + const f = fixture({ mixins: [ + () => {}, + options => { laterCalls++; return options; }, + ] }); + assert.throws(() => new ValidatedMethod(f.options), /didn't return the options object/); + assert.equal(laterCalls, 0); + assert.isEmpty(f.registrations); + }); + + for (const field of ['validate', 'run']) { + it('validates ' + field + ' after mixin transformation', () => { + const f = fixture({ mixins: [options => ({ ...options, [field]: true })] }); + const error = assert.throws(() => new ValidatedMethod(f.options)); + assert.equal(error.errorType, 'Match.Error'); + assert.isEmpty(f.registrations); + }); + } + + for (const rejects of [false, true]) { + it('forwards server callAsync and preserves its ' + (rejects ? 'rejected' : 'resolved') + ' promise', async () => { + const f = fixture({ applyOptions: { wait: true } }); + const args = { value: 1 }; + const value = rejects ? new Error('async transport') : {}; + const promise = rejects ? Promise.reject(value) : Promise.resolve(value); + let captured; + f.connection.applyAsync = function (...received) { + assert.strictEqual(this, f.connection); + captured = received; + return promise; + }; + const method = new ValidatedMethod(f.options); + const actual = method.callAsync(args); + assert.strictEqual(actual, promise); + assert.deepEqual(captured, [method.name, [args], method.applyOptions]); + assert.strictEqual(captured[1][0], args); + assert.strictEqual(captured[2], method.applyOptions); + if (rejects) await rejectsWith(actual, value); + else assert.strictEqual(await actual, value); + }); + } + + const rejectingMethod = new ValidatedMethod({ + name: 'validatedMethod.serverContracts.asyncRejection', + validate: null, + async run() { throw new Meteor.Error('server-contract-rejection'); }, + }); + + it('propagates a real server async run rejection', async () => { + await rejectingMethod.callAsync({}).then( + () => assert.fail('Expected rejection'), + error => { + assert.instanceOf(error, Meteor.Error); + assert.equal(error.error, 'server-contract-rejection'); + } + ); + }); + }); +} From 5cbefc037f4ab43771264bd19a38669d711237c9 Mon Sep 17 00:00:00 2001 From: jankapunkt Date: Tue, 20 Oct 2026 11:27:32 +0200 Subject: [PATCH 4/8] fix: support sync and async validate functions --- validated-method-tests.js | 229 +++++++++++++++++++++++++++++++++++++- validated-method.js | 24 +++- 2 files changed, 246 insertions(+), 7 deletions(-) diff --git a/validated-method-tests.js b/validated-method-tests.js index b666e0c..ba93fe1 100644 --- a/validated-method-tests.js +++ b/validated-method-tests.js @@ -1,6 +1,7 @@ import { Meteor } from 'meteor/meteor'; import { ValidatedMethod } from 'meteor/mdg:validated-method'; import SimpleSchema from 'simpl-schema'; +import AsyncSimpleSchema from 'meteor/aldeed:simple-schema'; import { assert } from 'chai'; const plainMethod = new ValidatedMethod({ @@ -89,6 +90,17 @@ const asyncMethod = new ValidatedMethod({ } }); +const assertThrows = async ({ fn, message }) => { + try { + await fn(); + assert.fail('Should have thrown'); + } catch (e) { + if (message) { + assert.match(e.message, new RegExp(message)); + } + } +} + function schemaMixin(methodOptions) { methodOptions.validate = methodOptions.schema.validator(); return methodOptions; @@ -342,13 +354,16 @@ if (Meteor.isServer) { for (const [label, value] of [ ['false', false], ['null', null], ['zero', 0], ['object', {}], - ['promise', Promise.resolve()], + ['promise', Promise.resolve('fail')], ]) { - it('rejects a validator returning ' + label + ' before running', () => { + it('rejects a validator returning ' + label + ' before running', async () => { let runs = 0; const f = fixture({ validate() { return value; }, run() { runs++; } }); const method = new ValidatedMethod(f.options); - assert.throws(() => method._execute({}, {}), /Returning from validate/); + await assertThrows({ + fn: () => method._execute({}, {}), + message: /Returning from validate/ + }) assert.equal(runs, 0); }); } @@ -487,3 +502,211 @@ if (Meteor.isServer) { }); }); } + + +// Keep the synchronous-schema suite above intact while specifying the async contract. +describe('mdg:method with AsyncSimpleSchema', () => { + const plainMethod = new ValidatedMethod({ + name: 'asyncSchema.plainMethod', + validate: new AsyncSimpleSchema({}).validator(), + run() { return 'result'; }, + }); + const noArgsMethod = new ValidatedMethod({ + name: 'asyncSchema.noArgsMethod', + validate: new AsyncSimpleSchema({}).validator(), + run() { return 'result'; }, + }); + const methodWithArgs = new ValidatedMethod({ + name: 'asyncSchema.methodWithArgs', + validate: new AsyncSimpleSchema({ + int: { type: Number }, + string: { type: String }, + }).validator(), + run() { return 'result'; }, + }); + const methodWithSchemaMixin = new ValidatedMethod({ + name: 'asyncSchema.methodWithSchemaMixin', + mixins: [schemaMixin], + schema: new AsyncSimpleSchema({ + int: { type: Number }, + string: { type: String }, + }), + run() { return 'result'; }, + }); + const methodThrowsImmediately = new ValidatedMethod({ + name: 'asyncSchema.methodThrowsImmediately', + validate: new AsyncSimpleSchema({}).validator(), + run() { throw new Meteor.Error('async-schema-run-error'); }, + }); + const methodReturnsName = new ValidatedMethod({ + name: 'asyncSchema.methodReturnsName', + validate: new AsyncSimpleSchema({}).validator(), + run() { return this.name; }, + }); + let resultReceived = false; + const methodWithApplyOptions = new ValidatedMethod({ + name: 'asyncSchema.methodWithApplyOptions', + validate: new AsyncSimpleSchema({}).validator(), + applyOptions: { + onResultReceived() { resultReceived = true; }, + }, + run() { return 'result'; }, + }); + const asyncMethod = new ValidatedMethod({ + name: 'asyncSchema.asyncMethod', + validate: new AsyncSimpleSchema({ param: { type: Number } }).validator(), + async run({ param }) { + await Promise.resolve(); + return ['result', 'result2', param].join(','); + }, + }); + + function callWithCallback(method, args) { + return new Promise((resolve, reject) => { + method.call(args, (error, result) => { + if (error) return reject(error); + resolve(result); + }); + }); + } + + async function expectRejection(invoke, checkError) { + let error; + try { + await invoke(); + } catch (caught) { + error = caught; + } + assert.exists(error, 'Expected the method to reject'); + checkError(error); + } + + it('defines a method callable through its callback and Meteor.call', async () => { + assert.equal(await callWithCallback(plainMethod, {}), 'result'); + const result = await new Promise((resolve, reject) => { + Meteor.call(plainMethod.name, {}, (error, value) => { + if (error) return reject(error); + resolve(value); + }); + }); + assert.equal(result, 'result'); + }); + + it('allows callback-only calls with an empty schema', async () => { + const result = await new Promise((resolve, reject) => { + noArgsMethod.call((error, value) => { + if (error) return reject(error); + resolve(value); + }); + }); + assert.equal(result, 'result'); + }); + + it('allows callAsync with a synchronous run function', async () => { + assert.equal(await plainMethod.callAsync({}), 'result'); + }); + + it('allows callAsync with an asynchronous run function', async () => { + assert.equal(await asyncMethod.callAsync({ param: 3000 }), 'result,result2,3000'); + }); + + for (const method of [methodWithArgs, methodWithSchemaMixin]) { + for (const [label, invoke] of [ + ['callback', args => callWithCallback(method, args)], + ['callAsync', args => method.callAsync(args)], + ['_execute', args => method._execute({}, args)], + ]) { + it('accepts valid arguments through ' + label + ': ' + method.name, async () => { + assert.equal(await invoke({ int: 5, string: 'what' }), 'result'); + }); + + it('rejects invalid arguments through ' + label + ': ' + method.name, async () => { + await expectRejection(() => invoke({}), error => { + assert.lengthOf(error.details, 2); + assert.sameMembers(error.details.map(detail => detail.name), ['int', 'string']); + }); + }); + } + } + + for (const [label, invoke] of [ + ['callback', () => callWithCallback(methodThrowsImmediately, {})], + ['callAsync', () => methodThrowsImmediately.callAsync({})], + ['_execute', () => methodThrowsImmediately._execute({}, {})], + ]) { + it('propagates run errors after validation through ' + label, async () => { + await expectRejection(invoke, error => { + assert.instanceOf(error, Meteor.Error); + assert.equal(error.error, 'async-schema-run-error'); + }); + }); + } + + it('has access to this.name during direct execution and callback calls', async () => { + assert.equal(await methodReturnsName._execute({}, {}), methodReturnsName.name); + assert.equal(await callWithCallback(methodReturnsName, {}), methodReturnsName.name); + }); + + if (Meteor.isClient) { + it('accepts Meteor.apply options', async () => { + resultReceived = false; + assert.equal(await callWithCallback(methodWithApplyOptions, {}), 'result'); + assert.isTrue(resultReceived); + }); + } + + it('awaits validation before running and preserves invocation context', async () => { + const args = { int: 5 }; + const context = { userId: 'user' }; + const calls = []; + const schema = new AsyncSimpleSchema({ int: { type: Number } }); + const registrations = []; + const method = new ValidatedMethod({ + name: 'asyncSchema.contextAndOrder', + connection: { methods(methods) { registrations.push(methods); } }, + async validate(received) { + assert.strictEqual(this, context); + assert.strictEqual(received, args); + await schema.validate(received); + calls.push('validated'); + }, + run(received) { + assert.strictEqual(this, context); + assert.strictEqual(received, args); + assert.equal(this.name, 'asyncSchema.contextAndOrder'); + assert.equal(this.userId, 'user'); + assert.deepEqual(calls, ['validated']); + calls.push('run'); + return 'result'; + }, + }); + assert.lengthOf(registrations, 1); + assert.equal(await registrations[0][method.name].call(context, args), 'result'); + assert.deepEqual(calls, ['validated', 'run']); + }); + + it('preserves the schema rejection and never runs on invalid arguments', async () => { + const schema = new AsyncSimpleSchema({ int: { type: Number } }); + let validationError; + let runs = 0; + const method = new ValidatedMethod({ + name: 'asyncSchema.validationRejection', + connection: { methods() {} }, + async validate(args) { + try { + await schema.validate(args); + } catch (error) { + validationError = error; + throw error; + } + }, + run() { runs++; }, + }); + await expectRejection(() => method._execute({}, {}), error => { + assert.strictEqual(error, validationError); + assert.lengthOf(error.details, 1); + assert.equal(error.details[0].name, 'int'); + }); + assert.equal(runs, 0); + }); +}); diff --git a/validated-method.js b/validated-method.js index 9ed4ad1..b9d4a74 100644 --- a/validated-method.js +++ b/validated-method.js @@ -132,15 +132,31 @@ export class ValidatedMethod { methodInvocation.name = this.name; const validateResult = this.validate.bind(methodInvocation)(args); - - if (typeof validateResult !== 'undefined') { + const boundFn = this.run.bind(methodInvocation); + const isUndefined = typeof validateResult === 'undefined'; + const isPromiseLike = typeof validateResult?.then === 'function'; + const fail = () => { throw new Error(`Returning from validate doesn't do anything; \ perhaps you meant to throw an error?`); + }; + + if (!isUndefined) { + if (isPromiseLike) { + const runAsync = async () => { + const validateResultValue = await validateResult; + if (typeof validateResultValue !== 'undefined') { + fail(); + } + return boundFn(args); + } + return runAsync(); + } + fail(); } - return this.run.bind(methodInvocation)(args); + return boundFn(args); } -}; +} // Mixins get a chance to transform the arguments before they are passed to the actual Method function applyMixins(args, mixins) { From 6923663d34dab39d8251369414f8849d0855dd9b Mon Sep 17 00:00:00 2001 From: jankapunkt Date: Tue, 20 Oct 2026 11:36:00 +0200 Subject: [PATCH 5/8] tests: updated tests to coverage async validator --- package-lock.json | 366 ++++++++++++++++++++++++++++++++++++++ package.js | 2 +- package.json | 4 +- validated-method-tests.js | 222 +++++++++++++++++++++++ 4 files changed, 592 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8572e94..2f27cff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "istanbul-lib-instrument": "6.0.3", "istanbul-lib-report": "3.0.1", "istanbul-reports": "3.2.0", + "puppeteer": "^25.14.0", "simpl-schema": "^1.13.1" } }, @@ -333,6 +334,61 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@puppeteer/browsers": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.2.5.tgz", + "integrity": "sha512-UoCo3Pynbm37aLEEoydSiG+t24ui7sLD40+07CKxzxNy4PpSowJMkvlLIiV67XjP1lMVynhQVnuwlTABqBH8LQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "modern-tar": "^0.8.5", + "yargs": "^18.0.0" + }, + "bin": { + "browsers": "lib/main-cli.js" + }, + "engines": { + "node": ">=22.12.0" + }, + "peerDependencies": { + "proxy-agent": ">=8.0.1", + "yauzl": "^2.10.0 || ^3.4.0" + }, + "peerDependenciesMeta": { + "proxy-agent": { + "optional": true + }, + "yauzl": { + "optional": true + } + } + }, + "node_modules/ansi-regex": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", + "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/baseline-browser-mapping": { "version": "2.11.30", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.30.tgz", @@ -411,6 +467,56 @@ "node": ">=18" } }, + "node_modules/chromium-bidi": { + "version": "157.0.8090-0", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-157.0.8090-0.tgz", + "integrity": "sha512-KJw7IQgqXwxpJgJlEIPg5mr2ZoqA+jkTRtc5EABI7sUJ3bu3cpI7NuEBoj4Gn1AsF78CaT9So5WQWspK3/wYag==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "mitt": "^3.0.1", + "zod": "^4.6.5" + }, + "engines": { + "node": ">=20.19.0 <22.0.0 || >=22.12.0" + }, + "peerDependencies": { + "devtools-protocol": "*" + } + }, + "node_modules/cliui": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", + "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^7.2.0", + "strip-ansi": "^7.1.0", + "wrap-ansi": "^9.0.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/clone": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", @@ -446,6 +552,13 @@ } } }, + "node_modules/devtools-protocol": { + "version": "0.0.1696802", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1696802.tgz", + "integrity": "sha512-FO5/SENfvc2K8wRnWQflKcwuoTH4dBkXCWTQ9ebIWtuX8JM5+ZvCotaEmkfh21pO7TvIKGTM3hG4xFiq9WTwmg==", + "dev": true, + "license": "BSD-3-Clause" + }, "node_modules/electron-to-chromium": { "version": "1.5.460", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.460.tgz", @@ -453,6 +566,13 @@ "dev": true, "license": "ISC" }, + "node_modules/emoji-regex": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", + "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", + "dev": true, + "license": "MIT" + }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -473,6 +593,29 @@ "node": ">=6.9.0" } }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-east-asian-width": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", + "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -579,6 +722,19 @@ "node": ">=6" } }, + "node_modules/lilconfig": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.4.tgz", + "integrity": "sha512-zJZyBmQhArDRefuWTypZxwDpFDIYmrj8ypSBvwGD5P13Y95s6DjzKgu4DVdGbeQa5PDEsAOCAPNk4X+QOR006w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antonk52" + } + }, "node_modules/lodash._reinterpolate": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", @@ -644,6 +800,23 @@ "lodash.template": "^4.5.0" } }, + "node_modules/mitt": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", + "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==", + "dev": true, + "license": "MIT" + }, + "node_modules/modern-tar": { + "version": "0.8.6", + "resolved": "https://registry.npmjs.org/modern-tar/-/modern-tar-0.8.6.tgz", + "integrity": "sha512-LYSks0tNVqbtez/9OB0YFP6qLRSqkdAxJWOQpVaR67lNTbj2zNLyYpowkRMia5lXLCZKzxwoxkxH2MbbBR2aEg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/mongo-object": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/mongo-object/-/mongo-object-0.1.4.tgz", @@ -675,6 +848,46 @@ "dev": true, "license": "ISC" }, + "node_modules/puppeteer": { + "version": "25.14.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-25.14.0.tgz", + "integrity": "sha512-+s1Iqbl9DsGLOaQdgCQyhtgHZsF9hi4Iu8iuBqxzraxUXoRG1QkYQI0CA1/VsNK1gZWJfs50BL/oOb1L+Yz8Yg==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@puppeteer/browsers": "3.2.5", + "chromium-bidi": "157.0.8090-0", + "devtools-protocol": "0.0.1696802", + "lilconfig": "^3.1.3", + "puppeteer-core": "25.14.0", + "typed-query-selector": "^2.12.3" + }, + "bin": { + "puppeteer": "lib/puppeteer/node/cli.js" + }, + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/puppeteer-core": { + "version": "25.14.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-25.14.0.tgz", + "integrity": "sha512-LQitnes3tBeVbdZ7V/4iwJPLZGgkl9uBVK0W7YYMh68j/3Y9eNuvj4yl+Fdo7zN0SuajOMrhd7aPj3DifK8k6A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@puppeteer/browsers": "3.2.5", + "chromium-bidi": "157.0.8090-0", + "devtools-protocol": "0.0.1696802", + "typed-query-selector": "^2.12.3", + "webdriver-bidi-protocol": "1.0.1", + "ws": "^8.22.0" + }, + "engines": { + "node": ">=22.12.0" + } + }, "node_modules/semver": { "version": "7.8.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", @@ -700,6 +913,39 @@ "mongo-object": "^0.1.4" } }, + "node_modules/string-width": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz", + "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-east-asian-width": "^1.5.0", + "strip-ansi": "^7.1.2" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -713,6 +959,13 @@ "node": ">=8" } }, + "node_modules/typed-query-selector": { + "version": "2.12.3", + "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.3.tgz", + "integrity": "sha512-/dtuMZyutHLlrxWhhC1uib00ELUr2dZ8C9B8YzZYsJmeE3V56OxRblrSM2UaF142pcMtak7ehZ6+poWGeehNIg==", + "dev": true, + "license": "MIT" + }, "node_modules/update-browserslist-db": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.4.tgz", @@ -744,12 +997,125 @@ "browserslist": ">= 4.21.0" } }, + "node_modules/webdriver-bidi-protocol": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/webdriver-bidi-protocol/-/webdriver-bidi-protocol-1.0.1.tgz", + "integrity": "sha512-WXWs/aXF2a6Al1Z2/V/7Gp2oPZOAAmHjJOTmv4KCXRJ122IMj3tSSMc6a4q3K4QOmhQbse/Ahr+oTVJOU2dUiw==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/wrap-ansi": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ws": { + "version": "8.22.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", + "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true, "license": "ISC" + }, + "node_modules/yargs": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz", + "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^9.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "string-width": "^8.2.1", + "y18n": "^5.0.5", + "yargs-parser": "^22.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, + "node_modules/yargs-parser": { + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", + "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, + "node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/package.js b/package.js index 1bd46a7..469eecd 100644 --- a/package.js +++ b/package.js @@ -24,7 +24,7 @@ Package.onTest(function (api) { api.use([ 'ecmascript', 'meteortesting:mocha@3.0.0', - //'aldeed:simple-schema@3.0.0', // modern support + 'aldeed:simple-schema@3.0.0', // modern support 'mdg:validated-method', 'random' ]); diff --git a/package.json b/package.json index 7c8fa95..e7f2c7a 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "scripts": { "test": "meteor test-packages --once --driver-package meteortesting:mocha ./", "test:watch": "meteor test-packages --driver-package meteortesting:mocha ./", - "test:coverage": "node coverage-support/run.cjs" + "test:coverage": "node coverage-support/run.cjs", + "test:ci": "TEST_BROWSER_DRIVER=puppeteer npm run test:coverage" }, "devDependencies": { "chai": "^6.3.0", @@ -11,6 +12,7 @@ "istanbul-lib-instrument": "6.0.3", "istanbul-lib-report": "3.0.1", "istanbul-reports": "3.2.0", + "puppeteer": "^25.14.0", "simpl-schema": "^1.13.1" } } diff --git a/validated-method-tests.js b/validated-method-tests.js index ba93fe1..b277199 100644 --- a/validated-method-tests.js +++ b/validated-method-tests.js @@ -710,3 +710,225 @@ describe('mdg:method with AsyncSimpleSchema', () => { assert.equal(runs, 0); }); }); + +import { DDP } from 'meteor/ddp-client'; + +// Exercise promise/thenable contracts independently of a particular schema library. +describe('ValidatedMethod async validation contracts', () => { + function fixture(validate, run) { + return new ValidatedMethod({ + name: 'asyncValidationContract', + connection: { methods() {} }, + validate, + run, + }); + } + + async function rejectsWith(invoke, expected) { + let caught; + try { + await invoke(); + } catch (error) { + caught = error; + } + assert.strictEqual(caught, expected); + } + + it('does not run until pending validation resolves', async () => { + let finishValidation; + const validation = new Promise(resolve => { finishValidation = resolve; }); + const args = { value: 42 }; + const context = { userId: 'user' }; + const result = {}; + let runs = 0; + const method = fixture(() => validation, function (received) { + runs++; + assert.strictEqual(this, context); + assert.strictEqual(received, args); + return result; + }); + const execution = method._execute(context, args); + assert.equal(runs, 0); + finishValidation(); + assert.strictEqual(await execution, result); + assert.equal(runs, 1); + }); + + it('preserves a delayed validation rejection without running', async () => { + let rejectValidation; + const validation = new Promise((resolve, reject) => { rejectValidation = reject; }); + const error = new Error('delayed validation'); + let runs = 0; + const method = fixture(() => validation, () => { runs++; }); + const execution = method._execute({}, {}); + const assertion = rejectsWith(() => execution, error); + rejectValidation(error); + await assertion; + assert.equal(runs, 0); + }); + + for (const [label, value] of [['false', false], ['null', null], ['zero', 0], ['object', {}]]) { + it('rejects async validation resolving to ' + label + ' without running', async () => { + let runs = 0; + const method = fixture(async () => value, () => { runs++; }); + let caught; + try { + await method._execute({}, {}); + } catch (error) { + caught = error; + } + assert.instanceOf(caught, Error); + assert.match(caught.message, /Returning from validate/); + assert.equal(runs, 0); + }); + } + + it('awaits a custom validation thenable with no catch method', async () => { + const calls = []; + const validation = { + then(resolve) { + assert.strictEqual(this, validation); + calls.push('validate'); + resolve(); + }, + }; + const result = {}; + const method = fixture(() => validation, () => { + calls.push('run'); + return result; + }); + assert.strictEqual(await method._execute({}, {}), result); + assert.deepEqual(calls, ['validate', 'run']); + }); + + it('preserves rejection from a custom validation thenable', async () => { + const error = new Error('thenable validation'); + let runs = 0; + const method = fixture(() => ({ then(resolve, reject) { reject(error); } }), + () => { runs++; }); + await rejectsWith(() => method._execute({}, {}), error); + assert.equal(runs, 0); + }); + + it('rejects a validation result whose then property is not callable', () => { + let runs = 0; + const method = fixture(() => ({ then: true }), () => { runs++; }); + assert.throws(() => method._execute({}, {}), /Returning from validate/); + assert.equal(runs, 0); + }); + + it('preserves an async run rejection after successful async validation', async () => { + const error = new Error('async run'); + const method = fixture(async () => {}, async () => { throw error; }); + await rejectsWith(() => method._execute({}, {}), error); + }); +}); + +if (Meteor.isClient) { + describe('ValidatedMethod client callAsync contracts', () => { + let previousInvocation; + let previousRunning; + + beforeEach(() => { + previousInvocation = DDP._CurrentMethodInvocation.get(); + previousRunning = DDP._CurrentMethodInvocation._isCallAsyncMethodRunning(); + }); + + afterEach(() => { + DDP._CurrentMethodInvocation._set(previousInvocation); + DDP._CurrentMethodInvocation._setCallAsyncMethodRunning(previousRunning); + }); + + function fixture(applyAsync) { + const connection = { methods() {}, applyAsync }; + return new ValidatedMethod({ + name: 'clientCallAsyncContract', + connection, + validate: null, + applyOptions: { wait: true, throwStubExceptions: false }, + run() {}, + }); + } + + for (const [label, transportResult] of [ + ['undefined', undefined], + ['plain object', {}], + ['non-callable then', { then: true }], + ['resolved promise', Promise.resolve('stub result')], + ]) { + it('uses the callback result when applyAsync returns ' + label, async () => { + const args = { value: 1 }; + const serverResult = {}; + let callback; + let captured; + let receiver; + const method = fixture(function (...received) { + receiver = this; + captured = received; + callback = received[3]; + return transportResult; + }); + const execution = method.callAsync(args); + assert.strictEqual(receiver, method.connection); + assert.equal(captured[0], method.name); + assert.strictEqual(captured[1][0], args); + assert.strictEqual(captured[2], method.applyOptions); + assert.deepEqual(captured[2], { + returnStubValue: true, + throwStubExceptions: true, + wait: true, + isFromCallAsync: true, + }); + assert.isUndefined(DDP._CurrentMethodInvocation.get()); + assert.isTrue(DDP._CurrentMethodInvocation._isCallAsyncMethodRunning()); + callback(null, serverResult); + assert.strictEqual(await execution, serverResult); + assert.isFalse(DDP._CurrentMethodInvocation._isCallAsyncMethodRunning()); + }); + } + + it('preserves callback errors and clears the callAsync flag', async () => { + const error = new Meteor.Error('client-callback-error'); + const method = fixture((name, args, options, callback) => { + callback(error); + }); + await method.callAsync({}).then( + () => assert.fail('Expected rejection'), + caught => assert.strictEqual(caught, error) + ); + assert.isFalse(DDP._CurrentMethodInvocation._isCallAsyncMethodRunning()); + }); + + it('preserves a rejected stub promise before the server callback', async () => { + const error = new Error('client stub'); + let callback; + const method = fixture((name, args, options, received) => { + callback = received; + return Promise.reject(error); + }); + const execution = method.callAsync({}); + try { + await execution.then( + () => assert.fail('Expected rejection'), + caught => assert.strictEqual(caught, error) + ); + } finally { + // Complete the simulated transport even when an assertion fails. + callback(null, 'later server result'); + } + await execution.then( + () => assert.fail('A late callback must not replace the rejection'), + caught => assert.strictEqual(caught, error) + ); + }); + + it('rejects when applyAsync throws synchronously', async () => { + const error = new Error('client transport'); + const method = fixture(() => { throw error; }); + await method.callAsync({}).then( + () => assert.fail('Expected rejection'), + caught => assert.strictEqual(caught, error) + ); + }); + }); +} From 2d76186c6388d77b547ce529a04569249302c52a Mon Sep 17 00:00:00 2001 From: jankapunkt Date: Tue, 20 Oct 2026 11:36:37 +0200 Subject: [PATCH 6/8] ci: add github actions ci --- .github/workflows/testsuite.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/testsuite.yml diff --git a/.github/workflows/testsuite.yml b/.github/workflows/testsuite.yml new file mode 100644 index 0000000..d5f48bb --- /dev/null +++ b/.github/workflows/testsuite.yml @@ -0,0 +1,30 @@ +name: Test suite + +on: [push, pull_request] + +jobs: + tests: + name: tests + runs-on: ubuntu-latest + strategy: + matrix: + meteor: ['1.7', '2.3', '2.16', '3.0.4', '3.5.1' ] + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Setup meteor + uses: meteorengineer/setup-meteor@v2 + with: + meteor-release: ${{ matrix.meteor }} + + - name: cache dependencies + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - run: | + meteor npm ci + meteor npm run test:ci \ No newline at end of file From 8e0b3d4b21688ed86b41b86677fbace22be24106 Mon Sep 17 00:00:00 2001 From: jankapunkt Date: Fri, 30 Oct 2026 16:36:50 +0100 Subject: [PATCH 7/8] build: drop Meteor 1 support --- .github/workflows/testsuite.yml | 2 +- package.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testsuite.yml b/.github/workflows/testsuite.yml index d5f48bb..df6d168 100644 --- a/.github/workflows/testsuite.yml +++ b/.github/workflows/testsuite.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - meteor: ['1.7', '2.3', '2.16', '3.0.4', '3.5.1' ] + meteor: ['2.3', '2.16', '3.0.4', '3.5.4' ] steps: - name: checkout uses: actions/checkout@v4 diff --git a/package.js b/package.js index 469eecd..cdaf961 100644 --- a/package.js +++ b/package.js @@ -6,7 +6,7 @@ Package.describe({ }); Package.onUse(function (api) { - api.versionsFrom(['1.7', '2.3', '3.0']); + api.versionsFrom(['2.3', '3.0']); api.use([ 'ecmascript', From 9a1845d11ec527ee5747cfb3083a25babffc4499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Sat, 31 Oct 2026 10:14:01 +0100 Subject: [PATCH 8/8] fix: run headless with ~100% coverage and 2x/3x compat (#1) * fix: run headless with 100% coverage and 2x/3x compat * fix: make ci compatible with mulziple lock files * fix: error handling for unsupported callAsync * fix: handle missing test case on supported vs unsupported callAsync * fix: add missing guard clause to tests to support 2.3 * fix: add missing 2.3 test --- .github/workflows/testsuite.yml | 6 +- .gitignore | 1 + coverage-support/collect.js | 7 +- coverage-support/run.cjs | 29 +- package-lock.json | 1121 ------------------------------- package.js | 4 +- package.json | 3 +- validated-method-tests.js | 110 ++- validated-method.js | 8 + 9 files changed, 134 insertions(+), 1155 deletions(-) delete mode 100644 package-lock.json diff --git a/.github/workflows/testsuite.yml b/.github/workflows/testsuite.yml index df6d168..ee1d6e2 100644 --- a/.github/workflows/testsuite.yml +++ b/.github/workflows/testsuite.yml @@ -11,7 +11,7 @@ jobs: meteor: ['2.3', '2.16', '3.0.4', '3.5.4' ] steps: - name: checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Setup meteor uses: meteorengineer/setup-meteor@v2 @@ -26,5 +26,5 @@ jobs: restore-keys: | ${{ runner.os }}-node- - run: | - meteor npm ci - meteor npm run test:ci \ No newline at end of file + meteor npm install + meteor npm run test:ci diff --git a/.gitignore b/.gitignore index cd75927..79d8dd5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ coverage-source/ .nyc_output/ coverage/ +.test-app/ diff --git a/coverage-support/collect.js b/coverage-support/collect.js index 7f12bd3..33082d0 100644 --- a/coverage-support/collect.js +++ b/coverage-support/collect.js @@ -27,6 +27,11 @@ if (Meteor.isServer) { } else { after(async function () { this.timeout(10000); - await Meteor.callAsync(methodName, globalThis.__validatedMethodCoverage__); + const coverage = globalThis.__validatedMethodCoverage__; + // Meteor.callAsync only exists since Meteor 2.8 + await (Meteor.callAsync + ? Meteor.callAsync(methodName, coverage) + : new Promise((resolve, reject) => Meteor.call(methodName, coverage, + (error, result) => (error ? reject(error) : resolve(result))))); }); } diff --git a/coverage-support/run.cjs b/coverage-support/run.cjs index 919c6d4..8b196d5 100644 --- a/coverage-support/run.cjs +++ b/coverage-support/run.cjs @@ -1,6 +1,6 @@ -const fs = require('node:fs'); -const path = require('node:path'); -const { spawnSync } = require('node:child_process'); +const fs = require('fs'); +const path = require('path'); +const { spawnSync } = require('child_process'); const { createInstrumenter } = require('istanbul-lib-instrument'); const { createCoverageMap } = require('istanbul-lib-coverage'); const { createContext } = require('istanbul-lib-report'); @@ -24,11 +24,32 @@ const instrumenter = createInstrumenter({ fs.writeFileSync(path.join(generated, 'validated-method.js'), instrumenter.instrumentSync(fs.readFileSync(source, 'utf8'), source)); +// test-packages bundles a separate test app and Npm.require ignores NODE_PATH, +// so the browser driver must be an npm dependency of that app. Meteor runs +// `npm install` there when the app already has a package.json. +// puppeteer 19 is the newest line that still runs on Meteor 2.x (Node 14). +const testApp = path.join(root, '.test-app'); +fs.mkdirSync(testApp, { recursive: true }); +fs.writeFileSync(path.join(testApp, 'package.json'), `${JSON.stringify({ + private: true, + dependencies: { + '@babel/runtime': '^7.23.5', + '@swc/helpers': '^0.5.17', + 'jquery': '^3.7.1', + 'meteor-node-stubs': '^1.2.5', + 'puppeteer': '19.11.1', + }, +}, null, 2)}\n`); + try { const result = spawnSync('meteor', - ['test-packages', '--once', '--driver-package', 'meteortesting:mocha', './'], { + ['test-packages', '--once', '--driver-package', 'meteortesting:mocha', + '--test-app-path', testApp, './'], { cwd: root, stdio: 'inherit', + // a driver that fails after the server suite leaves `--once` running forever + timeout: 10 * 60 * 1000, + killSignal: 'SIGKILL', env: { ...process.env, VALIDATED_METHOD_COVERAGE: raw }, }); if (result.error) throw result.error; diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 2f27cff..0000000 --- a/package-lock.json +++ /dev/null @@ -1,1121 +0,0 @@ -{ - "name": "validated-method", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "devDependencies": { - "chai": "^6.3.0", - "istanbul-lib-coverage": "3.2.2", - "istanbul-lib-instrument": "6.0.3", - "istanbul-lib-report": "3.0.1", - "istanbul-reports": "3.2.0", - "puppeteer": "^25.14.0", - "simpl-schema": "^1.13.1" - } - }, - "node_modules/@babel/code-frame": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", - "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-validator-identifier": "^7.29.7", - "js-tokens": "^4.0.0", - "picocolors": "^1.1.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/compat-data": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", - "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/core": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz", - "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.29.7", - "@babel/generator": "^7.29.7", - "@babel/helper-compilation-targets": "^7.29.7", - "@babel/helper-module-transforms": "^7.29.7", - "@babel/helpers": "^7.29.7", - "@babel/parser": "^7.29.7", - "@babel/template": "^7.29.7", - "@babel/traverse": "^7.29.7", - "@babel/types": "^7.29.7", - "@jridgewell/remapping": "^2.3.5", - "convert-source-map": "^2.0.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.3", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - } - }, - "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/generator": { - "version": "7.29.8", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz", - "integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/parser": "^7.29.8", - "@babel/types": "^7.29.8", - "@jridgewell/gen-mapping": "^0.3.12", - "@jridgewell/trace-mapping": "^0.3.28", - "jsesc": "^3.0.2" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", - "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/compat-data": "^7.29.7", - "@babel/helper-validator-option": "^7.29.7", - "browserslist": "^4.24.0", - "lru-cache": "^5.1.1", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/helper-globals": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", - "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", - "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/traverse": "^7.29.7", - "@babel/types": "^7.29.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", - "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-module-imports": "^7.29.7", - "@babel/helper-validator-identifier": "^7.29.7", - "@babel/traverse": "^7.29.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-string-parser": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", - "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", - "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-option": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", - "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helpers": { - "version": "7.29.10", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.10.tgz", - "integrity": "sha512-EMCx3AGZ3WfAl6ht7AyQoPm2Lh+BGYEMdc4Q6Hf7uSCDOZFuLq44qNwL+iaim8VlyYhRAo4X43+weadK8ZB4Yg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/template": "^7.29.7", - "@babel/types": "^7.29.8" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/parser": { - "version": "7.29.9", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", - "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/types": "^7.29.8" - }, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/template": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", - "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.29.7", - "@babel/parser": "^7.29.7", - "@babel/types": "^7.29.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse": { - "version": "7.29.10", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.10.tgz", - "integrity": "sha512-B3lYAs2nkKskbgQ1nfy8Ma9ao9Q1rntTAQHrzzyDuj+TSO+X3le6PfWwqDvodsb+OumE10eMFfuMCTQSQ5iuIQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.29.7", - "@babel/generator": "^7.29.8", - "@babel/helper-globals": "^7.29.7", - "@babel/parser": "^7.29.9", - "@babel/template": "^7.29.7", - "@babel/types": "^7.29.8", - "debug": "^4.3.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/types": { - "version": "7.29.8", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", - "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-string-parser": "^7.29.7", - "@babel/helper-validator-identifier": "^7.29.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@istanbuljs/schema": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz", - "integrity": "sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.13", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", - "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.0", - "@jridgewell/trace-mapping": "^0.3.24" - } - }, - "node_modules/@jridgewell/remapping": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", - "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", - "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.31", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", - "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, - "node_modules/@puppeteer/browsers": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.2.5.tgz", - "integrity": "sha512-UoCo3Pynbm37aLEEoydSiG+t24ui7sLD40+07CKxzxNy4PpSowJMkvlLIiV67XjP1lMVynhQVnuwlTABqBH8LQ==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "modern-tar": "^0.8.5", - "yargs": "^18.0.0" - }, - "bin": { - "browsers": "lib/main-cli.js" - }, - "engines": { - "node": ">=22.12.0" - }, - "peerDependencies": { - "proxy-agent": ">=8.0.1", - "yauzl": "^2.10.0 || ^3.4.0" - }, - "peerDependenciesMeta": { - "proxy-agent": { - "optional": true - }, - "yauzl": { - "optional": true - } - } - }, - "node_modules/ansi-regex": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", - "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/ansi-styles": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", - "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/baseline-browser-mapping": { - "version": "2.11.30", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.30.tgz", - "integrity": "sha512-YJs6Pz17RMNv8HoyKREtCY38E3BV1nPkWVmIb+XN1uHC1Vqt3KZCH/uJH9ZKRoiKb/icZ6tvehyee6RZNbFfRA==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "baseline-browser-mapping": "dist/cli.cjs" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/browserslist": { - "version": "4.29.4", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.4.tgz", - "integrity": "sha512-2TcbbiwXEq+N0kD36tykpCfyyQigUXmuwNQbnPp4Xk4PX9JOqVIKjJlIDjpH7uY6tmRGoAd+apeT1p60T8wsdA==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "baseline-browser-mapping": "^2.11.29", - "caniuse-lite": "^1.0.30001816", - "electron-to-chromium": "^1.5.459", - "node-releases": "^2.0.59", - "update-browserslist-db": "^1.3.4" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, - "node_modules/caniuse-lite": { - "version": "1.0.30001817", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001817.tgz", - "integrity": "sha512-uZ1JG80BwhtMalIAGPxPfmNhHyd/B/nTdr3hITWlRamSyAdUStP1Gop01e7SD5q6J90ixJvWDbvmiFVfDgn4bw==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "CC-BY-4.0" - }, - "node_modules/chai": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz", - "integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/chromium-bidi": { - "version": "157.0.8090-0", - "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-157.0.8090-0.tgz", - "integrity": "sha512-KJw7IQgqXwxpJgJlEIPg5mr2ZoqA+jkTRtc5EABI7sUJ3bu3cpI7NuEBoj4Gn1AsF78CaT9So5WQWspK3/wYag==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "mitt": "^3.0.1", - "zod": "^4.6.5" - }, - "engines": { - "node": ">=20.19.0 <22.0.0 || >=22.12.0" - }, - "peerDependencies": { - "devtools-protocol": "*" - } - }, - "node_modules/cliui": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", - "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^7.2.0", - "strip-ansi": "^7.1.0", - "wrap-ansi": "^9.0.0" - }, - "engines": { - "node": ">=20" - } - }, - "node_modules/cliui/node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/clone": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.8" - } - }, - "node_modules/convert-source-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true, - "license": "MIT" - }, - "node_modules/debug": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/devtools-protocol": { - "version": "0.0.1696802", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1696802.tgz", - "integrity": "sha512-FO5/SENfvc2K8wRnWQflKcwuoTH4dBkXCWTQ9ebIWtuX8JM5+ZvCotaEmkfh21pO7TvIKGTM3hG4xFiq9WTwmg==", - "dev": true, - "license": "BSD-3-Clause" - }, - "node_modules/electron-to-chromium": { - "version": "1.5.460", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.460.tgz", - "integrity": "sha512-rRaVC7bNUyGsL+GMtmZfv3AfgG6za7gE9v5bT0PIbjEerddA0IQ+tCK05NFAXqCpNlrxBZqbFqquyxHRQONHTA==", - "dev": true, - "license": "ISC" - }, - "node_modules/emoji-regex": { - "version": "10.6.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", - "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", - "dev": true, - "license": "MIT" - }, - "node_modules/escalade": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", - "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "license": "ISC", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-east-asian-width": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", - "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/html-escaper": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", - "dev": true, - "license": "MIT" - }, - "node_modules/istanbul-lib-coverage": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", - "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-instrument": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", - "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@babel/core": "^7.23.9", - "@babel/parser": "^7.23.9", - "@istanbuljs/schema": "^0.1.3", - "istanbul-lib-coverage": "^3.2.0", - "semver": "^7.5.4" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-lib-report": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", - "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^4.0.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-reports": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", - "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "html-escaper": "^2.0.0", - "istanbul-lib-report": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/jsesc": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", - "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", - "dev": true, - "license": "MIT", - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true, - "license": "MIT", - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/lilconfig": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.4.tgz", - "integrity": "sha512-zJZyBmQhArDRefuWTypZxwDpFDIYmrj8ypSBvwGD5P13Y95s6DjzKgu4DVdGbeQa5PDEsAOCAPNk4X+QOR006w==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/antonk52" - } - }, - "node_modules/lodash._reinterpolate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "integrity": "sha512-xYHt68QRoYGjeeM/XOE1uJtvXQAgvszfBhjV4yvsQH0u2i9I6cI6c6/eG4Hh3UAOVn0y/xAXwmTzEay49Q//HA==", - "dev": true, - "license": "MIT" - }, - "node_modules/lodash.template": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.18.1.tgz", - "integrity": "sha512-5urZrLnV/VD6zHK5KsVtZgt7H19v51mIzoS0aBNH8yp3I8tbswrEjOABOPY8m8uB7NuibubLrMX+Y0PXsU9X+w==", - "deprecated": "This package is deprecated. Use https://socket.dev/npm/package/eta instead.", - "dev": true, - "license": "MIT", - "dependencies": { - "lodash._reinterpolate": "^3.0.0", - "lodash.templatesettings": "^4.0.0" - } - }, - "node_modules/lodash.templatesettings": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz", - "integrity": "sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "lodash._reinterpolate": "^3.0.0" - } - }, - "node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^3.0.2" - } - }, - "node_modules/make-dir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", - "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/message-box": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/message-box/-/message-box-0.2.7.tgz", - "integrity": "sha512-C4ccA5nHb58kTS+pLrgF/JWtr7fAIkHxRDceH7tdy5fMA783nUfbYwZ7H2XLvSeYfcnWIYCig5dWW+icK9X/Ag==", - "dev": true, - "license": "MIT", - "dependencies": { - "lodash.template": "^4.5.0" - } - }, - "node_modules/mitt": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", - "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==", - "dev": true, - "license": "MIT" - }, - "node_modules/modern-tar": { - "version": "0.8.6", - "resolved": "https://registry.npmjs.org/modern-tar/-/modern-tar-0.8.6.tgz", - "integrity": "sha512-LYSks0tNVqbtez/9OB0YFP6qLRSqkdAxJWOQpVaR67lNTbj2zNLyYpowkRMia5lXLCZKzxwoxkxH2MbbBR2aEg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/mongo-object": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/mongo-object/-/mongo-object-0.1.4.tgz", - "integrity": "sha512-QtYk0gupWEn2+iB+DDRt1L+WbcNYvJRaHdih/dcqthOa1DbnREUGSs2WGcW478GNYpElflo/yybZXu0sTiRXHg==", - "dev": true, - "license": "MIT" - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, - "license": "MIT" - }, - "node_modules/node-releases": { - "version": "2.0.59", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.59.tgz", - "integrity": "sha512-5qr2okC4ItAI0hG5SaV0HoYMpnM/Y6+Oqr7AmPYy/2uEoGvS+GbSKLeRxSS1uAdu59yz0ouzcuXievSgg///WA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/picocolors": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", - "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "dev": true, - "license": "ISC" - }, - "node_modules/puppeteer": { - "version": "25.14.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-25.14.0.tgz", - "integrity": "sha512-+s1Iqbl9DsGLOaQdgCQyhtgHZsF9hi4Iu8iuBqxzraxUXoRG1QkYQI0CA1/VsNK1gZWJfs50BL/oOb1L+Yz8Yg==", - "dev": true, - "hasInstallScript": true, - "license": "Apache-2.0", - "dependencies": { - "@puppeteer/browsers": "3.2.5", - "chromium-bidi": "157.0.8090-0", - "devtools-protocol": "0.0.1696802", - "lilconfig": "^3.1.3", - "puppeteer-core": "25.14.0", - "typed-query-selector": "^2.12.3" - }, - "bin": { - "puppeteer": "lib/puppeteer/node/cli.js" - }, - "engines": { - "node": ">=22.12.0" - } - }, - "node_modules/puppeteer-core": { - "version": "25.14.0", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-25.14.0.tgz", - "integrity": "sha512-LQitnes3tBeVbdZ7V/4iwJPLZGgkl9uBVK0W7YYMh68j/3Y9eNuvj4yl+Fdo7zN0SuajOMrhd7aPj3DifK8k6A==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@puppeteer/browsers": "3.2.5", - "chromium-bidi": "157.0.8090-0", - "devtools-protocol": "0.0.1696802", - "typed-query-selector": "^2.12.3", - "webdriver-bidi-protocol": "1.0.1", - "ws": "^8.22.0" - }, - "engines": { - "node": ">=22.12.0" - } - }, - "node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/simpl-schema": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/simpl-schema/-/simpl-schema-1.13.1.tgz", - "integrity": "sha512-20Qc2X13TvLJYY37eapvJ5CWyYYSScX2BJV5RcP4A15efA4k8c0XEsp9F/RofQi/IMrp7PzyxTXyjwlG7EFhCQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "clone": "^2.1.2", - "message-box": "^0.2.7", - "mongo-object": "^0.1.4" - } - }, - "node_modules/string-width": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz", - "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "get-east-asian-width": "^1.5.0", - "strip-ansi": "^7.1.2" - }, - "engines": { - "node": ">=20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/strip-ansi": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", - "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.2.2" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/typed-query-selector": { - "version": "2.12.3", - "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.3.tgz", - "integrity": "sha512-/dtuMZyutHLlrxWhhC1uib00ELUr2dZ8C9B8YzZYsJmeE3V56OxRblrSM2UaF142pcMtak7ehZ6+poWGeehNIg==", - "dev": true, - "license": "MIT" - }, - "node_modules/update-browserslist-db": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.4.tgz", - "integrity": "sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "escalade": "^3.2.0", - "picocolors": "^1.1.1" - }, - "bin": { - "update-browserslist-db": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" - } - }, - "node_modules/webdriver-bidi-protocol": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/webdriver-bidi-protocol/-/webdriver-bidi-protocol-1.0.1.tgz", - "integrity": "sha512-WXWs/aXF2a6Al1Z2/V/7Gp2oPZOAAmHjJOTmv4KCXRJ122IMj3tSSMc6a4q3K4QOmhQbse/Ahr+oTVJOU2dUiw==", - "dev": true, - "license": "Apache-2.0" - }, - "node_modules/wrap-ansi": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", - "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^6.2.1", - "string-width": "^7.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ws": { - "version": "8.22.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", - "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" - } - }, - "node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true, - "license": "ISC" - }, - "node_modules/yargs": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz", - "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==", - "dev": true, - "license": "MIT", - "dependencies": { - "cliui": "^9.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "string-width": "^8.2.1", - "y18n": "^5.0.5", - "yargs-parser": "^22.0.0" - }, - "engines": { - "node": "^20.19.0 || ^22.12.0 || >=23" - } - }, - "node_modules/yargs-parser": { - "version": "22.0.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", - "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", - "dev": true, - "license": "ISC", - "engines": { - "node": "^20.19.0 || ^22.12.0 || >=23" - } - }, - "node_modules/zod": { - "version": "4.6.7", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", - "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - } - } -} diff --git a/package.js b/package.js index cdaf961..169ab27 100644 --- a/package.js +++ b/package.js @@ -23,8 +23,8 @@ Package.onUse(function (api) { Package.onTest(function (api) { api.use([ 'ecmascript', - 'meteortesting:mocha@3.0.0', - 'aldeed:simple-schema@3.0.0', // modern support + 'meteortesting:mocha@2.0.0 || 3.0.0', + 'aldeed:simple-schema@2.0.0 || 3.0.0', // modern support 'mdg:validated-method', 'random' ]); diff --git a/package.json b/package.json index e7f2c7a..e84c730 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,11 @@ "test:ci": "TEST_BROWSER_DRIVER=puppeteer npm run test:coverage" }, "devDependencies": { - "chai": "^6.3.0", + "chai": "^4.5.0", "istanbul-lib-coverage": "3.2.2", "istanbul-lib-instrument": "6.0.3", "istanbul-lib-report": "3.0.1", "istanbul-reports": "3.2.0", - "puppeteer": "^25.14.0", "simpl-schema": "^1.13.1" } } diff --git a/validated-method-tests.js b/validated-method-tests.js index b277199..4fbe9a6 100644 --- a/validated-method-tests.js +++ b/validated-method-tests.js @@ -4,6 +4,11 @@ import SimpleSchema from 'simpl-schema'; import AsyncSimpleSchema from 'meteor/aldeed:simple-schema'; import { assert } from 'chai'; +// 2.x releases < 2.8 do not support async methods +const supportsAsyncMethods = + typeof Meteor.callAsync === 'function' && + typeof Meteor.applyAsync === 'function'; + const plainMethod = new ValidatedMethod({ name: 'plainMethod', validate: new SimpleSchema({}).validator(), @@ -90,6 +95,23 @@ const asyncMethod = new ValidatedMethod({ } }); +// setTimeout cannot be used in async method stubs so +// we create one that uses no timeout +const asyncMethodNoTimeout = new ValidatedMethod({ + name: 'asyncMethodNoTimeout', + validate: new SimpleSchema({ + param: { type: Number }, + }).validator(), + async run({ param }) { + return new Promise(resolve => { + resolve(['result', 'result2', param]); + }) + .then(result => { + return result.join(','); + }); + } +}); + const assertThrows = async ({ fn, message }) => { try { await fn(); @@ -129,9 +151,26 @@ describe('mdg:method', () => { }); }); - it('allows methods to be called asynchronously', async () => { - const result = await asyncMethod.callAsync({ param: 3000 }); - assert.equal(result, 'result,result2,3000'); + if (supportsAsyncMethods) { + it('allows methods to be called asynchronously', async () => { + const result = await asyncMethodNoTimeout.callAsync({ param: 3000 }); + assert.equal(result, 'result,result2,3000'); + }); + } + + it('rejects callAsync when the Meteor release has no async methods', () => { + // 2.x < 2.8 lacks these already; on newer releases remove them temporarily + const { callAsync, applyAsync } = Meteor; + Meteor.callAsync = undefined; + Meteor.applyAsync = undefined; + try { + assert.throws(() => { + asyncMethodNoTimeout.callAsync({ param: 1 }); + }, 'Async methods are not supported in this version of Meteor'); + } finally { + Meteor.callAsync = callAsync; + Meteor.applyAsync = applyAsync; + } }); @@ -167,8 +206,9 @@ describe('mdg:method', () => { it('propagates errors if no callback is passed', async () => { if (Meteor.isServer) { - // Meteor 3 server calls reject their returned promise. - await methodThrowsImmediately.call({}).then( + // Meteor 3 server calls reject their returned promise, while + // Fibers-based 2.x server calls throw synchronously. + await (async () => methodThrowsImmediately.call({}))().then( () => assert.fail('Expected the method call to reject'), error => { assert.instanceOf(error, Meteor.Error); @@ -462,7 +502,7 @@ if (Meteor.isServer) { }); } - for (const rejects of [false, true]) { + for (const rejects of supportsAsyncMethods ? [false, true] : []) { it('forwards server callAsync and preserves its ' + (rejects ? 'rejected' : 'resolved') + ' promise', async () => { const f = fixture({ applyOptions: { wait: true } }); const args = { value: 1 }; @@ -485,21 +525,41 @@ if (Meteor.isServer) { }); } + if (!supportsAsyncMethods) { + it('throws synchronously from server callAsync without forwarding when async methods are unsupported', () => { + const f = fixture(); + let forwarded = false; + f.connection.applyAsync = function () { + forwarded = true; + return Promise.resolve(); + }; + const method = new ValidatedMethod(f.options); + let returned; + assert.throws(() => { + returned = method.callAsync({ value: 1 }); + }, Error, 'Async methods are not supported in this version of Meteor'); + assert.isUndefined(returned); + assert.isFalse(forwarded); + }); + } + const rejectingMethod = new ValidatedMethod({ name: 'validatedMethod.serverContracts.asyncRejection', validate: null, async run() { throw new Meteor.Error('server-contract-rejection'); }, }); - it('propagates a real server async run rejection', async () => { - await rejectingMethod.callAsync({}).then( - () => assert.fail('Expected rejection'), - error => { - assert.instanceOf(error, Meteor.Error); - assert.equal(error.error, 'server-contract-rejection'); - } - ); - }); + if (supportsAsyncMethods) { + it('propagates a real server async run rejection', async () => { + await rejectingMethod.callAsync({}).then( + () => assert.fail('Expected rejection'), + error => { + assert.instanceOf(error, Meteor.Error); + assert.equal(error.error, 'server-contract-rejection'); + } + ); + }); + } }); } @@ -602,13 +662,15 @@ describe('mdg:method with AsyncSimpleSchema', () => { assert.equal(result, 'result'); }); - it('allows callAsync with a synchronous run function', async () => { - assert.equal(await plainMethod.callAsync({}), 'result'); - }); + if (supportsAsyncMethods) { + it('allows callAsync with a synchronous run function', async () => { + assert.equal(await plainMethod.callAsync({}), 'result'); + }); - it('allows callAsync with an asynchronous run function', async () => { - assert.equal(await asyncMethod.callAsync({ param: 3000 }), 'result,result2,3000'); - }); + it('allows callAsync with an asynchronous run function', async () => { + assert.equal(await asyncMethod.callAsync({ param: 3000 }), 'result,result2,3000'); + }); + } for (const method of [methodWithArgs, methodWithSchemaMixin]) { for (const [label, invoke] of [ @@ -616,6 +678,8 @@ describe('mdg:method with AsyncSimpleSchema', () => { ['callAsync', args => method.callAsync(args)], ['_execute', args => method._execute({}, args)], ]) { + if (label === 'callAsync' && !supportsAsyncMethods) continue; + it('accepts valid arguments through ' + label + ': ' + method.name, async () => { assert.equal(await invoke({ int: 5, string: 'what' }), 'result'); }); @@ -634,6 +698,8 @@ describe('mdg:method with AsyncSimpleSchema', () => { ['callAsync', () => methodThrowsImmediately.callAsync({})], ['_execute', () => methodThrowsImmediately._execute({}, {})], ]) { + if (label === 'callAsync' && !supportsAsyncMethods) continue; + it('propagates run errors after validation through ' + label, async () => { await expectRejection(invoke, error => { assert.instanceOf(error, Meteor.Error); @@ -824,7 +890,7 @@ describe('ValidatedMethod async validation contracts', () => { }); }); -if (Meteor.isClient) { +if (Meteor.isClient && supportsAsyncMethods) { describe('ValidatedMethod client callAsync contracts', () => { let previousInvocation; let previousRunning; diff --git a/validated-method.js b/validated-method.js index b9d4a74..6185b55 100644 --- a/validated-method.js +++ b/validated-method.js @@ -1,5 +1,10 @@ import { check, Match } from 'meteor/check'; +// checked per call, so environments without async methods can be simulated in tests +const supportsAsyncMethods = () => + typeof Meteor.callAsync === 'function' && + typeof Meteor.applyAsync === 'function'; + export class ValidatedMethod { constructor(options) { // Default to no mixins @@ -86,6 +91,9 @@ export class ValidatedMethod { } callAsync(args) { + if (!supportsAsyncMethods()) { + throw new Error('Async methods are not supported in this version of Meteor'); + } //taken from the callAsync method internals which will use applyAsync with a isFromCallAsync param //which will flag methods as running on DDP //reset current method invocation and mark it as running