mirror of https://github.com/nocodb/nocodb
աɨռɢӄաօռɢ
2 years ago
committed by
GitHub
86 changed files with 26724 additions and 1247 deletions
@ -0,0 +1,62 @@ |
|||||||
|
name: 'PR to master branch from develop' |
||||||
|
|
||||||
|
on: |
||||||
|
# Triggered manually |
||||||
|
workflow_dispatch: |
||||||
|
inputs: |
||||||
|
tag: |
||||||
|
description: "Tag" |
||||||
|
required: true |
||||||
|
targetEnv: |
||||||
|
description: "Target Environment" |
||||||
|
required: true |
||||||
|
type: choice |
||||||
|
options: |
||||||
|
- DEV |
||||||
|
- PROD |
||||||
|
# Triggered by release-nocodb.yml |
||||||
|
workflow_call: |
||||||
|
inputs: |
||||||
|
tag: |
||||||
|
description: "Tag" |
||||||
|
required: true |
||||||
|
type: string |
||||||
|
targetEnv: |
||||||
|
description: "Target Environment" |
||||||
|
required: true |
||||||
|
type: string |
||||||
|
|
||||||
|
jobs: |
||||||
|
pr-to-master: |
||||||
|
runs-on: ubuntu-latest |
||||||
|
steps: |
||||||
|
- run: | |
||||||
|
echo 'triggering pr-to-master' |
||||||
|
- name: Checkout |
||||||
|
uses: actions/checkout@v2 |
||||||
|
with: |
||||||
|
ref: develop |
||||||
|
|
||||||
|
- name: Create Pull Request |
||||||
|
if: ${{ github.event.inputs.targetEnv == 'PROD' || inputs.targetEnv == 'PROD' }} |
||||||
|
id: cpr |
||||||
|
uses: repo-sync/pull-request@v2 |
||||||
|
env: |
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
||||||
|
with: |
||||||
|
source_branch: "develop" |
||||||
|
destination_branch: "master" |
||||||
|
pr_title: '${{ github.event.inputs.tag || inputs.tag }} Pre-release' |
||||||
|
pr_label: 'Bot: Automated PR,Bot: Automerge' |
||||||
|
- name: Check outputs |
||||||
|
if: ${{ github.event.inputs.targetEnv == 'PROD' || inputs.targetEnv == 'PROD' }} |
||||||
|
run: | |
||||||
|
echo "Pull Request Number - ${{ steps.cpr.outputs.pr_number }}" |
||||||
|
echo "Pull Request URL - ${{ steps.cpr.outputs.pr_url }}" |
||||||
|
- name: automerge |
||||||
|
if: ${{ github.event.inputs.targetEnv == 'PROD' || inputs.targetEnv == 'PROD' }} |
||||||
|
uses: "pascalgn/automerge-action@v0.14.3" |
||||||
|
env: |
||||||
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
||||||
|
PULL_REQUEST: "${{ steps.cpr.outputs.pr_number }}" |
||||||
|
MERGE_LABELS: "Bot: Automerge" |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,99 @@ |
|||||||
|
import View from '../../../../noco-models/View'; |
||||||
|
import { isSystemColumn, UITypes } from 'nocodb-sdk'; |
||||||
|
import Model from '../../../../noco-models/Model'; |
||||||
|
import LinkToAnotherRecordColumn from '../../../../noco-models/LinkToAnotherRecordColumn'; |
||||||
|
|
||||||
|
const getAst = async ({ |
||||||
|
query, |
||||||
|
extractOnlyPrimaries = false, |
||||||
|
includePkByDefault = true, |
||||||
|
model, |
||||||
|
view |
||||||
|
}: { |
||||||
|
query?: RequestQuery; |
||||||
|
extractOnlyPrimaries?: boolean; |
||||||
|
includePkByDefault?: boolean; |
||||||
|
model: Model; |
||||||
|
view?: View; |
||||||
|
}) => { |
||||||
|
if (!model.columns?.length) await model.getColumns(); |
||||||
|
if (extractOnlyPrimaries) { |
||||||
|
return { |
||||||
|
[model.primaryKey.title]: 1, |
||||||
|
[model.primaryValue.title]: 1 |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
let fields = query?.fields || query?.f; |
||||||
|
if (fields && fields !== '*') { |
||||||
|
fields = Array.isArray(fields) ? fields : fields.split(','); |
||||||
|
} else { |
||||||
|
fields = null; |
||||||
|
} |
||||||
|
|
||||||
|
let allowedCols = null; |
||||||
|
if (view) |
||||||
|
allowedCols = (await View.getColumns(view.id)).reduce( |
||||||
|
(o, c) => ({ |
||||||
|
...o, |
||||||
|
[c.fk_column_id]: c.show |
||||||
|
}), |
||||||
|
{} |
||||||
|
); |
||||||
|
|
||||||
|
return model.columns.reduce(async (obj, col) => { |
||||||
|
let value: number | boolean | { [key: string]: any } = 1; |
||||||
|
const nestedFields = |
||||||
|
query?.nested?.[col.title]?.fields || query?.nested?.[col.title]?.f; |
||||||
|
if (nestedFields && nestedFields !== '*') { |
||||||
|
if (col.uidt === UITypes.LinkToAnotherRecord) { |
||||||
|
const model = await col |
||||||
|
.getColOptions<LinkToAnotherRecordColumn>() |
||||||
|
.then(colOpt => colOpt.getRelatedTable()); |
||||||
|
|
||||||
|
value = await getAst({ |
||||||
|
model, |
||||||
|
query: query?.nested?.[col.title] |
||||||
|
}); |
||||||
|
} else { |
||||||
|
value = (Array.isArray(fields) ? fields : fields.split(',')).reduce( |
||||||
|
(o, f) => ({ ...o, [f]: 1 }), |
||||||
|
{} |
||||||
|
); |
||||||
|
} |
||||||
|
} else if (col.uidt === UITypes.LinkToAnotherRecord) { |
||||||
|
const model = await col |
||||||
|
.getColOptions<LinkToAnotherRecordColumn>() |
||||||
|
.then(colOpt => colOpt.getRelatedTable()); |
||||||
|
|
||||||
|
value = await getAst({ |
||||||
|
model, |
||||||
|
query: query?.nested, |
||||||
|
extractOnlyPrimaries: true |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
return { |
||||||
|
...(await obj), |
||||||
|
[col.title]: |
||||||
|
allowedCols && (!includePkByDefault || !col.pk) |
||||||
|
? allowedCols[col.id] && |
||||||
|
(!isSystemColumn(col) || view.show_system_fields) && |
||||||
|
(!fields?.length || fields.includes(col.title)) && |
||||||
|
value |
||||||
|
: fields?.length |
||||||
|
? fields.includes(col.title) |
||||||
|
: value |
||||||
|
}; |
||||||
|
}, Promise.resolve({})); |
||||||
|
}; |
||||||
|
|
||||||
|
type RequestQuery = { |
||||||
|
[fields in 'f' | 'fields']?: string | string[]; |
||||||
|
} & { |
||||||
|
nested?: { |
||||||
|
[field: string]: RequestQuery; |
||||||
|
}; |
||||||
|
}; |
||||||
|
|
||||||
|
export default getAst; |
File diff suppressed because one or more lines are too long
@ -0,0 +1,19 @@ |
|||||||
|
import { Request } from 'express'; |
||||||
|
import { Tele } from 'nc-help'; |
||||||
|
|
||||||
|
const countMap = {}; |
||||||
|
|
||||||
|
const metrics = async (req: Request) => { |
||||||
|
if (!req?.route?.path) return; |
||||||
|
const event = `a:api:${req.route.path}:${req.method}`; |
||||||
|
countMap[event] = (countMap[event] || 0) + 1; |
||||||
|
if (countMap[event] >= 50) { |
||||||
|
Tele.event({ event }); |
||||||
|
countMap[event] = 0; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
export default async (req: Request, _res, next) => { |
||||||
|
metrics(req).then(() => {}); |
||||||
|
next(); |
||||||
|
}; |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue