diff --git a/eslint.config.js b/eslint.config.js index a49b322..48f99ca 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -48,6 +48,18 @@ export default tseslint.config( 'unicorn/no-null': 'off', 'unicorn/prevent-abbreviations': 'off', 'unicorn/consistent-function-scoping': 'off', + 'unicorn/consistent-boolean-name': 'off', + 'unicorn/prefer-private-class-fields': 'off', + 'unicorn/max-nested-calls': 'off', + 'unicorn/prefer-await': 'off', + 'unicorn/no-break-in-nested-loop': 'off', + 'unicorn/no-computed-property-existence-check': 'off', + 'unicorn/prefer-number-coercion': 'off', + 'unicorn/name-replacements': 'off', + 'unicorn/require-array-sort-compare': 'off', + 'unicorn/prefer-array-from-map': 'off', + 'unicorn/prefer-math-constants': 'off', + 'unicorn/prefer-number-is-safe-integer': 'off', 'n/no-missing-import': 'off', 'n/no-unsupported-features/node-builtins': 'off', 'import-x/no-named-as-default': 'off', diff --git a/package.json b/package.json index 0185276..92dd240 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "eslint-plugin-n": "^18.0.0", "eslint-plugin-prettier": "^5.0.0", "eslint-plugin-promise": "^7.0.0", - "eslint-plugin-unicorn": "^64.0.0", + "eslint-plugin-unicorn": "^68.0.0", "eslint-plugin-unused-imports": "^4.0.0", "typescript-eslint": "^8.0.0", "prettier": "^3.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0fac5ce..339d00b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -121,8 +121,8 @@ importers: specifier: ^7.0.0 version: 7.3.0(eslint@10.5.0) eslint-plugin-unicorn: - specifier: ^64.0.0 - version: 64.0.0(eslint@10.5.0) + specifier: ^68.0.0 + version: 68.0.0(eslint@10.5.0) eslint-plugin-unused-imports: specifier: ^4.0.0 version: 4.4.1(@typescript-eslint/eslint-plugin@8.62.0(@typescript-eslint/parser@8.62.0(eslint@10.5.0)(typescript@6.0.3))(eslint@10.5.0)(typescript@6.0.3))(eslint@10.5.0) @@ -152,8 +152,8 @@ packages: resolution: {integrity: sha512-0ktzq4/9ya2QoAuVWzl3McpLV9W//Tj+oMonQ4ucgm5l6tQ46aaju/rJL9kzeY5MkG6wzXvFt/MmaLqf9uNC9w==} engines: {node: ^22.20 || ^24.12 || >=25} - '@babel/helper-validator-identifier@7.28.5': - resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==} + '@babel/helper-validator-identifier@7.29.7': + resolution: {integrity: sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==} engines: {node: '>=6.9.0'} '@cloudquery/plugin-pb-javascript@0.0.40': @@ -740,6 +740,11 @@ packages: engines: {node: '>=6.0.0'} hasBin: true + baseline-browser-mapping@2.10.38: + resolution: {integrity: sha512-31/02mVB4yuQU6adKk5SlY6m+mxDwUq5KZkyYgnLrrKl7TEm1+3PyDtDBz2kOv/wxZz41GHsvV1A/u6RmiyBvw==} + engines: {node: '>=6.0.0'} + hasBin: true + bindings@1.5.0: resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} @@ -766,6 +771,11 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true + browserslist@4.28.4: + resolution: {integrity: sha512-MTc8i/x9jBQd1iMw2CFGS+rwMa07eYjLR0CCTLDACl9xhxy+nIs3KeML/biicXtk9JrZ6dnnTatmc7ErPXIxqw==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + builtin-modules@5.0.0: resolution: {integrity: sha512-bkXY9WsVpY7CvMhKSR6pZilZu9Ln5WDrKVBUXf2S443etkmEO4V58heTecXcUIsNsi4Rx8JUO4NfX1IcQl4deg==} engines: {node: '>=18.20'} @@ -789,6 +799,9 @@ packages: caniuse-lite@1.0.30001781: resolution: {integrity: sha512-RdwNCyMsNBftLjW6w01z8bKEvT6e/5tpPVEgtn22TiLGlstHOVecsX2KHFkD5e/vRnIE4EGzpuIODb3mtswtkw==} + caniuse-lite@1.0.30001799: + resolution: {integrity: sha512-hG1bReV+OUU+MOqK4t/ZWI0tZOyz3rqS9XuhOUz1cIcbwBKjOyJEJuw9ER5JuNyqxNk8u/JUVbGibBOL1yrjFw==} + cbor2@2.3.0: resolution: {integrity: sha512-76WB3hq8BoaGkMkBVJ27fW5LJU+qqDLEpgRNCG/SYKhODWXpVPOTD4UcUto3IEzYLA52nsvbhb0wabhHDn3qXg==} engines: {node: '>=20'} @@ -822,10 +835,6 @@ packages: ci-parallel-vars@1.0.1: resolution: {integrity: sha512-uvzpYrpmidaoxvIQHM+rKSrigjOe9feHYbw4uOI2gdfe1C3xIlxO+kVXq83WQWNniTf8bAxVpy+cQeFQsMERKg==} - clean-regexp@1.0.0: - resolution: {integrity: sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==} - engines: {node: '>=4'} - cli-truncate@6.0.0: resolution: {integrity: sha512-3+YKIUFsohD9MIoOFPFBldjAlnfCmCDcqe6aYGFqlDTRKg80p4wg35L+j83QQ63iOlKRccEkbn8IuM++HsgEjA==} engines: {node: '>=22'} @@ -962,6 +971,10 @@ packages: resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} engines: {node: '>= 0.4'} + detect-indent@7.0.2: + resolution: {integrity: sha512-y+8xyqdGLL+6sh0tVeHcfP/QDd8gUgbasolJJpY7NgeQGSZ739bDtSiaiDgtoicy+mtYB81dKLxO9xRhCyIB3A==} + engines: {node: '>=12.20'} + detect-libc@2.1.2: resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} engines: {node: '>=8'} @@ -985,6 +998,9 @@ packages: electron-to-chromium@1.5.322: resolution: {integrity: sha512-vFU34OcrvMcH66T+dYC3G4nURmgfDVewMIu6Q2urXpumAPSMmzvcn04KVVV8Opikq8Vs5nUbO/8laNhNRqSzYw==} + electron-to-chromium@1.5.378: + resolution: {integrity: sha512-VinvOAuuPmdD1guEgGv5f2Qp7/vlfqOrUOMYNnOD4wj3pit8kRsQHzfIf6teyUGWo15Tg5+bOJaRunvyltpVWQ==} + emittery@2.0.0: resolution: {integrity: sha512-FLtgn/CGBXiX3ZtPAm5q4LWWepHChOt55J9u01WFu3dyap2U7IwptlrqoE1COR/kxwdy/DOxIBALSxIW449I1g==} engines: {node: '>=22'} @@ -1050,10 +1066,6 @@ packages: resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} - escape-string-regexp@1.0.5: - resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} - engines: {node: '>=0.8.0'} - escape-string-regexp@2.0.0: resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==} engines: {node: '>=8'} @@ -1192,11 +1204,11 @@ packages: peerDependencies: eslint: ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 - eslint-plugin-unicorn@64.0.0: - resolution: {integrity: sha512-rNZwalHh8i0UfPlhNwg5BTUO1CMdKNmjqe+TgzOTZnpKoi8VBgsW7u9qCHIdpxEzZ1uwrJrPF0uRb7l//K38gA==} - engines: {node: ^20.10.0 || >=21.0.0} + eslint-plugin-unicorn@68.0.0: + resolution: {integrity: sha512-mHYWvX948Q4H3bGc39bsNMxD/leOuNI+Iws9NVsoSz5VA7EGP86wnz7mZ/SPSvRhefT8L4hd8DHfDuGC+lIoCQ==} + engines: {node: '>=22'} peerDependencies: - eslint: '>=9.38.0' + eslint: '>=10.4' eslint-plugin-unused-imports@4.4.1: resolution: {integrity: sha512-oZGYUz1X3sRMGUB+0cZyK2VcvRX5lm/vB56PgNNcU+7ficUCKm66oZWKUubXWnOuPjQ8PvmXtCViXBMONPe7tQ==} @@ -1411,8 +1423,8 @@ packages: resolution: {integrity: sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==} engines: {node: '>=18'} - globals@17.5.0: - resolution: {integrity: sha512-qoV+HK2yFl/366t2/Cb3+xxPUo5BuMynomoDmiaZBIdbs+0pYbjfZU+twLhGKp4uCZ/+NbtpVepH5bGCxRyy2g==} + globals@17.7.0: + resolution: {integrity: sha512-Czmyns5dUsq4seFBR/Kdydhmo8y9kC79hiSkPn0YcGtNnYWnrgt0vjrSjx9tspoDGWm2CMarffRuLjM4xUz8xg==} engines: {node: '>=18'} globalthis@1.0.4: @@ -1827,6 +1839,10 @@ packages: node-releases@2.0.36: resolution: {integrity: sha512-TdC8FSgHz8Mwtw9g5L4gR/Sh9XhSP/0DEkQxfEFXOpiul5IiHgHan2VhYYb6agDSfp4KuvltmGApc8HMgUrIkA==} + node-releases@2.0.49: + resolution: {integrity: sha512-f06bl1D+8ZDkn2oOQQKAh5/otFWqVnM1Q5oerA8Pex7UfT66Tx4IPHIqVVFKqFT3FUtaDstdgkM7yT7JWhqxfw==} + engines: {node: '>=18'} + nopt@8.1.0: resolution: {integrity: sha512-ieGu42u/Qsa4TFktmaKEwM6MQH0pOWnaB3htzh0JRtx84+Mebc0cbZYN5bC+6WTZ4+77xrL9Pn5m7CV6VIkV7A==} engines: {node: ^18.17.0 || >=20.5.0} @@ -1993,16 +2009,12 @@ packages: resolution: {integrity: sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==} engines: {node: '>= 0.4'} - regexp-tree@0.1.27: - resolution: {integrity: sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==} - hasBin: true - regexp.prototype.flags@1.5.4: resolution: {integrity: sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==} engines: {node: '>= 0.4'} - regjsparser@0.13.0: - resolution: {integrity: sha512-NZQZdC5wOE/H3UT28fVGL+ikOZcEzfMGk/c3iN9UGxzWHMa1op7274oyiUVrAG4B2EuFhus8SvkaYnhvW92p9Q==} + regjsparser@0.13.2: + resolution: {integrity: sha512-NgRBy2Nx/bE+9F27nVHnqcN5HjyLmecqsqx2PJHu3/IEtADD4WuxuXIVExD5PoSDFVrl78dOonfcOe5O+5nbzQ==} hasBin: true require-directory@2.1.1: @@ -2516,7 +2528,7 @@ snapshots: escape-string-regexp: 5.0.0 execa: 9.6.1 - '@babel/helper-validator-identifier@7.28.5': {} + '@babel/helper-validator-identifier@7.29.7': {} '@cloudquery/plugin-pb-javascript@0.0.40': dependencies: @@ -3130,6 +3142,8 @@ snapshots: baseline-browser-mapping@2.10.10: {} + baseline-browser-mapping@2.10.38: {} + bindings@1.5.0: dependencies: file-uri-to-path: 1.0.0 @@ -3160,6 +3174,14 @@ snapshots: node-releases: 2.0.36 update-browserslist-db: 1.2.3(browserslist@4.28.1) + browserslist@4.28.4: + dependencies: + baseline-browser-mapping: 2.10.38 + caniuse-lite: 1.0.30001799 + electron-to-chromium: 1.5.378 + node-releases: 2.0.49 + update-browserslist-db: 1.2.3(browserslist@4.28.4) + builtin-modules@5.0.0: {} call-bind-apply-helpers@1.0.2: @@ -3186,6 +3208,8 @@ snapshots: caniuse-lite@1.0.30001781: {} + caniuse-lite@1.0.30001799: {} + cbor2@2.3.0: dependencies: '@cto.af/wtf8': 0.0.5 @@ -3211,10 +3235,6 @@ snapshots: ci-parallel-vars@1.0.1: {} - clean-regexp@1.0.0: - dependencies: - escape-string-regexp: 1.0.5 - cli-truncate@6.0.0: dependencies: slice-ansi: 9.0.0 @@ -3363,6 +3383,8 @@ snapshots: object-keys: 1.1.1 optional: true + detect-indent@7.0.2: {} + detect-libc@2.1.2: {} diff@4.0.4: {} @@ -3385,6 +3407,8 @@ snapshots: electron-to-chromium@1.5.322: {} + electron-to-chromium@1.5.378: {} + emittery@2.0.0: {} emoji-regex@10.6.0: {} @@ -3513,8 +3537,6 @@ snapshots: escalade@3.2.0: {} - escape-string-regexp@1.0.5: {} - escape-string-regexp@2.0.0: {} escape-string-regexp@4.0.0: {} @@ -3668,23 +3690,23 @@ snapshots: '@eslint-community/eslint-utils': 4.9.1(eslint@10.5.0) eslint: 10.5.0 - eslint-plugin-unicorn@64.0.0(eslint@10.5.0): + eslint-plugin-unicorn@68.0.0(eslint@10.5.0): dependencies: - '@babel/helper-validator-identifier': 7.28.5 + '@babel/helper-validator-identifier': 7.29.7 '@eslint-community/eslint-utils': 4.9.1(eslint@10.5.0) + browserslist: 4.28.4 change-case: 5.4.4 ci-info: 4.4.0 - clean-regexp: 1.0.0 core-js-compat: 3.49.0 + detect-indent: 7.0.2 eslint: 10.5.0 find-up-simple: 1.0.1 - globals: 17.5.0 + globals: 17.7.0 indent-string: 5.0.0 is-builtin-module: 5.0.0 jsesc: 3.1.0 pluralize: 8.0.0 - regexp-tree: 0.1.27 - regjsparser: 0.13.0 + regjsparser: 0.13.2 semver: 7.8.5 strip-indent: 4.1.1 @@ -3928,7 +3950,7 @@ snapshots: globals@15.15.0: {} - globals@17.5.0: {} + globals@17.7.0: {} globalthis@1.0.4: dependencies: @@ -4328,6 +4350,8 @@ snapshots: node-releases@2.0.36: {} + node-releases@2.0.49: {} + nopt@8.1.0: dependencies: abbrev: 3.0.1 @@ -4511,8 +4535,6 @@ snapshots: which-builtin-type: 1.2.1 optional: true - regexp-tree@0.1.27: {} - regexp.prototype.flags@1.5.4: dependencies: call-bind: 1.0.9 @@ -4523,7 +4545,7 @@ snapshots: set-function-name: 2.0.2 optional: true - regjsparser@0.13.0: + regjsparser@0.13.2: dependencies: jsesc: 3.1.0 @@ -4980,6 +5002,12 @@ snapshots: escalade: 3.2.0 picocolors: 1.1.1 + update-browserslist-db@1.2.3(browserslist@4.28.4): + dependencies: + browserslist: 4.28.4 + escalade: 3.2.0 + picocolors: 1.1.1 + uri-js@4.4.1: dependencies: punycode: 2.3.1 diff --git a/src/memdb/memdb.ts b/src/memdb/memdb.ts index 4178fd4..791fdc8 100644 --- a/src/memdb/memdb.ts +++ b/src/memdb/memdb.ts @@ -85,8 +85,8 @@ export const newMemDBPlugin = (): Plugin => { return Promise.resolve(pluginClient); } const parsedSpec = JSON.parse(spec) as Partial; - const validSchema = validate(parsedSpec); - if (!validSchema) { + const isValidSchema = validate(parsedSpec); + if (!isValidSchema) { const messages = validate.errors?.map((error) => error.message).join(', '); return Promise.reject(new ValidationError(`Invalid spec: ${messages}`, { props: { spec } })); } diff --git a/src/package/docker.ts b/src/package/docker.ts index f32f2b9..627517c 100644 --- a/src/package/docker.ts +++ b/src/package/docker.ts @@ -141,8 +141,8 @@ const buildDockerfile = async ( const supportedTargets = await pMap( plugin.buildTargets(), async ({ os, arch }) => { - const imageRepository = `docker.cloudquery.io/${plugin.team()}/${plugin.kind()}-${plugin.name()}`; - const imageTag = `${imageRepository}:${pluginVersion}-${os}-${arch}`; + const imageRepo = `docker.cloudquery.io/${plugin.team()}/${plugin.kind()}-${plugin.name()}`; + const imageTag = `${imageRepo}:${pluginVersion}-${os}-${arch}`; const imageTar = `plugin-${plugin.name()}-${pluginVersion}-${os}-${arch}.tar`; const imagePath = `${outputDirectory}/${imageTar}`; logger.info(`Building docker image ${imageTag}`); diff --git a/src/plugin/serve.ts b/src/plugin/serve.ts index 744a918..438bf9d 100644 --- a/src/plugin/serve.ts +++ b/src/plugin/serve.ts @@ -122,8 +122,8 @@ export const createServeCommand = (plugin: Plugin) => { if (!semverValid(pluginVersion)) { throw new Error(`invalid plugin version: ${pluginVersion}`); } - distDir = distDir || path.join(pluginDirectory, 'dist'); - docsDir = docsDir || path.join(pluginDirectory, 'docs'); + distDir ||= path.join(pluginDirectory, 'dist'); + docsDir ||= path.join(pluginDirectory, 'docs'); await packageDocker({ logger, message, distDir, docsDir, pluginVersion, pluginDirectory, plugin }); }, ) diff --git a/src/scalar/bool.test.ts b/src/scalar/bool.test.ts index 6e85852..eaeba87 100644 --- a/src/scalar/bool.test.ts +++ b/src/scalar/bool.test.ts @@ -3,15 +3,15 @@ import test from 'ava'; import { Bool } from './bool.js'; -[null, undefined].forEach((v) => { +for (const v of [null, undefined]) { test(`should set values to false when ${v} is passed`, (t) => { const b = new Bool(v); t.false(b.valid); t.true(DataType.isBool(b.dataType)); }); -}); +} -[1, true, 'true', 'Y', 'y', 'TRUE', 'on', new Bool(true)].forEach((v, index) => { +for (const [index, v] of [1, true, 'true', 'Y', 'y', 'TRUE', 'on', new Bool(true)].entries()) { test(`should support truthy value '${v}' (${index})`, (t) => { const b = new Bool(v); t.true(b.valid); @@ -19,9 +19,9 @@ import { Bool } from './bool.js'; t.true(DataType.isBool(b.dataType)); t.is(b.toString(), 'true'); }); -}); +} -[0, false, 'false', 'N', 'n', 'FALSE', 'off'].forEach((v, index) => { +for (const [index, v] of [0, false, 'false', 'N', 'n', 'FALSE', 'off'].entries()) { test(`should support falsy value '${v}' (${index})`, (t) => { const b = new Bool(v); t.true(b.valid); @@ -29,7 +29,7 @@ import { Bool } from './bool.js'; t.true(DataType.isBool(b.dataType)); t.is(b.toString(), 'false'); }); -}); +} test('should throw when unable to set value', (t) => { t.throws(() => new Bool({ value: {} }), { message: 'Unable to set Bool from value' }); diff --git a/src/scalar/text.test.ts b/src/scalar/text.test.ts index f645806..9e2d2a6 100644 --- a/src/scalar/text.test.ts +++ b/src/scalar/text.test.ts @@ -3,29 +3,29 @@ import test from 'ava'; import { Text } from './text.js'; -[null, undefined, new Text()].forEach((v) => { +for (const v of [null, undefined, new Text()]) { test(`should set values to null string when ${v} is passed`, (t) => { const s = new Text(v); t.is(s.value, null); t.false(s.valid); t.true(DataType.isUtf8(s.dataType)); }); -}); +} -[ +for (const [index, { value, expected }] of [ { value: '', expected: '' }, { value: 'test string', expected: 'test string' }, - { value: String('new string object'), expected: 'new string object' }, + { value: 'new string object', expected: 'new string object' }, { value: new Text('new text object'), expected: 'new text object' }, { value: new TextEncoder().encode('test'), expected: 'test' }, -].forEach(({ value, expected }, index) => { +].entries()) { test(`valid strings: '${value}' (${index})`, (t) => { const s = new Text(value); t.true(s.valid); t.is(s.value, expected); t.true(DataType.isUtf8(s.dataType)); }); -}); +} test('should throw when unable to set value', (t) => { t.throws(() => new Text({ value: {} }), { message: 'Unable to set Text from value' }); diff --git a/src/scalar/timestamp.ts b/src/scalar/timestamp.ts index 5c7e1bd..5a92253 100644 --- a/src/scalar/timestamp.ts +++ b/src/scalar/timestamp.ts @@ -70,7 +70,7 @@ export class Timestamp implements Scalar> { dateValue = value; } - if (value instanceof globalThis.Date) { + if (value instanceof Date) { dateValue = DateTime.fromJSDate(value, { zone: 'utc' }); } diff --git a/src/scheduler/cqid.ts b/src/scheduler/cqid.ts index 939e9af..6f264ed 100644 --- a/src/scheduler/cqid.ts +++ b/src/scheduler/cqid.ts @@ -13,8 +13,8 @@ export const setCQId = (resource: Resource, deterministicCQId: boolean, generato } const primaryKeys = getPrimaryKeys(resource.table); - const cqOnlyPK = primaryKeys.every((pk) => pk === cqIDColumn.name); - if (cqOnlyPK) { + const isCqOnlyPK = primaryKeys.every((pk) => pk === cqIDColumn.name); + if (isCqOnlyPK) { return resource.setCqId(randomCQId); } diff --git a/src/schema/column.ts b/src/schema/column.ts index 2ed3ee7..0811139 100644 --- a/src/schema/column.ts +++ b/src/schema/column.ts @@ -77,16 +77,16 @@ export const toArrowField = (column: Column): Field => { export const fromArrowField = (field: Field): Column => { const { name, type, nullable } = field; const metadata = field.metadata; - const primaryKey = metadata.get(arrow.METADATA_PRIMARY_KEY) === arrow.METADATA_TRUE; - const unique = metadata.get(arrow.METADATA_UNIQUE) === arrow.METADATA_TRUE; - const incrementalKey = metadata.get(arrow.METADATA_INCREMENTAL) === arrow.METADATA_TRUE; + const isPrimaryKey = metadata.get(arrow.METADATA_PRIMARY_KEY) === arrow.METADATA_TRUE; + const isUnique = metadata.get(arrow.METADATA_UNIQUE) === arrow.METADATA_TRUE; + const isIncrementalKey = metadata.get(arrow.METADATA_INCREMENTAL) === arrow.METADATA_TRUE; return createColumn({ name, type, - primaryKey, + primaryKey: isPrimaryKey, notNull: !nullable, - unique, - incrementalKey, + unique: isUnique, + incrementalKey: isIncrementalKey, }); }; diff --git a/src/schema/table.test.ts b/src/schema/table.test.ts index 3a530a4..f4726a5 100644 --- a/src/schema/table.test.ts +++ b/src/schema/table.test.ts @@ -68,7 +68,7 @@ const testCases = [ }, ]; -testCases.forEach((testCase) => { +for (const testCase of testCases) { test(`filterTables - ${testCase.name}`, (t) => { const { allTables, tables, skipTables, skipDependentTables, expected, expectedError } = testCase; if (expectedError) { @@ -82,4 +82,4 @@ testCases.forEach((testCase) => { expected.map(({ name }) => name), ); }); -}); +} diff --git a/src/schema/table.ts b/src/schema/table.ts index 5626308..5b8a6ac 100644 --- a/src/schema/table.ts +++ b/src/schema/table.ts @@ -133,7 +133,7 @@ export const filterTables = ( const withParents = deduplicate(withChildren.flatMap((table) => [...getAllParents(table), table])); const withSkipped = withParents.filter((table) => { - return !isMatch(table.name, skip) && !getAllParents(table).some((parent) => isMatch(parent.name, skip)); + return !isMatch(table.name, skip) && getAllParents(table).every((parent) => !isMatch(parent.name, skip)); }); const skippedParents = withParents diff --git a/src/transformers/transform.ts b/src/transformers/transform.ts index 547d84c..c369469 100644 --- a/src/transformers/transform.ts +++ b/src/transformers/transform.ts @@ -27,9 +27,8 @@ function defaultGetTypeFromValue(key: string, value: unknown): DataType | null { const field = new Field('element', elementType); // 'element' can be any name as it's just for internal representation return new List(field); - } else { - return new JSONType(); } + return new JSONType(); } default: { throw new TransformError(`Unsupported type: ${typeof value}`, { props: { value } });