Skip to content

Commit

Permalink
Merge branch 'master' into table-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aptkingston authored Jun 27, 2024
2 parents 6d1dd4f + b506d84 commit 778eed5
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 83 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/budibase_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,6 @@ jobs:
- run: yarn --frozen-lockfile

- name: Test server
env:
DD_CIVISIBILITY_AGENTLESS_ENABLED: true
DD_API_KEY: "${{ secrets.DATADOG_API_KEY }}"
DD_SITE: "datadoghq.eu"
NODE_OPTIONS: "-r dd-trace/ci/init"
DD_ENV: "ci"
DD_SERVICE: "budibase/packages/server"
run: |
if ${{ env.USE_NX_AFFECTED }}; then
yarn test --scope=@budibase/server --since=${{ env.NX_BASE_BRANCH }}
Expand Down Expand Up @@ -233,10 +226,11 @@ jobs:
if: ${{ steps.get_pro_commits.outputs.base_commit_excluding_merges != '' }}
run: |
cd packages/pro
base_commit='${{ steps.get_pro_commits.outputs.base_commit }}'
base_commit_excluding_merges='${{ steps.get_pro_commits.outputs.base_commit_excluding_merges }}'
pro_commit='${{ steps.get_pro_commits.outputs.pro_commit }}'
any_commit=$(git log --no-merges $base_commit_excluding_merges...$pro_commit)
any_commit=$(git log --no-merges $base_commit...$pro_commit)
if [ -n "$any_commit" ]; then
echo $any_commit
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-api-sales/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"@types/react": "17.0.39",
"eslint": "8.10.0",
"eslint-config-next": "12.1.0",
"typescript": "5.2.2"
"typescript": "5.5.2"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"proper-lockfile": "^4.1.2",
"svelte": "^4.2.10",
"svelte-eslint-parser": "^0.33.1",
"typescript": "5.2.2",
"typescript": "5.5.2",
"typescript-eslint": "^7.3.1",
"yargs": "^17.7.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/backend-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"prepack": "cp package.json dist",
"build": "tsc -p tsconfig.build.json --paths null && node ./scripts/build.js",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
"check:types": "tsc -p tsconfig.json --noEmit --paths null --target es2020",
"test": "bash scripts/test.sh",
"test:watch": "jest --watchAll"
},
Expand Down Expand Up @@ -79,7 +79,7 @@
"pouchdb-adapter-memory": "7.2.2",
"testcontainers": "^10.7.2",
"timekeeper": "2.2.0",
"typescript": "5.2.2"
"typescript": "5.5.2"
},
"nx": {
"targets": {
Expand Down
4 changes: 2 additions & 2 deletions packages/backend-core/src/sql/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ class InternalBuilder {
contains(filters.containsAny, true)
}

const tableRef = opts?.aliases?.[table._id!] || table._id
// when searching internal tables make sure long looking for rows
if (filters.documentType && !isExternalTable(table)) {
const tableRef = opts?.aliases?.[table._id!] || table._id
if (filters.documentType && !isExternalTable(table) && tableRef) {
// has to be its own option, must always be AND onto the search
query.andWhereLike(
`${tableRef}._id`,
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"tsc": "node ../../scripts/build.js",
"build": "yarn tsc",
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
"check:types": "tsc -p tsconfig.json --noEmit --paths null --target es2020",
"start": "ts-node ./src/index.ts"
},
"dependencies": {
Expand Down Expand Up @@ -40,6 +40,6 @@
"@types/node-fetch": "2.6.4",
"@types/pouchdb": "^6.4.0",
"ts-node": "10.8.1",
"typescript": "5.2.2"
"typescript": "5.5.2"
}
}
26 changes: 14 additions & 12 deletions packages/client/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@
{ "type": "bigint", "message": "stringAsNumber" },
{ "type": "options", "message": "stringAsNumber" },
{ "type": "formula", "message": "stringAsNumber" },
{ "type": "datetime", "message": "dateAsNumber"}
{ "type": "datetime", "message": "dateAsNumber" }
],
"unsupported": [
{ "type": "json", "message": "jsonPrimitivesOnly" }
]
"unsupported": [{ "type": "json", "message": "jsonPrimitivesOnly" }]
},
"stringLike": {
"supported": ["string", "number", "bigint", "options", "longform", "boolean", "datetime"],
"unsupported": [
{ "type": "json", "message": "jsonPrimitivesOnly" }
]
"supported": [
"string",
"number",
"bigint",
"options",
"longform",
"boolean",
"datetime"
],
"unsupported": [{ "type": "json", "message": "jsonPrimitivesOnly" }]
},
"datetimeLike": {
"supported": ["datetime"],
Expand All @@ -43,11 +47,9 @@
{ "type": "options", "message": "stringAsDate" },
{ "type": "formula", "message": "stringAsDate" },
{ "type": "bigint", "message": "stringAsDate" },
{ "type": "number", "message": "numberAsDate"}
{ "type": "number", "message": "numberAsDate" }
],
"unsupported": [
{ "type": "json", "message": "jsonPrimitivesOnly" }
]
"unsupported": [{ "type": "json", "message": "jsonPrimitivesOnly" }]
}
},
"layout": {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/components/preview/SettingsBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
allSettings.push(setting)
}
})
return allSettings.filter(setting => setting.showInBar)
return allSettings.filter(setting => setting.showInBar && !setting.hidden)
}
const updatePosition = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/pro
Submodule pro updated from 6c8d01 to e8f2c5
6 changes: 3 additions & 3 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"prebuild": "rimraf dist/",
"build": "node ./scripts/build.js",
"postbuild": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client && copyfiles -f ../../yarn.lock ./dist/",
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
"check:types": "tsc -p tsconfig.json --noEmit --paths null --target es2020",
"build:isolated-vm-lib:snippets": "esbuild --minify --bundle src/jsRunner/bundles/snippets.ts --outfile=src/jsRunner/bundles/snippets.ivm.bundle.js --platform=node --format=iife --global-name=snippets",
"build:isolated-vm-lib:string-templates": "esbuild --minify --bundle src/jsRunner/bundles/index-helpers.ts --outfile=src/jsRunner/bundles/index-helpers.ivm.bundle.js --platform=node --format=iife --external:handlebars --global-name=helpers",
"build:isolated-vm-lib:bson": "esbuild --minify --bundle src/jsRunner/bundles/bsonPackage.ts --outfile=src/jsRunner/bundles/bson.ivm.bundle.js --platform=node --format=iife --global-name=bson",
Expand Down Expand Up @@ -99,7 +99,7 @@
"mysql2": "3.9.8",
"node-fetch": "2.6.7",
"object-sizeof": "2.6.1",
"openai": "^3.2.1",
"openai": "^4.52.1",
"openapi-types": "9.3.1",
"pg": "8.10.0",
"pouchdb": "7.3.0",
Expand Down Expand Up @@ -152,7 +152,7 @@
"timekeeper": "2.2.0",
"ts-node": "10.8.1",
"tsconfig-paths": "4.0.0",
"typescript": "5.2.2",
"typescript": "5.5.2",
"update-dotenv": "1.1.1",
"yargs": "13.2.4"
},
Expand Down
12 changes: 5 additions & 7 deletions packages/server/src/automations/steps/openai.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Configuration, OpenAIApi } from "openai"
import { OpenAI } from "openai"

import {
AutomationActionStepId,
AutomationStepSchema,
Expand Down Expand Up @@ -75,13 +76,11 @@ export async function run({ inputs }: AutomationStepInput) {
}

try {
const configuration = new Configuration({
const openai = new OpenAI({
apiKey: environment.OPENAI_API_KEY,
})

const openai = new OpenAIApi(configuration)

const completion = await openai.createChatCompletion({
const completion = await openai.chat.completions.create({
model: inputs.model,
messages: [
{
Expand All @@ -90,8 +89,7 @@ export async function run({ inputs }: AutomationStepInput) {
},
],
})

const response = completion?.data?.choices[0]?.message?.content
const response = completion?.choices[0]?.message?.content

return {
response,
Expand Down
44 changes: 22 additions & 22 deletions packages/server/src/automations/tests/openai.spec.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
const setup = require("./utilities")

import environment from "../../environment"
import openai from "openai"
import { OpenAI } from "openai"

jest.mock(
"openai",
jest.fn(() => ({
Configuration: jest.fn(),
OpenAIApi: jest.fn(() => ({
createChatCompletion: jest.fn(() => ({
data: {
jest.mock("openai", () => ({
OpenAI: jest.fn().mockImplementation(() => ({
chat: {
completions: {
create: jest.fn(() => ({
choices: [
{
message: {
content: "This is a test",
},
},
],
},
})),
})),
}))
)
})),
},
},
})),
}))

const mockedOpenAIApi = openai.OpenAIApi as jest.MockedClass<
typeof openai.OpenAIApi
>
const mockedOpenAI = OpenAI as jest.MockedClass<typeof OpenAI>

const OPENAI_PROMPT = "What is the meaning of life?"

Expand Down Expand Up @@ -73,14 +69,18 @@ describe("test the openai action", () => {
})

it("should present the correct error message when an error is thrown from the createChatCompletion call", async () => {
mockedOpenAIApi.mockImplementation(
mockedOpenAI.mockImplementation(
() =>
({
createChatCompletion: jest.fn(() => {
throw new Error(
"An error occurred while calling createChatCompletion"
)
}),
chat: {
completions: {
create: jest.fn(() => {
throw new Error(
"An error occurred while calling createChatCompletion"
)
}),
},
},
} as any)
)

Expand Down
1 change: 0 additions & 1 deletion packages/server/src/utilities/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export function validate(rows: Rows, schema: TableSchema): ValidationResults {
} else if (
// If there's no data for this field don't bother with further checks
// If the field is already marked as invalid there's no need for further checks
results.schemaValidation[columnName] === false ||
columnData == null ||
isAutoColumn
) {
Expand Down
4 changes: 2 additions & 2 deletions packages/shared-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
"check:types": "tsc -p tsconfig.json --noEmit --paths null --target es2020",
"test": "jest",
"test:watch": "yarn test --watchAll"
},
Expand All @@ -21,7 +21,7 @@
},
"devDependencies": {
"rimraf": "3.0.2",
"typescript": "5.2.2"
"typescript": "5.5.2"
},
"nx": {
"targets": {
Expand Down
12 changes: 8 additions & 4 deletions packages/shared-core/src/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,16 @@ export const buildQuery = (filter: SearchFilter[]) => {
query.equal = query.equal || {}
query.equal[field] = true
} else {
query[queryOperator] = query[queryOperator] || {}
query[queryOperator]![field] = value
query[queryOperator] = {
...query[queryOperator],
[field]: value,
}
}
} else {
query[queryOperator] = query[queryOperator] || {}
query[queryOperator]![field] = value
query[queryOperator] = {
...query[queryOperator],
[field]: value,
}
}
}
})
Expand Down
4 changes: 2 additions & 2 deletions packages/string-templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"scripts": {
"build": "tsc --emitDeclarationOnly && rollup -c",
"dev": "rollup -cw",
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
"check:types": "tsc -p tsconfig.json --noEmit --paths null --target es2020",
"test": "jest",
"manifest": "ts-node ./scripts/gen-collection-info.ts"
},
Expand All @@ -45,6 +45,6 @@
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "29.1.1",
"typescript": "5.2.2"
"typescript": "5.5.2"
}
}
4 changes: 2 additions & 2 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
"check:types": "tsc -p tsconfig.json --noEmit --paths null"
"check:types": "tsc -p tsconfig.json --noEmit --paths null --target es2020"
},
"jest": {},
"devDependencies": {
Expand All @@ -20,7 +20,7 @@
"@types/pouchdb": "6.4.0",
"@types/redlock": "4.0.7",
"rimraf": "3.0.2",
"typescript": "5.2.2"
"typescript": "5.5.2"
},
"dependencies": {
"scim-patch": "^0.8.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"prebuild": "rimraf dist/",
"build": "node ../../scripts/build.js",
"postbuild": "copyfiles -f ../../yarn.lock ./dist/",
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
"check:types": "tsc -p tsconfig.json --noEmit --paths null --target es2020",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"run:docker": "node dist/index.js",
"debug": "yarn build && node --expose-gc --inspect=9223 dist/index.js",
Expand Down Expand Up @@ -91,7 +91,7 @@
"rimraf": "3.0.2",
"supertest": "6.3.3",
"timekeeper": "2.2.0",
"typescript": "5.2.2",
"typescript": "5.5.2",
"update-dotenv": "1.1.1"
},
"nx": {
Expand Down
Loading

0 comments on commit 778eed5

Please sign in to comment.