diff --git a/.github/workflows/test-pulls.yml b/.github/workflows/test-pulls.yml index bdc167689..b1c17abf3 100644 --- a/.github/workflows/test-pulls.yml +++ b/.github/workflows/test-pulls.yml @@ -16,41 +16,10 @@ jobs: - name: yarn install run: yarn install - name: Build packages - run: yarn build --ignore='@lowdefy/blocks-*' + run: yarn build - # format tests don't pass on node 12 since icu is missing and tests don't work with locales - name: Test packages - run: yarn test --ignore='@lowdefy/format' --ignore='@lowdefy/blocks-*' - - - name: Upload coverage to codecov - run: bash <(curl -s https://codecov.io/bash) - - - name: Upload coverage to codeclimate - uses: paambaati/codeclimate-action@v2.7.5 - env: - CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} - with: - coverageLocations: | - ${{github.workspace}}/packages/**/coverage/lcov.info:lcov - continue-on-error: true - - test-blocks: - name: Test blocks - runs-on: ubuntu-latest - steps: - - name: Setup Node - uses: actions/setup-node@v2 - with: - node-version: '12.x' - - uses: actions/checkout@v2 - - name: yarn install - run: yarn install - - name: Build packages - run: yarn build --ignore='@lowdefy/api' --ignore='@lowdefy/build' --ignore='@lowdefy/cli' --ignore='@lowdefy/client' --ignore='@lowdefy/engine' --ignore='@lowdefy/layout' --ignore='@lowdefy/node-utils' --ignore='@lowdefy/operators' --ignore='@lowdefy/server*' - - # format tests don't pass on node 12 since icu is missing and tests don't work with locales - - name: Test packages - run: yarn test --scope='@lowdefy/blocks-*' + run: yarn test --ignore='@lowdefy/engine' --ignore='@lowdefy/blocks-*' --ignore='@lowdefy/plugin-aws' - name: Upload coverage to codecov run: bash <(curl -s https://codecov.io/bash) @@ -71,7 +40,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v2 with: - node-version: '12.x' + node-version: '14.x' - uses: actions/checkout@v2 - name: Check yarn cache integrity run: yarn install --immutable --immutable-cache --check-cache diff --git a/.pnp.cjs b/.pnp.cjs index ab3486ee8..e59bec046 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -2810,7 +2810,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@swc/cli", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:0.1.55"], ["@swc/core", "npm:1.2.135"], ["@swc/jest", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:0.2.17"], - ["jest", "virtual:42e288f3c714e1d86d12bf40fb17a72864641a713e0a167e85a3dab47534d11bcd2e71357e431b2f4737000bc9432f95c60dff0c9bfb212cd46e1f0f5bf0ad9f#npm:27.4.7"] + ["jest", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:27.5.1"] ], "linkType": "SOFT", }] @@ -3511,12 +3511,26 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./packages/plugins/plugins/plugin-aws/", "packageDependencies": [ ["@lowdefy/plugin-aws", "workspace:packages/plugins/plugins/plugin-aws"], + ["@emotion/jest", "virtual:573fe255dffc9c89f4f7aa60da718603753ee98acc55d6772bbd0ebdcf07f9183fb8e54b4f3f2246c538a14ead402db8d2e076039c667d1538702638a0cc87b8#npm:11.7.1"], ["@lowdefy/ajv", "workspace:packages/utils/ajv"], + ["@lowdefy/block-dev", "workspace:packages/utils/block-dev"], + ["@lowdefy/block-utils", "workspace:packages/utils/block-utils"], + ["@lowdefy/blocks-antd", "workspace:packages/plugins/blocks/blocks-antd"], + ["@lowdefy/helpers", "workspace:packages/utils/helpers"], ["@swc/cli", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:0.1.55"], ["@swc/core", "npm:1.2.135"], ["@swc/jest", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:0.2.17"], + ["@testing-library/dom", "npm:8.11.3"], + ["@testing-library/react", "virtual:573fe255dffc9c89f4f7aa60da718603753ee98acc55d6772bbd0ebdcf07f9183fb8e54b4f3f2246c538a14ead402db8d2e076039c667d1538702638a0cc87b8#npm:13.0.0-alpha.4"], + ["@testing-library/user-event", "virtual:573fe255dffc9c89f4f7aa60da718603753ee98acc55d6772bbd0ebdcf07f9183fb8e54b4f3f2246c538a14ead402db8d2e076039c667d1538702638a0cc87b8#npm:14.0.0-alpha.14"], + ["antd", "virtual:f494f6d4e058cb1c8a3b456f6099aff9bd740d65abfc014377b7a3f1e34fcb35eb64a962e127c8bfbedaa0555175b6f2cdc47011e32e2fb5f081d7d32f526c78#npm:4.17.0-alpha.7"], ["aws-sdk", "npm:2.1066.0"], - ["jest", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:27.5.1"] + ["copyfiles", "npm:2.4.1"], + ["jest", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:27.5.1"], + ["jest-serializer-html", "npm:7.1.0"], + ["jest-transform-yaml", "npm:1.0.0"], + ["react", "npm:18.0.0-rc.0"], + ["react-dom", "virtual:573fe255dffc9c89f4f7aa60da718603753ee98acc55d6772bbd0ebdcf07f9183fb8e54b4f3f2246c538a14ead402db8d2e076039c667d1538702638a0cc87b8#npm:18.0.0-rc.0"] ], "linkType": "SOFT", }] @@ -10506,13 +10520,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }] ]], ["jest", [ - ["npm:27.4.7", { - "packageLocation": "./.yarn/cache/jest-npm-27.4.7-cdda9da561-28ce948b30.zip/node_modules/jest/", - "packageDependencies": [ - ["jest", "npm:27.4.7"] - ], - "linkType": "SOFT", - }], ["npm:27.5.1", { "packageLocation": "./.yarn/cache/jest-npm-27.5.1-bacad4fe2a-96f1d69042.zip/node_modules/jest/", "packageDependencies": [ @@ -10520,22 +10527,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ], "linkType": "SOFT", }], - ["virtual:42e288f3c714e1d86d12bf40fb17a72864641a713e0a167e85a3dab47534d11bcd2e71357e431b2f4737000bc9432f95c60dff0c9bfb212cd46e1f0f5bf0ad9f#npm:27.4.7", { - "packageLocation": "./.yarn/__virtual__/jest-virtual-4325f46d83/0/cache/jest-npm-27.4.7-cdda9da561-28ce948b30.zip/node_modules/jest/", - "packageDependencies": [ - ["jest", "virtual:42e288f3c714e1d86d12bf40fb17a72864641a713e0a167e85a3dab47534d11bcd2e71357e431b2f4737000bc9432f95c60dff0c9bfb212cd46e1f0f5bf0ad9f#npm:27.4.7"], - ["@jest/core", "virtual:af105d7a2bc799821f67e8114057f53830abc6c7c9faa96846247605351f361b4158d347970d00ebc3c04dbab6e46e1c1e24df193c1caf1f7d80a00c65068a2a#npm:27.5.1"], - ["@types/node-notifier", null], - ["import-local", "npm:3.1.0"], - ["jest-cli", "virtual:af105d7a2bc799821f67e8114057f53830abc6c7c9faa96846247605351f361b4158d347970d00ebc3c04dbab6e46e1c1e24df193c1caf1f7d80a00c65068a2a#npm:27.5.1"], - ["node-notifier", null] - ], - "packagePeers": [ - "@types/node-notifier", - "node-notifier" - ], - "linkType": "HARD", - }], ["virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:27.5.1", { "packageLocation": "./.yarn/__virtual__/jest-virtual-af105d7a2b/0/cache/jest-npm-27.5.1-bacad4fe2a-96f1d69042.zip/node_modules/jest/", "packageDependencies": [ diff --git a/.yarn/cache/jest-npm-27.4.7-cdda9da561-28ce948b30.zip b/.yarn/cache/jest-npm-27.4.7-cdda9da561-28ce948b30.zip deleted file mode 100644 index feec693d5..000000000 Binary files a/.yarn/cache/jest-npm-27.4.7-cdda9da561-28ce948b30.zip and /dev/null differ diff --git a/packages/plugins/operators/operators-js/jest.config.cjs b/packages/plugins/actions/actions-core/jest.config.js similarity index 96% rename from packages/plugins/operators/operators-js/jest.config.cjs rename to packages/plugins/actions/actions-core/jest.config.js index 67c7bbf70..77ce109f7 100644 --- a/packages/plugins/operators/operators-js/jest.config.cjs +++ b/packages/plugins/actions/actions-core/jest.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { clearMocks: true, collectCoverage: true, collectCoverageFrom: ['src/**/*.js'], diff --git a/packages/plugins/blocks/blocks-antd/jest.config.js b/packages/plugins/blocks/blocks-antd/jest.config.js index 212bbd203..2a0dea045 100644 --- a/packages/plugins/blocks/blocks-antd/jest.config.js +++ b/packages/plugins/blocks/blocks-antd/jest.config.js @@ -4,7 +4,7 @@ export default { collectCoverageFrom: ['src/**/*.js'], coverageDirectory: 'coverage', coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], - coverageReporters: [['lcov', { projectRoot: '../../..' }], 'text', 'clover'], + coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], errorOnDeprecated: true, testEnvironment: 'jsdom', testPathIgnorePatterns: ['/dist/', '/src/test'], diff --git a/packages/plugins/blocks/blocks-basic/jest.config.js b/packages/plugins/blocks/blocks-basic/jest.config.js index 212bbd203..2a0dea045 100644 --- a/packages/plugins/blocks/blocks-basic/jest.config.js +++ b/packages/plugins/blocks/blocks-basic/jest.config.js @@ -4,7 +4,7 @@ export default { collectCoverageFrom: ['src/**/*.js'], coverageDirectory: 'coverage', coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], - coverageReporters: [['lcov', { projectRoot: '../../..' }], 'text', 'clover'], + coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], errorOnDeprecated: true, testEnvironment: 'jsdom', testPathIgnorePatterns: ['/dist/', '/src/test'], diff --git a/packages/plugins/blocks/blocks-color-selectors/jest.config.js b/packages/plugins/blocks/blocks-color-selectors/jest.config.js index 212bbd203..2a0dea045 100644 --- a/packages/plugins/blocks/blocks-color-selectors/jest.config.js +++ b/packages/plugins/blocks/blocks-color-selectors/jest.config.js @@ -4,7 +4,7 @@ export default { collectCoverageFrom: ['src/**/*.js'], coverageDirectory: 'coverage', coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], - coverageReporters: [['lcov', { projectRoot: '../../..' }], 'text', 'clover'], + coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], errorOnDeprecated: true, testEnvironment: 'jsdom', testPathIgnorePatterns: ['/dist/', '/src/test'], diff --git a/packages/plugins/blocks/blocks-echarts/jest.config.js b/packages/plugins/blocks/blocks-echarts/jest.config.js index 212bbd203..2a0dea045 100644 --- a/packages/plugins/blocks/blocks-echarts/jest.config.js +++ b/packages/plugins/blocks/blocks-echarts/jest.config.js @@ -4,7 +4,7 @@ export default { collectCoverageFrom: ['src/**/*.js'], coverageDirectory: 'coverage', coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], - coverageReporters: [['lcov', { projectRoot: '../../..' }], 'text', 'clover'], + coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], errorOnDeprecated: true, testEnvironment: 'jsdom', testPathIgnorePatterns: ['/dist/', '/src/test'], diff --git a/packages/plugins/blocks/blocks-loaders/jest.config.js b/packages/plugins/blocks/blocks-loaders/jest.config.js index 212bbd203..2a0dea045 100644 --- a/packages/plugins/blocks/blocks-loaders/jest.config.js +++ b/packages/plugins/blocks/blocks-loaders/jest.config.js @@ -4,7 +4,7 @@ export default { collectCoverageFrom: ['src/**/*.js'], coverageDirectory: 'coverage', coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], - coverageReporters: [['lcov', { projectRoot: '../../..' }], 'text', 'clover'], + coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], errorOnDeprecated: true, testEnvironment: 'jsdom', testPathIgnorePatterns: ['/dist/', '/src/test'], diff --git a/packages/plugins/blocks/blocks-markdown/jest.config.js b/packages/plugins/blocks/blocks-markdown/jest.config.js index 212bbd203..2a0dea045 100644 --- a/packages/plugins/blocks/blocks-markdown/jest.config.js +++ b/packages/plugins/blocks/blocks-markdown/jest.config.js @@ -4,7 +4,7 @@ export default { collectCoverageFrom: ['src/**/*.js'], coverageDirectory: 'coverage', coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], - coverageReporters: [['lcov', { projectRoot: '../../..' }], 'text', 'clover'], + coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], errorOnDeprecated: true, testEnvironment: 'jsdom', testPathIgnorePatterns: ['/dist/', '/src/test'], diff --git a/packages/plugins/connections/connection-axios-http/src/types.js b/packages/plugins/connections/connection-axios-http/src/types.js index 4691afe39..843c4197f 100644 --- a/packages/plugins/connections/connection-axios-http/src/types.js +++ b/packages/plugins/connections/connection-axios-http/src/types.js @@ -23,8 +23,3 @@ export default { .map((connection) => Object.keys(connections[connection].requests)) .flat(), }; - -// export default { -// connections: ['AxiosHttp'], -// requests: ['AxiosHttp'], -// }; diff --git a/packages/plugins/connections/connection-elasticsearch/src/types.js b/packages/plugins/connections/connection-elasticsearch/src/types.js index b14a21d7d..843c4197f 100644 --- a/packages/plugins/connections/connection-elasticsearch/src/types.js +++ b/packages/plugins/connections/connection-elasticsearch/src/types.js @@ -23,15 +23,3 @@ export default { .map((connection) => Object.keys(connections[connection].requests)) .flat(), }; - -// export default { -// connections: ['Elasticsearch'], -// requests: [ -// ElasticsearchDelete, -// ElasticsearchDeleteByQuery, -// ElasticsearchIndex, -// ElasticsearchSearch, -// ElasticsearchUpdate, -// ElasticsearchUpdateByQuery, -// ], -// }; diff --git a/packages/plugins/connections/connection-google-sheets/src/types.js b/packages/plugins/connections/connection-google-sheets/src/types.js index f283fd643..843c4197f 100644 --- a/packages/plugins/connections/connection-google-sheets/src/types.js +++ b/packages/plugins/connections/connection-google-sheets/src/types.js @@ -23,16 +23,3 @@ export default { .map((connection) => Object.keys(connections[connection].requests)) .flat(), }; - -// export default { -// connections: ['GoogleSheet'], -// requests: [ -// GoogleSheetAppendMany, -// GoogleSheetAppendOne, -// GoogleSheetDeleteOne, -// GoogleSheetGetMany, -// GoogleSheetGetOne, -// GoogleSheetUpdateOne, -// GoogleSheetUpdateMany, -// ], -// }; diff --git a/packages/plugins/connections/connection-knex/src/types.js b/packages/plugins/connections/connection-knex/src/types.js index c978a63a8..21ccc53c4 100644 --- a/packages/plugins/connections/connection-knex/src/types.js +++ b/packages/plugins/connections/connection-knex/src/types.js @@ -22,8 +22,3 @@ export default { .map((connection) => Object.keys(connections[connection].requests)) .flat(), }; - -// export default { -// connections: ['Knex'], -// requests: ['KnexBuilder', 'KnexRaw'], -// }; diff --git a/packages/plugins/connections/connection-mongodb/src/types.js b/packages/plugins/connections/connection-mongodb/src/types.js index 04a5333d6..843c4197f 100644 --- a/packages/plugins/connections/connection-mongodb/src/types.js +++ b/packages/plugins/connections/connection-mongodb/src/types.js @@ -23,18 +23,3 @@ export default { .map((connection) => Object.keys(connections[connection].requests)) .flat(), }; - -// export default { -// connections: ['MongoDBCollection'], -// requests: [ -// MongoDBAggregation, -// MongoDBDeleteMany, -// MongoDBDeleteOne, -// MongoDBFind, -// MongoDBFindOne, -// MongoDBInsertMany, -// MongoDBInsertOne, -// MongoDBUpdateMany, -// MongoDBUpdateOne, -// ], -// }; diff --git a/packages/plugins/connections/connection-redis/src/types.js b/packages/plugins/connections/connection-redis/src/types.js index e5f36d5b1..843c4197f 100644 --- a/packages/plugins/connections/connection-redis/src/types.js +++ b/packages/plugins/connections/connection-redis/src/types.js @@ -23,8 +23,3 @@ export default { .map((connection) => Object.keys(connections[connection].requests)) .flat(), }; - -// export default { -// connections: ['Redis'], -// requests: ['Redis'], -// }; diff --git a/packages/plugins/connections/connection-sendgrid/src/types.js b/packages/plugins/connections/connection-sendgrid/src/types.js index b43a4cc6d..843c4197f 100644 --- a/packages/plugins/connections/connection-sendgrid/src/types.js +++ b/packages/plugins/connections/connection-sendgrid/src/types.js @@ -23,8 +23,3 @@ export default { .map((connection) => Object.keys(connections[connection].requests)) .flat(), }; - -// export default { -// connections: ['SendGridMail'], -// requests: ['SendGridMailSend'], -// }; diff --git a/packages/plugins/connections/connection-stripe/src/types.js b/packages/plugins/connections/connection-stripe/src/types.js index c711afeaa..843c4197f 100644 --- a/packages/plugins/connections/connection-stripe/src/types.js +++ b/packages/plugins/connections/connection-stripe/src/types.js @@ -23,8 +23,3 @@ export default { .map((connection) => Object.keys(connections[connection].requests)) .flat(), }; - -// export default { -// connections: ['Stripe'], -// requests: ['StripeRequest'], -// }; diff --git a/packages/plugins/actions/actions-core/jest.config.cjs b/packages/plugins/operators/operators-change-case/jest.config.js similarity index 96% rename from packages/plugins/actions/actions-core/jest.config.cjs rename to packages/plugins/operators/operators-change-case/jest.config.js index 67c7bbf70..77ce109f7 100644 --- a/packages/plugins/actions/actions-core/jest.config.cjs +++ b/packages/plugins/operators/operators-change-case/jest.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { clearMocks: true, collectCoverage: true, collectCoverageFrom: ['src/**/*.js'], diff --git a/packages/plugins/operators/operators-change-case/jest.config.cjs b/packages/plugins/operators/operators-diff/jest.config.js similarity index 96% rename from packages/plugins/operators/operators-change-case/jest.config.cjs rename to packages/plugins/operators/operators-diff/jest.config.js index 67c7bbf70..77ce109f7 100644 --- a/packages/plugins/operators/operators-change-case/jest.config.cjs +++ b/packages/plugins/operators/operators-diff/jest.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { clearMocks: true, collectCoverage: true, collectCoverageFrom: ['src/**/*.js'], diff --git a/packages/plugins/operators/operators-diff/jest.config.cjs b/packages/plugins/operators/operators-js/jest.config.js similarity index 96% rename from packages/plugins/operators/operators-diff/jest.config.cjs rename to packages/plugins/operators/operators-js/jest.config.js index 67c7bbf70..77ce109f7 100644 --- a/packages/plugins/operators/operators-diff/jest.config.cjs +++ b/packages/plugins/operators/operators-js/jest.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { clearMocks: true, collectCoverage: true, collectCoverageFrom: ['src/**/*.js'], diff --git a/packages/plugins/operators/operators-mql/jest.config.cjs b/packages/plugins/operators/operators-mql/jest.config.cjs deleted file mode 100644 index 67c7bbf70..000000000 --- a/packages/plugins/operators/operators-mql/jest.config.cjs +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - clearMocks: true, - collectCoverage: true, - collectCoverageFrom: ['src/**/*.js'], - coverageDirectory: 'coverage', - coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], - coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], - errorOnDeprecated: true, - testEnvironment: 'jsdom', - testPathIgnorePatterns: ['/dist/', '/src/test'], - transform: { - '^.+\\.(t|j)sx?$': ['@swc/jest', { configFile: '../../../../.swcrc.test' }], - }, -}; diff --git a/packages/plugins/operators/operators-mql/jest.config.js b/packages/plugins/operators/operators-mql/jest.config.js new file mode 100644 index 000000000..77ce109f7 --- /dev/null +++ b/packages/plugins/operators/operators-mql/jest.config.js @@ -0,0 +1,14 @@ +export default { + clearMocks: true, + collectCoverage: true, + collectCoverageFrom: ['src/**/*.js'], + coverageDirectory: 'coverage', + coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], + coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], + errorOnDeprecated: true, + testEnvironment: 'jsdom', + testPathIgnorePatterns: ['/dist/', '/src/test'], + transform: { + '^.+\\.(t|j)sx?$': ['@swc/jest', { configFile: '../../../../.swcrc.test' }], + }, +}; diff --git a/packages/plugins/operators/operators-nunjucks/jest.config.cjs b/packages/plugins/operators/operators-nunjucks/jest.config.cjs deleted file mode 100644 index 67c7bbf70..000000000 --- a/packages/plugins/operators/operators-nunjucks/jest.config.cjs +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - clearMocks: true, - collectCoverage: true, - collectCoverageFrom: ['src/**/*.js'], - coverageDirectory: 'coverage', - coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], - coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], - errorOnDeprecated: true, - testEnvironment: 'jsdom', - testPathIgnorePatterns: ['/dist/', '/src/test'], - transform: { - '^.+\\.(t|j)sx?$': ['@swc/jest', { configFile: '../../../../.swcrc.test' }], - }, -}; diff --git a/packages/plugins/operators/operators-nunjucks/jest.config.js b/packages/plugins/operators/operators-nunjucks/jest.config.js new file mode 100644 index 000000000..77ce109f7 --- /dev/null +++ b/packages/plugins/operators/operators-nunjucks/jest.config.js @@ -0,0 +1,14 @@ +export default { + clearMocks: true, + collectCoverage: true, + collectCoverageFrom: ['src/**/*.js'], + coverageDirectory: 'coverage', + coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], + coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], + errorOnDeprecated: true, + testEnvironment: 'jsdom', + testPathIgnorePatterns: ['/dist/', '/src/test'], + transform: { + '^.+\\.(t|j)sx?$': ['@swc/jest', { configFile: '../../../../.swcrc.test' }], + }, +}; diff --git a/packages/plugins/operators/operators-uuid/jest.config.cjs b/packages/plugins/operators/operators-uuid/jest.config.cjs deleted file mode 100644 index 67c7bbf70..000000000 --- a/packages/plugins/operators/operators-uuid/jest.config.cjs +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - clearMocks: true, - collectCoverage: true, - collectCoverageFrom: ['src/**/*.js'], - coverageDirectory: 'coverage', - coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], - coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], - errorOnDeprecated: true, - testEnvironment: 'jsdom', - testPathIgnorePatterns: ['/dist/', '/src/test'], - transform: { - '^.+\\.(t|j)sx?$': ['@swc/jest', { configFile: '../../../../.swcrc.test' }], - }, -}; diff --git a/packages/plugins/operators/operators-uuid/jest.config.js b/packages/plugins/operators/operators-uuid/jest.config.js new file mode 100644 index 000000000..77ce109f7 --- /dev/null +++ b/packages/plugins/operators/operators-uuid/jest.config.js @@ -0,0 +1,14 @@ +export default { + clearMocks: true, + collectCoverage: true, + collectCoverageFrom: ['src/**/*.js'], + coverageDirectory: 'coverage', + coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], + coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], + errorOnDeprecated: true, + testEnvironment: 'jsdom', + testPathIgnorePatterns: ['/dist/', '/src/test'], + transform: { + '^.+\\.(t|j)sx?$': ['@swc/jest', { configFile: '../../../../.swcrc.test' }], + }, +}; diff --git a/packages/plugins/operators/operators-yaml/jest.config.cjs b/packages/plugins/operators/operators-yaml/jest.config.cjs deleted file mode 100644 index 67c7bbf70..000000000 --- a/packages/plugins/operators/operators-yaml/jest.config.cjs +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - clearMocks: true, - collectCoverage: true, - collectCoverageFrom: ['src/**/*.js'], - coverageDirectory: 'coverage', - coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], - coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], - errorOnDeprecated: true, - testEnvironment: 'jsdom', - testPathIgnorePatterns: ['/dist/', '/src/test'], - transform: { - '^.+\\.(t|j)sx?$': ['@swc/jest', { configFile: '../../../../.swcrc.test' }], - }, -}; diff --git a/packages/plugins/operators/operators-yaml/jest.config.js b/packages/plugins/operators/operators-yaml/jest.config.js new file mode 100644 index 000000000..77ce109f7 --- /dev/null +++ b/packages/plugins/operators/operators-yaml/jest.config.js @@ -0,0 +1,14 @@ +export default { + clearMocks: true, + collectCoverage: true, + collectCoverageFrom: ['src/**/*.js'], + coverageDirectory: 'coverage', + coveragePathIgnorePatterns: ['/dist/', '/src/test', '/src/index.js'], + coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], + errorOnDeprecated: true, + testEnvironment: 'jsdom', + testPathIgnorePatterns: ['/dist/', '/src/test'], + transform: { + '^.+\\.(t|j)sx?$': ['@swc/jest', { configFile: '../../../../.swcrc.test' }], + }, +}; diff --git a/packages/plugins/plugins/plugin-aws/jest.config.cjs b/packages/plugins/plugins/plugin-aws/jest.config.js similarity index 73% rename from packages/plugins/plugins/plugin-aws/jest.config.cjs rename to packages/plugins/plugins/plugin-aws/jest.config.js index 0f5446103..18ba79831 100644 --- a/packages/plugins/plugins/plugin-aws/jest.config.cjs +++ b/packages/plugins/plugins/plugin-aws/jest.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { clearMocks: true, collectCoverage: true, collectCoverageFrom: ['src/**/*.js'], @@ -6,9 +6,11 @@ module.exports = { coveragePathIgnorePatterns: ['/dist/', '/src/index.js'], coverageReporters: [['lcov', { projectRoot: '../../../..' }], 'text', 'clover'], errorOnDeprecated: true, - testEnvironment: 'node', + testEnvironment: 'jsdom', testPathIgnorePatterns: ['/dist/'], transform: { '^.+\\.(t|j)sx?$': ['@swc/jest', { configFile: '../../../../.swcrc.test' }], + '\\.yaml$': 'jest-transform-yaml', }, + snapshotSerializers: ['@emotion/jest/serializer', 'jest-serializer-html'], }; diff --git a/packages/plugins/plugins/plugin-aws/package.json b/packages/plugins/plugins/plugin-aws/package.json index 149638d93..3b33382ee 100644 --- a/packages/plugins/plugins/plugin-aws/package.json +++ b/packages/plugins/plugins/plugin-aws/package.json @@ -36,19 +36,34 @@ "scripts": { "build": "yarn swc", "clean": "rm -rf dist", + "copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\"", "prepare": "yarn build", - "swc": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files", + "swc": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start && yarn copyfiles", "test": "jest --coverage" }, "dependencies": { - "aws-sdk": "2.1066.0" + "@lowdefy/block-utils": "4.0.0-alpha.6", + "@lowdefy/blocks-antd": "4.0.0-alpha.6", + "@lowdefy/helpers": "4.0.0-alpha.6", + "antd": "4.17.0-alpha.7", + "aws-sdk": "2.1066.0", + "react": "18.0.0-rc.0", + "react-dom": "18.0.0-rc.0" }, "devDependencies": { + "@emotion/jest": "11.7.1", "@lowdefy/ajv": "4.0.0-alpha.6", + "@lowdefy/block-dev": "4.0.0-alpha.6", "@swc/cli": "0.1.55", "@swc/core": "1.2.135", "@swc/jest": "0.2.17", - "jest": "27.5.1" + "@testing-library/dom": "8.11.3", + "@testing-library/react": "13.0.0-alpha.4", + "@testing-library/user-event": "14.0.0-alpha.14", + "copyfiles": "2.4.1", + "jest": "27.5.1", + "jest-serializer-html": "7.1.0", + "jest-transform-yaml": "1.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/plugins/plugins/plugin-aws/src/blocks/S3UploadButton/S3UploadButton.js b/packages/plugins/plugins/plugin-aws/src/blocks/S3UploadButton/S3UploadButton.js index d05743224..a93db318b 100644 --- a/packages/plugins/plugins/plugin-aws/src/blocks/S3UploadButton/S3UploadButton.js +++ b/packages/plugins/plugins/plugin-aws/src/blocks/S3UploadButton/S3UploadButton.js @@ -17,9 +17,9 @@ import React, { useEffect, useState } from 'react'; import { blockDefaultProps } from '@lowdefy/block-utils'; import { get } from '@lowdefy/helpers'; -import { Upload } from 'antd'; +import { Button } from '@lowdefy/blocks-antd/blocks'; -import Button from '../Button/Button.js'; +import { Upload } from 'antd'; const makeFileValue = (file, s3Parameters) => { const { lastModified, name, percent, size, status, type, uid } = file; diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3Bucket.js b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3Bucket.js index 4713ea45b..f3751aca4 100644 --- a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3Bucket.js +++ b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3Bucket.js @@ -14,13 +14,12 @@ limitations under the License. */ -import AwsS3PresignedGetObject from './AwsS3PresignedGetObject/index.js'; -import AwsS3PresignedPostPolicy from './AwsS3PresignedPostPolicy/index.js'; +import AwsS3PresignedGetObject from './AwsS3PresignedGetObject/AwsS3PresignedGetObject.js'; +import AwsS3PresignedPostPolicy from './AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js'; +import schema from './schema.js'; export default { - import: { - schema: 'connections/AwsS3Bucket/AwsS3BucketSchema.json', - }, + schema, requests: { AwsS3PresignedGetObject, AwsS3PresignedPostPolicy, diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3Bucket.test.js b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3Bucket.test.js index 5df4bf28a..9ec11a7e9 100644 --- a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3Bucket.test.js +++ b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3Bucket.test.js @@ -17,7 +17,8 @@ import { validate } from '@lowdefy/ajv'; import AwsS3Bucket from './AwsS3Bucket.js'; -import schema from './AwsS3BucketSchema.json'; + +const schema = AwsS3Bucket.schema; test('All requests are present', () => { expect(AwsS3Bucket.requests.AwsS3PresignedGetObject).toBeDefined(); diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3BucketSchema.json b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3BucketSchema.json deleted file mode 100644 index 7f1d7320e..000000000 --- a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3BucketSchema.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Lowdefy Connection Schema - AwsS3Bucket", - "type": "object", - "required": ["accessKeyId", "secretAccessKey", "region", "bucket"], - "properties": { - "accessKeyId": { - "type": "string", - "description": "AWS IAM access key id with s3 access.", - "errorMessage": { - "type": "AwsS3Bucket connection property \"accessKeyId\" should be a string." - } - }, - "secretAccessKey": { - "type": "string", - "description": "AWS IAM secret access key with s3 access.", - "errorMessage": { - "type": "AwsS3Bucket connection property \"secretAccessKey\" should be a string." - } - }, - "region": { - "type": "string", - "description": "AWS region the bucket is located in.", - "errorMessage": { - "type": "AwsS3Bucket connection property \"region\" should be a string." - } - }, - "bucket": { - "type": "string", - "description": "S3 bucket name.", - "errorMessage": { - "type": "AwsS3Bucket connection property \"bucket\" should be a string." - } - }, - "read": { - "type": "boolean", - "default": true, - "description": "Allow reads from the bucket.", - "errorMessage": { - "type": "AwsS3Bucket connection property \"read\" should be a boolean." - } - }, - "write": { - "type": "boolean", - "default": false, - "description": "Allow writes to the bucket.", - "errorMessage": { - "type": "AwsS3Bucket connection property \"write\" should be a boolean." - } - } - }, - "errorMessage": { - "type": "AwsS3Bucket connection properties should be an object.", - "required": { - "accessKeyId": "AwsS3Bucket connection should have required property \"accessKeyId\".", - "secretAccessKey": "AwsS3Bucket connection should have required property \"secretAccessKey\".", - "region": "AwsS3Bucket connection should have required property \"region\".", - "bucket": "AwsS3Bucket connection should have required property \"bucket\"." - } - } -} \ No newline at end of file diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.js b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.js index 6f00b49d4..86706cd2d 100644 --- a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.js +++ b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.js @@ -15,8 +15,9 @@ */ import AWS from 'aws-sdk'; +import schema from './schema.js'; -function awsS3PresignedGetObject({ request, connection }) { +function AwsS3PresignedGetObject({ request, connection }) { const { accessKeyId, secretAccessKey, region, bucket } = connection; const { expires, key, versionId, responseContentDisposition, responseContentType } = request; const params = { @@ -31,4 +32,10 @@ function awsS3PresignedGetObject({ request, connection }) { return s3.getSignedUrl('getObject', params); } -export default awsS3PresignedGetObject; +AwsS3PresignedGetObject.schema = schema; +AwsS3PresignedGetObject.meta = { + checkRead: true, + checkWrite: false, +}; + +export default AwsS3PresignedGetObject; diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.test.js b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.test.js index 789a30d16..43cf86d33 100644 --- a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.test.js +++ b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.test.js @@ -17,12 +17,13 @@ import { validate } from '@lowdefy/ajv'; import AWS from 'aws-sdk'; -import awsS3PresignedGetObject from './AwsS3PresignedGetObject.js'; -import requestIndex from './index.js'; -import schema from './AwsS3PresignedGetObjectSchema.json'; +import AwsS3PresignedGetObject from './AwsS3PresignedGetObject.js'; jest.mock('aws-sdk'); +const schema = AwsS3PresignedGetObject.schema; +const { checkRead, checkWrite } = AwsS3PresignedGetObject.meta; + const mockGetSignedUrl = jest.fn(); const getSignedUrlMockImp = () => 'res'; const mockS3Constructor = jest.fn(); @@ -32,8 +33,6 @@ const s3ConstructorMockImp = () => ({ AWS.S3 = mockS3Constructor; -const { checkRead, checkWrite } = requestIndex.meta; - beforeEach(() => { mockGetSignedUrl.mockReset(); mockS3Constructor.mockReset(); @@ -41,7 +40,7 @@ beforeEach(() => { mockS3Constructor.mockImplementation(s3ConstructorMockImp); }); -test('awsS3PresignedGetObject', () => { +test('AwsS3PresignedGetObject', () => { const request = { key: 'key' }; const connection = { accessKeyId: 'accessKeyId', @@ -50,7 +49,7 @@ test('awsS3PresignedGetObject', () => { write: true, bucket: 'bucket', }; - const res = awsS3PresignedGetObject({ request, connection }); + const res = AwsS3PresignedGetObject({ request, connection }); expect(mockS3Constructor.mock.calls).toEqual([ [ { @@ -73,7 +72,7 @@ test('awsS3PresignedGetObject', () => { expect(res).toEqual('res'); }); -test('awsS3PresignedGetObject options ', async () => { +test('AwsS3PresignedGetObject options ', async () => { const request = { key: 'key', versionId: 'versionId', @@ -87,7 +86,7 @@ test('awsS3PresignedGetObject options ', async () => { region: 'region', bucket: 'bucket', }; - const res = awsS3PresignedGetObject({ request, connection }); + const res = AwsS3PresignedGetObject({ request, connection }); expect(mockS3Constructor.mock.calls).toEqual([ [ { @@ -133,7 +132,7 @@ test('Error from s3 client', async () => { region: 'region', bucket: 'bucket', }; - await expect(() => awsS3PresignedGetObject({ request, connection })).toThrow( + await expect(() => AwsS3PresignedGetObject({ request, connection })).toThrow( 'Test S3 client error.' ); }); diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObjectSchema.json b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObjectSchema.json deleted file mode 100644 index b8f016942..000000000 --- a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObjectSchema.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Lowdefy Request Schema - AwsS3PresignedGetObject", - "type": "object", - "required": ["key"], - "properties": { - "expires": { - "type": "number", - "description": "Number of seconds for which the policy should be valid.", - "default": 3600, - "errorMessage": { - "type": "AwsS3PresignedGetObject request property \"expires\" should be a number." - } - }, - "key": { - "type": "string", - "description": "Key under which object is stored.", - "errorMessage": { - "type": "AwsS3PresignedGetObject request property \"key\" should be a string." - } - }, - "responseContentDisposition": { - "type": "string", - "description": "Sets the Content-Disposition header of the response.", - "errorMessage": { - "type": "AwsS3PresignedGetObject request property \"responseContentDisposition\" should be a string." - } - }, - "responseContentType": { - "type": "string", - "description": "Sets the Content-Type header of the response.", - "errorMessage": { - "type": "AwsS3PresignedGetObject request property \"responseContentType\" should be a string." - } - }, - "versionId": { - "type": "string", - "description": "VersionId used to reference a specific version of the object.", - "errorMessage": { - "type": "AwsS3PresignedGetObject request property \"versionId\" should be a string." - } - } - }, - "errorMessage": { - "type": "AwsS3PresignedGetObject request properties should be an object.", - "required": "AwsS3PresignedGetObject request should have required property \"key\"." - } -} \ No newline at end of file diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/index.js b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/index.js deleted file mode 100644 index 9a792586f..000000000 --- a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/index.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright 2020-2021 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -export default { - import: { - path: 'connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.js', - schema: 'connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObjectSchema.json', - }, - meta: { - checkRead: true, - checkWrite: false, - }, -}; diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/schema.js b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/schema.js new file mode 100644 index 000000000..f8e396094 --- /dev/null +++ b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedGetObject/schema.js @@ -0,0 +1,64 @@ +/* + Copyright 2020-2021 Lowdefy, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +export default { + $schema: 'http://json-schema.org/draft-07/schema#', + title: 'Lowdefy Request Schema - AwsS3PresignedGetObject', + type: 'object', + required: ['key'], + properties: { + expires: { + type: 'number', + description: 'Number of seconds for which the policy should be valid.', + default: 3600, + errorMessage: { + type: 'AwsS3PresignedGetObject request property "expires" should be a number.', + }, + }, + key: { + type: 'string', + description: 'Key under which object is stored.', + errorMessage: { + type: 'AwsS3PresignedGetObject request property "key" should be a string.', + }, + }, + responseContentDisposition: { + type: 'string', + description: 'Sets the Content-Disposition header of the response.', + errorMessage: { + type: 'AwsS3PresignedGetObject request property "responseContentDisposition" should be a string.', + }, + }, + responseContentType: { + type: 'string', + description: 'Sets the Content-Type header of the response.', + errorMessage: { + type: 'AwsS3PresignedGetObject request property "responseContentType" should be a string.', + }, + }, + versionId: { + type: 'string', + description: 'VersionId used to reference a specific version of the object.', + errorMessage: { + type: 'AwsS3PresignedGetObject request property "versionId" should be a string.', + }, + }, + }, + errorMessage: { + type: 'AwsS3PresignedGetObject request properties should be an object.', + required: 'AwsS3PresignedGetObject request should have required property "key".', + }, +}; diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js index cc039af67..6d0b13695 100644 --- a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js +++ b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js @@ -15,8 +15,9 @@ */ import AWS from 'aws-sdk'; +import schema from './schema.js'; -function awsS3PresignedPostPolicy({ request, connection }) { +function AwsS3PresignedPostPolicy({ request, connection }) { const { accessKeyId, secretAccessKey, region, bucket } = connection; const { acl, conditions, expires, key } = request; const params = { @@ -38,4 +39,10 @@ function awsS3PresignedPostPolicy({ request, connection }) { return s3.createPresignedPost(params); } -export default awsS3PresignedPostPolicy; +AwsS3PresignedPostPolicy.schema = schema; +AwsS3PresignedPostPolicy.meta = { + checkRead: false, + checkWrite: true, +}; + +export default AwsS3PresignedPostPolicy; diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.test.js b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.test.js index 56f1d3799..2e36104c7 100644 --- a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.test.js +++ b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.test.js @@ -17,12 +17,13 @@ import { validate } from '@lowdefy/ajv'; import AWS from 'aws-sdk'; -import awsS3PresignedPostPolicy from './AwsS3PresignedPostPolicy.js'; -import requestIndex from './index.js'; -import schema from './AwsS3PresignedPostPolicySchema.json'; +import AwsS3PresignedPostPolicy from './AwsS3PresignedPostPolicy.js'; jest.mock('aws-sdk'); +const schema = AwsS3PresignedPostPolicy.schema; +const { checkRead, checkWrite } = AwsS3PresignedPostPolicy.meta; + const mockCreatePresignedPost = jest.fn(); const createPresignedPostMockImp = () => 'res'; const mockS3Constructor = jest.fn(); @@ -32,8 +33,6 @@ const s3ConstructorMockImp = () => ({ AWS.S3 = mockS3Constructor; -const { checkRead, checkWrite } = requestIndex.meta; - beforeEach(() => { mockCreatePresignedPost.mockReset(); mockS3Constructor.mockReset(); @@ -41,7 +40,7 @@ beforeEach(() => { mockS3Constructor.mockImplementation(s3ConstructorMockImp); }); -test('awsS3PresignedPostPolicy', () => { +test('AwsS3PresignedPostPolicy', () => { const request = { key: 'key' }; const connection = { accessKeyId: 'accessKeyId', @@ -50,7 +49,7 @@ test('awsS3PresignedPostPolicy', () => { write: true, bucket: 'bucket', }; - const res = awsS3PresignedPostPolicy({ request, connection }); + const res = AwsS3PresignedPostPolicy({ request, connection }); expect(mockS3Constructor.mock.calls).toEqual([ [ { @@ -74,7 +73,7 @@ test('awsS3PresignedPostPolicy', () => { expect(res).toEqual('res'); }); -test('awsS3PresignedPostPolicy options ', async () => { +test('AwsS3PresignedPostPolicy options ', async () => { const request = { key: 'key', acl: 'private', @@ -88,7 +87,7 @@ test('awsS3PresignedPostPolicy options ', async () => { write: true, bucket: 'bucket', }; - const res = awsS3PresignedPostPolicy({ request, connection }); + const res = AwsS3PresignedPostPolicy({ request, connection }); expect(mockS3Constructor.mock.calls).toEqual([ [ { @@ -127,7 +126,7 @@ test('Error from s3 client', async () => { bucket: 'bucket', write: true, }; - await expect(() => awsS3PresignedPostPolicy({ request, connection })).toThrow( + await expect(() => AwsS3PresignedPostPolicy({ request, connection })).toThrow( 'Test S3 client error.' ); }); diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicySchema.json b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicySchema.json deleted file mode 100644 index 2da5a0531..000000000 --- a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicySchema.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Lowdefy Request Schema - AwsS3PresignedPostPolicy", - "type": "object", - "required": ["key"], - "properties": { - "acl": { - "type": "string", - "enum": [ - "private", - "public-read", - "public-read-write", - "aws-exec-read", - "authenticated-read", - "bucket-owner-read", - "bucket-owner-full-control" - ], - "description": "Access control lists used to grant read and write access.", - "errorMessage": { - "type": "AwsS3PresignedPostPolicy request property \"acl\" should be a string.", - "enum": "AwsS3PresignedPostPolicy request property \"acl\" is not one of \"private\", \"public-read\", \"public-read-write\", \"aws-exec-read\", \"authenticated-read\", \"bucket-owner-read\", \"bucket-owner-full-control\"." - } - }, - "conditions": { - "type": "array", - "items": { - "type": "array" - }, - "description": "Conditions to be enforced on the request.", - "errorMessage": { - "type": "AwsS3PresignedPostPolicy request property \"conditions\" should be a array." - } - }, - "expires": { - "type": "number", - "description": "Number of seconds for which the policy should be valid.", - "default": 3600, - "errorMessage": { - "type": "AwsS3PresignedPostPolicy request property \"expires\" should be a number." - } - }, - "key": { - "type": "string", - "description": "Key under which object will be stored.", - "errorMessage": { - "type": "AwsS3PresignedPostPolicy request property \"key\" should be a string." - } - } - }, - "errorMessage": { - "type": "AwsS3PresignedPostPolicy request properties should be an object.", - "required": "AwsS3PresignedPostPolicy request should have required property \"key\"." - } -} \ No newline at end of file diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/index.js b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/index.js deleted file mode 100644 index ecb8718fb..000000000 --- a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/index.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright 2020-2021 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -export default { - import: { - path: 'connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js', - schema: 'connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedPostPolicySchema.json', - }, - meta: { - checkRead: false, - checkWrite: true, - }, -}; diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/schema.js b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/schema.js new file mode 100644 index 000000000..3e3a0fde3 --- /dev/null +++ b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/schema.js @@ -0,0 +1,70 @@ +/* + Copyright 2020-2021 Lowdefy, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +export default { + $schema: 'http://json-schema.org/draft-07/schema#', + title: 'Lowdefy Request Schema - AwsS3PresignedPostPolicy', + type: 'object', + required: ['key'], + properties: { + acl: { + type: 'string', + enum: [ + 'private', + 'public-read', + 'public-read-write', + 'aws-exec-read', + 'authenticated-read', + 'bucket-owner-read', + 'bucket-owner-full-control', + ], + description: 'Access control lists used to grant read and write access.', + errorMessage: { + type: 'AwsS3PresignedPostPolicy request property "acl" should be a string.', + enum: 'AwsS3PresignedPostPolicy request property "acl" is not one of "private", "public-read", "public-read-write", "aws-exec-read", "authenticated-read", "bucket-owner-read", "bucket-owner-full-control".', + }, + }, + conditions: { + type: 'array', + items: { + type: 'array', + }, + description: 'Conditions to be enforced on the request.', + errorMessage: { + type: 'AwsS3PresignedPostPolicy request property "conditions" should be a array.', + }, + }, + expires: { + type: 'number', + description: 'Number of seconds for which the policy should be valid.', + default: 3600, + errorMessage: { + type: 'AwsS3PresignedPostPolicy request property "expires" should be a number.', + }, + }, + key: { + type: 'string', + description: 'Key under which object will be stored.', + errorMessage: { + type: 'AwsS3PresignedPostPolicy request property "key" should be a string.', + }, + }, + }, + errorMessage: { + type: 'AwsS3PresignedPostPolicy request properties should be an object.', + required: 'AwsS3PresignedPostPolicy request should have required property "key".', + }, +}; diff --git a/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/schema.js b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/schema.js new file mode 100644 index 000000000..cef7975f6 --- /dev/null +++ b/packages/plugins/plugins/plugin-aws/src/connections/AwsS3Bucket/schema.js @@ -0,0 +1,77 @@ +/* + Copyright 2020-2021 Lowdefy, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +export default { + $schema: 'http://json-schema.org/draft-07/schema#', + title: 'Lowdefy Connection Schema - AwsS3Bucket', + type: 'object', + required: ['accessKeyId', 'secretAccessKey', 'region', 'bucket'], + properties: { + accessKeyId: { + type: 'string', + description: 'AWS IAM access key id with s3 access.', + errorMessage: { + type: 'AwsS3Bucket connection property "accessKeyId" should be a string.', + }, + }, + secretAccessKey: { + type: 'string', + description: 'AWS IAM secret access key with s3 access.', + errorMessage: { + type: 'AwsS3Bucket connection property "secretAccessKey" should be a string.', + }, + }, + region: { + type: 'string', + description: 'AWS region the bucket is located in.', + errorMessage: { + type: 'AwsS3Bucket connection property "region" should be a string.', + }, + }, + bucket: { + type: 'string', + description: 'S3 bucket name.', + errorMessage: { + type: 'AwsS3Bucket connection property "bucket" should be a string.', + }, + }, + read: { + type: 'boolean', + default: true, + description: 'Allow reads from the bucket.', + errorMessage: { + type: 'AwsS3Bucket connection property "read" should be a boolean.', + }, + }, + write: { + type: 'boolean', + default: false, + description: 'Allow writes to the bucket.', + errorMessage: { + type: 'AwsS3Bucket connection property "write" should be a boolean.', + }, + }, + }, + errorMessage: { + type: 'AwsS3Bucket connection properties should be an object.', + required: { + accessKeyId: 'AwsS3Bucket connection should have required property "accessKeyId".', + secretAccessKey: 'AwsS3Bucket connection should have required property "secretAccessKey".', + region: 'AwsS3Bucket connection should have required property "region".', + bucket: 'AwsS3Bucket connection should have required property "bucket".', + }, + }, +}; diff --git a/packages/plugins/plugins/plugin-aws/src/types.js b/packages/plugins/plugins/plugin-aws/src/types.js index f283fd643..843c4197f 100644 --- a/packages/plugins/plugins/plugin-aws/src/types.js +++ b/packages/plugins/plugins/plugin-aws/src/types.js @@ -23,16 +23,3 @@ export default { .map((connection) => Object.keys(connections[connection].requests)) .flat(), }; - -// export default { -// connections: ['GoogleSheet'], -// requests: [ -// GoogleSheetAppendMany, -// GoogleSheetAppendOne, -// GoogleSheetDeleteOne, -// GoogleSheetGetMany, -// GoogleSheetGetOne, -// GoogleSheetUpdateOne, -// GoogleSheetUpdateMany, -// ], -// }; diff --git a/packages/utils/block-utils/src/__snapshots__/ErrorBoundary.test.js.snap b/packages/utils/block-utils/src/__snapshots__/ErrorBoundary.test.js.snap index fddfa309e..494202fcf 100644 --- a/packages/utils/block-utils/src/__snapshots__/ErrorBoundary.test.js.snap +++ b/packages/utils/block-utils/src/__snapshots__/ErrorBoundary.test.js.snap @@ -85,7 +85,7 @@ exports[`display fallback component on error generated by child 1`] = ` `; -exports[`display no error message on error generated by child 1`] = ``; +exports[`display no error message on error generated by child 1`] = `null`; exports[`no error 1`] = `
diff --git a/packages/utils/block-utils/src/__snapshots__/createIcon.test.js.snap b/packages/utils/block-utils/src/__snapshots__/createIcon.test.js.snap index a0e4fca7e..f5e838d6c 100644 --- a/packages/utils/block-utils/src/__snapshots__/createIcon.test.js.snap +++ b/packages/utils/block-utils/src/__snapshots__/createIcon.test.js.snap @@ -21,6 +21,7 @@ exports[`Icon onClick.loading false 1`] = ` class="emotion-0" data-testid="AiIcon" id="test-id" + title="AiIcon" /> `; @@ -29,6 +30,7 @@ exports[`Icon onClick.loading true 1`] = ` class="emotion-0" data-testid="AiOutlineLoading3Quarters" id="test-id" + title="AiIcon" /> `; @@ -37,6 +39,7 @@ exports[`Icon properties string 1`] = ` class="emotion-0" data-testid="AiIcon" id="test-id" + title="AiIcon" /> `; @@ -45,6 +48,7 @@ exports[`Icon properties.name 1`] = ` class="emotion-0" data-testid="AiIcon" id="test-id" + title="AiIcon" /> `; @@ -54,6 +58,7 @@ exports[`Icon properties.name error 1`] = ` color="#F00" data-testid="AiOutlineExclamationCircle" id="test-id" + title="ErrorIcon" /> `; @@ -83,6 +88,7 @@ exports[`Icon properties.spin 1`] = ` class="emotion-0 emotion-1" data-testid="AiIcon" id="test-id" + title="AiIcon" /> `; @@ -95,5 +101,6 @@ exports[`Icon properties.style 1`] = ` class="emotion-0" data-testid="AiIcon" id="test-id" + title="AiIcon" /> `; diff --git a/packages/utils/node-utils/src/getConfigFromEnv.test.js b/packages/utils/node-utils/src/getConfigFromEnv.test.js index 4dd41c09e..e00bad158 100644 --- a/packages/utils/node-utils/src/getConfigFromEnv.test.js +++ b/packages/utils/node-utils/src/getConfigFromEnv.test.js @@ -27,7 +27,8 @@ test('Get config from env', () => { LOWDEFY_SERVER_BUILD_DIRECTORY: 'build', LOWDEFY_SERVER_PUBLIC_DIRECTORY: 'public', LOWDEFY_SERVER_PORT: '8080', - LOWDEFY_SERVER_BASE_PATH: 'base', + LOWDEFY_BASE_PATH: 'base', + LOWDEFY_SERVER_LOG_LEVEL: 'verbose', OTHER_VAR: 'other', ANOTHER_VAR: 'another', ASDF_GHJK: 'asdfghjk', @@ -35,6 +36,7 @@ test('Get config from env', () => { const config = getConfigFromEnv(); expect(config).toEqual({ buildDirectory: 'build', + logLevel: 'verbose', publicDirectory: 'public', port: 8080, basePath: 'base', diff --git a/yarn.lock b/yarn.lock index 39e68f408..1fcf7f619 100644 --- a/yarn.lock +++ b/yarn.lock @@ -960,7 +960,7 @@ __metadata: languageName: node linkType: hard -"@jest/core@npm:^27.4.7, @jest/core@npm:^27.5.1": +"@jest/core@npm:^27.5.1": version: 27.5.1 resolution: "@jest/core@npm:27.5.1" dependencies: @@ -1975,7 +1975,7 @@ __metadata: "@swc/cli": 0.1.55 "@swc/core": 1.2.135 "@swc/jest": 0.2.17 - jest: 27.4.7 + jest: 27.5.1 languageName: unknown linkType: soft @@ -2606,12 +2606,26 @@ __metadata: version: 0.0.0-use.local resolution: "@lowdefy/plugin-aws@workspace:packages/plugins/plugins/plugin-aws" dependencies: + "@emotion/jest": 11.7.1 "@lowdefy/ajv": 4.0.0-alpha.6 + "@lowdefy/block-dev": 4.0.0-alpha.6 + "@lowdefy/block-utils": 4.0.0-alpha.6 + "@lowdefy/blocks-antd": 4.0.0-alpha.6 + "@lowdefy/helpers": 4.0.0-alpha.6 "@swc/cli": 0.1.55 "@swc/core": 1.2.135 "@swc/jest": 0.2.17 + "@testing-library/dom": 8.11.3 + "@testing-library/react": 13.0.0-alpha.4 + "@testing-library/user-event": 14.0.0-alpha.14 + antd: 4.17.0-alpha.7 aws-sdk: 2.1066.0 + copyfiles: 2.4.1 jest: 27.5.1 + jest-serializer-html: 7.1.0 + jest-transform-yaml: 1.0.0 + react: 18.0.0-rc.0 + react-dom: 18.0.0-rc.0 languageName: unknown linkType: soft @@ -8560,7 +8574,7 @@ __metadata: languageName: node linkType: hard -"jest-cli@npm:^27.4.7, jest-cli@npm:^27.5.1": +"jest-cli@npm:^27.5.1": version: 27.5.1 resolution: "jest-cli@npm:27.5.1" dependencies: @@ -9011,24 +9025,6 @@ __metadata: languageName: node linkType: hard -"jest@npm:27.4.7": - version: 27.4.7 - resolution: "jest@npm:27.4.7" - dependencies: - "@jest/core": ^27.4.7 - import-local: ^3.0.2 - jest-cli: ^27.4.7 - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true - bin: - jest: bin/jest.js - checksum: 28ce948b30c074907393f37553acac4422d0f60190776e62b3403e4c742d33dd6012e3a20748254a43e38b5b4ce52d813b13a3a5be1d43d6d12429bd08ce1a23 - languageName: node - linkType: hard - "jest@npm:27.5.1": version: 27.5.1 resolution: "jest@npm:27.5.1"