From 458ccbd705192db8a03863a03693e185cb40cdd9 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 19 Apr 2023 22:33:28 +0530 Subject: [PATCH 01/28] chore: update actions to deploy nestjs backend Signed-off-by: Pranav C --- .github/workflows/release-docker.yml | 7 +++---- .github/workflows/release-npm.yml | 2 +- .github/workflows/release-pr.yml | 13 +++++++------ packages/nocodb-nest/package.json | 7 ++++--- scripts/upgradeNcGui.js | 14 +++++++------- scripts/upgradeNocodbSdk.js | 6 +++--- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index adc17aacee..a4915919be 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -43,7 +43,7 @@ jobs: buildx: runs-on: ubuntu-latest env: - working-directory: ./packages/nocodb + working-directory: ./packages/nocodb-nest steps: - name: Get Docker Repository id: get-docker-repository @@ -58,7 +58,7 @@ jobs: if [[ ${{ github.event.inputs.currentVersion || inputs.currentVersion || 'N/A' }} != 'N/A' ]]; then DOCKER_BUILD_TAG=${{ github.event.inputs.currentVersion || inputs.currentVersion }}-${{ github.event.inputs.tag || inputs.tag }} fi - if [[ ${{ inputs.isDaily || 'N' }} == 'Y' ]]; then + if [[ ${{ inputs.isDaily || 'N' }} == 'Y' ]]; then DOCKER_REPOSITORY=${DOCKER_REPOSITORY}-daily else DOCKER_REPOSITORY=${DOCKER_REPOSITORY}-timely @@ -90,7 +90,7 @@ jobs: cd packages/nocodb-sdk npm install && npm run build cd ../.. - targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNocodbSdk.js && + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNocodbSdk.js && targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} node scripts/bumpNcGuiVersion.js && cd packages/nc-gui npm install @@ -104,7 +104,6 @@ jobs: - name: Build nocodb and docker files run: | - npm run build npm run docker:build working-directory: ${{ env.working-directory }} diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 55ec46d9af..257ebab89b 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -35,7 +35,7 @@ jobs: release: runs-on: ubuntu-latest env: - working-directory: ./packages/nocodb + working-directory: ./packages/nocodb-nest steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index d29e6b7a17..0eb1a0393d 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -13,6 +13,7 @@ on: - "packages/nc-gui/**" - "packages/nc-plugin/**" - "packages/nocodb/**" + - "packages/nocodb-nest/**" concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -116,13 +117,13 @@ jobs: - name: Upload Rendered Compose File as Artifact uses: actions/upload-artifact@v3 with: - name: preview-spec + name: preview-spec path: docker-compose.rendered.yml retention-days: 2 - name: Serialize PR Event to File run: | cat << EOF > event.json - ${{ toJSON(github.event) }} + ${{ toJSON(github.event) }} EOF - name: Upload PR Event as Artifact uses: actions/upload-artifact@v3 @@ -130,7 +131,7 @@ jobs: name: preview-spec path: event.json retention-days: 2 - + # Add a comment for PR executable build # leave-executable-comment: # if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' && github.event.pull_request.draft == false && github.base_ref == 'develop' && github.event.action != 'closed' }} @@ -177,12 +178,12 @@ jobs: - name: Serialize PR Event to File run: | cat << EOF > event.json - ${{ toJSON(github.event) }} - + ${{ toJSON(github.event) }} + EOF - name: Upload PR Event as Artifact uses: actions/upload-artifact@v3 with: name: preview-spec path: event.json - retention-days: 2 \ No newline at end of file + retention-days: 2 diff --git a/packages/nocodb-nest/package.json b/packages/nocodb-nest/package.json index 955172eef8..664aa02987 100644 --- a/packages/nocodb-nest/package.json +++ b/packages/nocodb-nest/package.json @@ -1,7 +1,7 @@ { - "name": "nocodb-nest", - "version": "0.0.1", - "description": "NocoDB Backend (Nest)", + "name": "nocodb", + "version": "0.106.1", + "description": "NocoDB Backend", "main": "dist/bundle.js", "author": { "name": "NocoDB Inc", @@ -20,6 +20,7 @@ "scripts": { "build": "nest build", "build:obfuscate": "EE=true webpack --config webpack.config.js", + "obfuscate:build:publish": "npm run build:obfuscate && npm publish .", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "start": "nest start", "start:dev": "nest start --watch", diff --git a/scripts/upgradeNcGui.js b/scripts/upgradeNcGui.js index d984562bc9..b18eb53378 100644 --- a/scripts/upgradeNcGui.js +++ b/scripts/upgradeNcGui.js @@ -22,8 +22,8 @@ const replacePackageName = (filePath) => { const bumbVersionAndSave = () => { // upgrade nc-lib-gui version in nocodb - execSync(`cd packages/nocodb && npm install --save --save-exact ${ncLibPackage.name}@${ncLibPackage.version}`, {}); - const nocodbPackageFilePath = path.join(__dirname, '..', 'packages', 'nocodb', 'package.json') + execSync(`cd packages/nocodb-nest && npm install --save --save-exact ${ncLibPackage.name}@${ncLibPackage.version}`, {}); + const nocodbPackageFilePath = path.join(__dirname, '..', 'packages', 'nocodb-nest', 'package.json') const nocoLibPackage = JSON.parse(fs.readFileSync(nocodbPackageFilePath)) if (process.env.targetEnv === 'DEV') { nocoLibPackage.name = `${nocoLibPackage.name}-daily` @@ -35,11 +35,11 @@ const bumbVersionAndSave = () => { if (process.env.targetEnv === 'DEV') { // replace nc-lib-gui by nc-lib-gui-daily if it is nightly build / pr release const filePaths = [ - path.join(__dirname, '..', 'packages', 'nocodb', 'Dockerfile'), - path.join(__dirname, '..', 'packages', 'nocodb', 'litestream', 'Dockerfile'), - path.join(__dirname, '..', 'packages', 'nocodb', 'package.json'), - path.join(__dirname, '..', 'packages', 'nocodb', 'README.md'), - path.join(__dirname, '..', 'packages', 'nocodb', 'src', 'lib', 'Noco.ts'), + path.join(__dirname, '..', 'packages', 'nocodb-nest', 'Dockerfile'), + path.join(__dirname, '..', 'packages', 'nocodb-nest', 'litestream', 'Dockerfile'), + path.join(__dirname, '..', 'packages', 'nocodb-nest', 'package.json'), + path.join(__dirname, '..', 'packages', 'nocodb-nest', 'README.md'), + path.join(__dirname, '..', 'packages', 'nocodb-nest', 'src', 'lib', 'Noco.ts'), ] Promise.all(filePaths.map(filePath => { return replacePackageName(filePath) })).then(() => { bumbVersionAndSave(); diff --git a/scripts/upgradeNocodbSdk.js b/scripts/upgradeNocodbSdk.js index 5deb3d8d64..f031168df2 100644 --- a/scripts/upgradeNocodbSdk.js +++ b/scripts/upgradeNocodbSdk.js @@ -20,7 +20,7 @@ const replacePackageName = (filePath) => { const bumbVersionAndSave = () => { // upgrade nocodb-sdk version in nocodb - execSync(`cd packages/nocodb && npm install --save --save-exact ${nocodbSdkPackage.name}@${nocodbSdkPackage.version}`, {}); + execSync(`cd packages/nocodb-nest && npm install --save --save-exact ${nocodbSdkPackage.name}@${nocodbSdkPackage.version}`, {}); // upgrade nocodb-sdk version in nc-gui execSync(`cd packages/nc-gui && npm install --save --save-exact ${nocodbSdkPackage.name}@${nocodbSdkPackage.version}`, {}); } @@ -47,9 +47,9 @@ const dfs = function(dir) { const searchAndReplace = (target) => { let list = [ ...dfs(path.resolve(path.join(__dirname, '..', 'packages', 'nc-gui'))), - ...dfs(path.resolve(path.join(__dirname, '..', 'packages', 'nocodb'))), + ...dfs(path.resolve(path.join(__dirname, '..', 'packages', 'nocodb-nest'))), path.join(__dirname, '..', 'packages', 'nc-gui', 'package.json'), - path.join(__dirname, '..', 'packages', 'nocodb', 'package.json') + path.join(__dirname, '..', 'packages', 'nocodb-nest', 'package.json') ] return Promise.all(list.map(d => { return new Promise((resolve, reject) => { From 881fd04dbc3029727403b18a21c1fbeea4eb4db4 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 24 Apr 2023 19:23:50 +0800 Subject: [PATCH 02/28] feat(nc-gui): show body for v2 but not in EE --- packages/nc-gui/components/webhook/Editor.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/webhook/Editor.vue b/packages/nc-gui/components/webhook/Editor.vue index fe652c5dda..ebabf7809c 100644 --- a/packages/nc-gui/components/webhook/Editor.vue +++ b/packages/nc-gui/components/webhook/Editor.vue @@ -66,7 +66,9 @@ const hook = reactive< version: 'v2', }) -const urlTabKey = ref('params') +const isBodyShown = ref(hook.version === 'v1' || (hook.version === 'v2' && appInfo.ee)) + +const urlTabKey = ref(isBodyShown.value ? 'body' : 'params') const apps: Record = ref() @@ -596,7 +598,7 @@ onMounted(async () => { - + { -
+
Use context variable data to refer the record under consideration From 38188c3724d3750a820aa8c7c8a8cd8d2ae2f837 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 24 Apr 2023 19:24:28 +0800 Subject: [PATCH 03/28] feat(nocodb): revise constructWebHookData logic --- packages/nocodb-nest/src/helpers/webhookHelpers.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nocodb-nest/src/helpers/webhookHelpers.ts b/packages/nocodb-nest/src/helpers/webhookHelpers.ts index d259a3e646..c0fc56a448 100644 --- a/packages/nocodb-nest/src/helpers/webhookHelpers.ts +++ b/packages/nocodb-nest/src/helpers/webhookHelpers.ts @@ -1,6 +1,7 @@ import Handlebars from 'handlebars'; import { v4 as uuidv4 } from 'uuid'; import { Filter, HookLog } from '../models'; +import Noco from '../Noco'; import NcPluginMgrv2 from './NcPluginMgrv2'; import type { Column, FormView, Hook, Model, View } from '../models'; import type { HookLogType } from 'nocodb-sdk'; @@ -135,7 +136,7 @@ export async function validateCondition(filters: Filter[], data: any) { } export function constructWebHookData(hook, model, view, prevData, newData) { - if (hook.version === 'v2') { + if (hook.version === 'v2' && !Noco.isEE()) { // extend in the future - currently only support records const scope = 'records'; From 56ef3a40dfef9929f6767b413ab1456b2f31f014 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 24 Apr 2023 19:24:53 +0800 Subject: [PATCH 04/28] feat(nocodb): allow v2 and EE to use populateSamplePayload --- packages/nocodb-nest/src/services/hooks.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nocodb-nest/src/services/hooks.service.ts b/packages/nocodb-nest/src/services/hooks.service.ts index a13d534149..c0a4f2aa42 100644 --- a/packages/nocodb-nest/src/services/hooks.service.ts +++ b/packages/nocodb-nest/src/services/hooks.service.ts @@ -8,6 +8,7 @@ import { } from '../helpers/populateSamplePayload'; import { invokeWebhook } from '../helpers/webhookHelpers'; import { Hook, HookLog, Model } from '../models'; +import Noco from '../Noco'; import type { HookReqType, HookTestReqType, HookType } from 'nocodb-sdk'; @Injectable() @@ -107,7 +108,7 @@ export class HooksService { }) { const model = await Model.getByIdOrName({ id: param.tableId }); - if (param.version === 'v1') { + if (param.version === 'v1' || (param.version === 'v2' && Noco.isEE())) { return await populateSamplePayload(model, false, param.operation); } return await populateSamplePayloadV2(model, false, param.operation); From 44669680189ad79504548e75e80db2e8799c7d66 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 25 Apr 2023 11:46:39 +0800 Subject: [PATCH 05/28] fix(nocodb): allow reset the license key --- packages/nocodb-nest/src/schema/swagger.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/nocodb-nest/src/schema/swagger.json b/packages/nocodb-nest/src/schema/swagger.json index b4e9f6c9c5..dc1cfaae11 100644 --- a/packages/nocodb-nest/src/schema/swagger.json +++ b/packages/nocodb-nest/src/schema/swagger.json @@ -17087,7 +17087,6 @@ "description": "The license key", "example": "1234567890", "maxLength": 255, - "minLength": 10, "type": "string" } }, From 470206741a257715c82353c057ed1b7b41276add Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 25 Apr 2023 12:35:58 +0800 Subject: [PATCH 06/28] fix(nocodb): add missing liestream dockerfile --- packages/nocodb-nest/litestream/Dockerfile | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 packages/nocodb-nest/litestream/Dockerfile diff --git a/packages/nocodb-nest/litestream/Dockerfile b/packages/nocodb-nest/litestream/Dockerfile new file mode 100644 index 0000000000..82fba2d0fd --- /dev/null +++ b/packages/nocodb-nest/litestream/Dockerfile @@ -0,0 +1,100 @@ +FROM golang:alpine3.14 as lt + +WORKDIR /usr/src/ + +RUN apk add --no-cache git make musl-dev gcc + +# build litestream +RUN git clone https://github.com/benbjohnson/litestream.git litestream +RUN cd litestream ; go install ./cmd/litestream + +RUN cp $GOPATH/bin/litestream /usr/src/lt + + + +FROM node:12 as builder +WORKDIR /usr/src/app + +# Copy application dependency manifests to the container image. +# A wildcard is used to ensure both package.json AND package-lock.json are copied. +# Copying this separately prevents re-running npm ci on every code change. +COPY ./package*.json ./ +COPY ./docker/main.js ./docker/main.js +#COPY ./docker/start.sh /usr/src/appEntry/start.sh +COPY ./docker/start-litestream.sh /usr/src/appEntry/start.sh +# install production dependencies, +# reduce node_module size with modclean & removing sqlite deps, +# package built code into app.tar.gz & add execute permission to start.sh +RUN npm ci --production --quiet +RUN npx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**" --run +RUN rm -rf ./node_modules/sqlite3/deps +RUN tar -czf ../appEntry/app.tar.gz ./* +RUN chmod +x /usr/src/appEntry/start.sh + + + + +FROM alpine:3.14 + +#ENV AWS_ACCESS_KEY_ID= +#ENV AWS_SECRET_ACCESS_KEY= +#ENV AWS_BUCKET= + + + +#WORKDIR /usr/src/ +# +## Install go lang +#RUN apk add --no-cache git make musl-dev go +# +## Configure Go +#ENV GOROOT /usr/lib/go +#ENV GOPATH /go +#ENV PATH /go/bin:$PATH +# +#RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin +# +## build litestream +# +#RUN git clone https://github.com/benbjohnson/litestream.git litestream +#RUN cd litestream ; go install ./cmd/litestream + + +# Bug fix for segfault ( Convert PT_GNU_STACK program header into PT_PAX_FLAGS ) +#RUN apk --update --no-cache add paxctl \ +# && paxctl -cm $(which node) + +WORKDIR /usr/src/app + +ENV NC_DOCKER 0.6 +ENV PORT 8080 +ENV NC_TOOL_DIR=/usr/app/data/ + + +# Copy application dependency manifests to the container image. +# A wildcard is used to ensure both package.json AND package-lock.json are copied. +# Copying this separately prevents re-running npm install on every code change. +#COPY ./build/ ./build/ +#COPY ./docker/main.js ./docker/main.js +#COPY ./package.json ./ + +RUN apk --update --no-cache add \ + nodejs \ + tar + +# Copy litestream binary build +COPY --from=lt /usr/src/lt /usr/src/appEntry/litestream +# Copy packaged production code & main entry file +COPY --from=builder /usr/src/appEntry/ /usr/src/appEntry/ + + +# Run the web service on container startup. +#CMD [ "node", "docker/index.js" ] +ENTRYPOINT ["sh", "/usr/src/appEntry/start.sh"] + + + + + + + From 0fe9090ad7517efcac9660f381aecd0db2bb0901 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 26 Apr 2023 13:37:00 +0800 Subject: [PATCH 07/28] feat(nc-gui): add IsExpandedFormOpenInj --- packages/nc-gui/context/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/nc-gui/context/index.ts b/packages/nc-gui/context/index.ts index ff359ea77f..0ea07a931e 100644 --- a/packages/nc-gui/context/index.ts +++ b/packages/nc-gui/context/index.ts @@ -19,6 +19,7 @@ export const IsGridInj: InjectionKey> = Symbol('is-grid-injection') export const IsGalleryInj: InjectionKey> = Symbol('is-gallery-injection') export const IsKanbanInj: InjectionKey> = Symbol('is-kanban-injection') export const IsLockedInj: InjectionKey> = Symbol('is-locked-injection') +export const IsExpandedFormOpenInj: InjectionKey> = Symbol('is-expanded-form-open-injection') export const CellValueInj: InjectionKey> = Symbol('cell-value-injection') export const ActiveViewInj: InjectionKey> = Symbol('active-view-injection') export const ReadonlyInj: InjectionKey> = Symbol('readonly-injection') From 59f5b886ecd48b18ce2a7a7c49bdbaad5d2040fa Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 26 Apr 2023 13:37:04 +0800 Subject: [PATCH 08/28] fix(nc-gui): cellWrapperEl + provide IsExpandedFormOpenInj --- .../nc-gui/components/smartsheet/expanded-form/index.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/expanded-form/index.vue b/packages/nc-gui/components/smartsheet/expanded-form/index.vue index d1dc2d97f8..f03d3eb229 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/index.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/index.vue @@ -5,6 +5,7 @@ import type { Ref } from 'vue' import { CellClickHookInj, FieldsInj, + IsExpandedFormOpenInj, IsFormInj, IsKanbanInj, MetaInj, @@ -180,10 +181,14 @@ if (isKanban.value) { } } -const cellWrapperEl = ref() +provide(IsExpandedFormOpenInj, isExpanded) + +const cellWrapperEl = ref() onMounted(() => { - setTimeout(() => (cellWrapperEl.value?.querySelector('input,select,textarea') as HTMLInputElement)?.focus()) + setTimeout(() => { + cellWrapperEl.value?.$el?.querySelector('input,select,textarea')?.focus() + }, 300) }) const addNewRow = () => { From 7a5e76ed510dd26b2c0dc5b533ed1e923d832254 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 26 Apr 2023 13:46:56 +0800 Subject: [PATCH 09/28] fix(nc-gui): focus when expanded form not open --- packages/nc-gui/components/cell/Currency.vue | 6 ++++-- packages/nc-gui/components/cell/Decimal.vue | 6 ++++-- packages/nc-gui/components/cell/Duration.vue | 5 ++++- packages/nc-gui/components/cell/Email.vue | 6 ++++-- packages/nc-gui/components/cell/Float.vue | 6 ++++-- packages/nc-gui/components/cell/Integer.vue | 6 ++++-- packages/nc-gui/components/cell/Percent.vue | 8 ++++---- packages/nc-gui/components/cell/Text.vue | 8 ++++---- packages/nc-gui/components/cell/TextArea.vue | 6 ++++-- packages/nc-gui/components/cell/Url.vue | 5 ++++- 10 files changed, 40 insertions(+), 22 deletions(-) diff --git a/packages/nc-gui/components/cell/Currency.vue b/packages/nc-gui/components/cell/Currency.vue index ee025aa9a2..e2ea7a9e77 100644 --- a/packages/nc-gui/components/cell/Currency.vue +++ b/packages/nc-gui/components/cell/Currency.vue @@ -1,6 +1,6 @@