diff --git a/package.json b/package.json index 303231cbf..a6ae37c86 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ }, "scripts": { "clean": "rm -rf dist & rm -rf test/node/dist & rm -rf test/browser/bundle.js & rm -rf helpers", - "test": "npm run build && npm run test:node:build && npm run test:node:run && npm run test:typings && npm run test:esmimports", + "test": "npm run build && npm run test:node:build && npm run test:node:run && npm run test:typings && npm run test:esmimports && npm run test:exports", "test:node:build": "tsc -p test/node", "test:node": "npm run build && npm run test:node:build && npm run test:node:run", "test:node:run": "mocha --timeout 15000 test/node/dist/**/*.test.js", @@ -52,6 +52,7 @@ "test:typings": "tsd test/typings", "test:esmimports": "node scripts/check-esm-imports.js", "test:esbuild": "esbuild --bundle --platform=node --external:pg-native dist/esm/index.js --outfile=/dev/null", + "test:exports": "node scripts/check-exports.js", "prettier": "prettier --write 'src/**/*.ts' 'test/**/*.ts'", "build": "npm run clean && (npm run build:esm & npm run build:cjs) && npm run script:module-fixup && npm run script:copy-interface-doc", "build:esm": "tsc -p tsconfig.json && npm run script:add-deno-type-references", diff --git a/scripts/check-exports.js b/scripts/check-exports.js new file mode 100644 index 000000000..238e3f332 --- /dev/null +++ b/scripts/check-exports.js @@ -0,0 +1,40 @@ +/** + * This script ensures all files in a path are exported in the index.ts file. + * For now it only checks the operation-node folder, as we've had issues with + * missing exports there. + */ + +const fs = require('node:fs') +const path = require('node:path') +const forEachFile = require('./util/for-each-file') + +let errorsFound = false + +function checkExports(dir) { + const indexFileContents = fs.readFileSync( + path.join(__dirname, '..', 'src/index.ts'), + 'utf-8', + ) + + forEachFile(dir, (filePath) => { + if (filePath.endsWith('.ts')) { + const expectedExportPath = filePath.replace( + /^.+\/src\/(.+)\.ts$/, + "'./$1.js'", + ) + + if (!indexFileContents.includes(expectedExportPath)) { + console.log(`Missing export: ${expectedExportPath}`) + errorsFound = true + } + } + }) +} + +checkExports(path.join(__dirname, '..', 'src/operation-node')) + +if (errorsFound) { + console.log(' ') + console.log('check-exports.js failed!') + process.exit(1) +} diff --git a/src/index.ts b/src/index.ts index b27a601d2..9818f1131 100644 --- a/src/index.ts +++ b/src/index.ts @@ -112,17 +112,21 @@ export * from './plugin/parse-json-results/parse-json-results-plugin.js' export * from './operation-node/add-column-node.js' export * from './operation-node/add-constraint-node.js' +export * from './operation-node/add-index-node.js' +export * from './operation-node/aggregate-function-node.js' export * from './operation-node/alias-node.js' export * from './operation-node/alter-column-node.js' export * from './operation-node/alter-table-node.js' export * from './operation-node/and-node.js' +export * from './operation-node/binary-operation-node.js' export * from './operation-node/case-node.js' +export * from './operation-node/cast-node.js' export * from './operation-node/check-constraint-node.js' export * from './operation-node/column-definition-node.js' export * from './operation-node/column-node.js' export * from './operation-node/column-update-node.js' -export * from './operation-node/common-table-expression-node.js' export * from './operation-node/common-table-expression-name-node.js' +export * from './operation-node/common-table-expression-node.js' export * from './operation-node/constraint-node.js' export * from './operation-node/create-index-node.js' export * from './operation-node/create-schema-node.js' @@ -130,6 +134,7 @@ export * from './operation-node/create-table-node.js' export * from './operation-node/create-type-node.js' export * from './operation-node/create-view-node.js' export * from './operation-node/data-type-node.js' +export * from './operation-node/default-insert-value-node.js' export * from './operation-node/default-value-node.js' export * from './operation-node/delete-query-node.js' export * from './operation-node/drop-column-node.js' @@ -139,8 +144,11 @@ export * from './operation-node/drop-schema-node.js' export * from './operation-node/drop-table-node.js' export * from './operation-node/drop-type-node.js' export * from './operation-node/drop-view-node.js' +export * from './operation-node/explain-node.js' +export * from './operation-node/fetch-node.js' export * from './operation-node/foreign-key-constraint-node.js' export * from './operation-node/from-node.js' +export * from './operation-node/function-node.js' export * from './operation-node/generated-node.js' export * from './operation-node/group-by-item-node.js' export * from './operation-node/group-by-node.js' @@ -148,8 +156,14 @@ export * from './operation-node/having-node.js' export * from './operation-node/identifier-node.js' export * from './operation-node/insert-query-node.js' export * from './operation-node/join-node.js' +export * from './operation-node/json-operator-chain-node.js' +export * from './operation-node/json-path-leg-node.js' +export * from './operation-node/json-path-node.js' +export * from './operation-node/json-reference-node.js' export * from './operation-node/limit-node.js' export * from './operation-node/list-node.js' +export * from './operation-node/matched-node.js' +export * from './operation-node/merge-query-node.js' export * from './operation-node/modify-column-node.js' export * from './operation-node/offset-node.js' export * from './operation-node/on-conflict-node.js' @@ -163,7 +177,11 @@ export * from './operation-node/operator-node.js' export * from './operation-node/or-node.js' export * from './operation-node/order-by-item-node.js' export * from './operation-node/order-by-node.js' +export * from './operation-node/output-node.js' +export * from './operation-node/over-node.js' export * from './operation-node/parens-node.js' +export * from './operation-node/partition-by-item-node.js' +export * from './operation-node/partition-by-node.js' export * from './operation-node/primary-constraint-node.js' export * from './operation-node/primitive-value-list-node.js' export * from './operation-node/query-node.js' @@ -172,39 +190,26 @@ export * from './operation-node/reference-node.js' export * from './operation-node/references-node.js' export * from './operation-node/rename-column-node.js' export * from './operation-node/returning-node.js' +export * from './operation-node/schemable-identifier-node.js' export * from './operation-node/select-all-node.js' -export * from './operation-node/select-query-node.js' +export * from './operation-node/select-modifier-node.js' export * from './operation-node/select-query-node.js' export * from './operation-node/selection-node.js' +export * from './operation-node/set-operation-node.js' +export * from './operation-node/simple-reference-expression-node.js' export * from './operation-node/table-node.js' +export * from './operation-node/top-node.js' +export * from './operation-node/tuple-node.js' +export * from './operation-node/unary-operation-node.js' export * from './operation-node/unique-constraint-node.js' export * from './operation-node/update-query-node.js' +export * from './operation-node/using-node.js' export * from './operation-node/value-list-node.js' export * from './operation-node/value-node.js' export * from './operation-node/values-node.js' export * from './operation-node/when-node.js' export * from './operation-node/where-node.js' export * from './operation-node/with-node.js' -export * from './operation-node/explain-node.js' -export * from './operation-node/default-insert-value-node.js' -export * from './operation-node/aggregate-function-node.js' -export * from './operation-node/over-node.js' -export * from './operation-node/partition-by-node.js' -export * from './operation-node/partition-by-item-node.js' -export * from './operation-node/set-operation-node.js' -export * from './operation-node/binary-operation-node.js' -export * from './operation-node/unary-operation-node.js' -export * from './operation-node/using-node.js' -export * from './operation-node/json-reference-node.js' -export * from './operation-node/json-path-leg-node.js' -export * from './operation-node/json-path-node.js' -export * from './operation-node/json-operator-chain-node.js' -export * from './operation-node/tuple-node.js' -export * from './operation-node/merge-query-node.js' -export * from './operation-node/matched-node.js' -export * from './operation-node/fetch-node.js' -export * from './operation-node/top-node.js' -export * from './operation-node/output-node.js' export * from './util/column-type.js' export * from './util/compilable.js'