diff --git a/packages/backend-core/src/environment.js b/packages/backend-core/src/environment.js index 527760c1ca..d4a6b4a3af 100644 --- a/packages/backend-core/src/environment.js +++ b/packages/backend-core/src/environment.js @@ -30,6 +30,12 @@ module.exports = { COOKIE_DOMAIN: process.env.COOKIE_DOMAIN, PLATFORM_URL: process.env.PLATFORM_URL, TENANT_FEATURE_FLAGS: process.env.TENANT_FEATURE_FLAGS, + BACKUPS_BUCKET_NAME: process.env.BACKUPS_BUCKET_NAME || "backups", + APPS_BUCKET_NAME: process.env.APPS_BUCKET_NAME || "prod-budi-app-assets", + TEMPLATES_BUCKET_NAME: process.env.TEMPLATES_BUCKET_NAME || "templates", + GLOBAL_BUCKET_NAME: process.env.GLOBAL_BUCKET_NAME || "global", + GLOBAL_CLOUD_BUCKET_NAME: + process.env.GLOBAL_CLOUD_BUCKET_NAME || "prod-budi-tenant-uploads", isTest, _set(key, value) { process.env[key] = value diff --git a/packages/backend-core/src/objectStore/utils.js b/packages/backend-core/src/objectStore/utils.js index 1634a24981..a243553df8 100644 --- a/packages/backend-core/src/objectStore/utils.js +++ b/packages/backend-core/src/objectStore/utils.js @@ -1,12 +1,13 @@ const { join } = require("path") const { tmpdir } = require("os") +const env = require("../environment") exports.ObjectStoreBuckets = { - BACKUPS: "backups", - APPS: "prod-budi-app-assets", - TEMPLATES: "templates", - GLOBAL: "global", - GLOBAL_CLOUD: "prod-budi-tenant-uploads", + BACKUPS: env.BACKUPS_BUCKET_NAME, + APPS: env.APPS_BUCKET_NAME, + TEMPLATES: env.TEMPLATES_BUCKET_NAME, + GLOBAL: env.GLOBAL_BUCKET_NAME, + GLOBAL_CLOUD: env.GLOBAL_CLOUD_BUCKET_NAME, } exports.budibaseTempDir = function () { diff --git a/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte b/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte index dd3b37fce5..a4b06f45a2 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte @@ -47,7 +47,7 @@ diff --git a/packages/server/__mocks__/pg.ts b/packages/server/__mocks__/pg.ts index af2ae24a97..5f8a133134 100644 --- a/packages/server/__mocks__/pg.ts +++ b/packages/server/__mocks__/pg.ts @@ -17,18 +17,9 @@ module PgMock { Client.prototype.connect = jest.fn() Client.prototype.release = jest.fn() - function Pool() {} - const on = jest.fn() - Pool.prototype.query = query - Pool.prototype.connect = jest.fn(() => { - // @ts-ignore - return new Client() - }) - Pool.prototype.on = on pg.Client = Client - pg.Pool = Pool pg.queryMock = query pg.on = on diff --git a/packages/server/src/integrations/index.ts b/packages/server/src/integrations/index.ts index 711e9d2262..f3e7a5fc3a 100644 --- a/packages/server/src/integrations/index.ts +++ b/packages/server/src/integrations/index.ts @@ -46,6 +46,7 @@ const INTEGRATIONS = { [SourceNames.FIREBASE]: firebase.integration, [SourceNames.GOOGLE_SHEETS]: googlesheets.integration, [SourceNames.REDIS]: redis.integration, + [SourceNames.FIREBASE]: firebase.integration, } // optionally add oracle integration if the oracle binary can be installed diff --git a/packages/server/src/integrations/tests/firebase.spec.js b/packages/server/src/integrations/tests/firebase.spec.js new file mode 100644 index 0000000000..369ed896a8 --- /dev/null +++ b/packages/server/src/integrations/tests/firebase.spec.js @@ -0,0 +1,103 @@ +const { Firestore } = require("@google-cloud/firestore") +const FirebaseIntegration = require("../firebase") +jest.mock("@google-cloud/firestore") + +class TestConfiguration { + constructor(config = {}) { + this.integration = new FirebaseIntegration.integration(config) + } +} + +describe("Firebase Integration", () => { + let config + let tableName = "Users" + + beforeEach(() => { + config = new TestConfiguration() + }) + + it("calls the create method with the correct params", async () => { + const response = await config.integration.create({ + table: tableName, + json: { + Name: "John" + } + }) + expect(config.integration.client.put).toHaveBeenCalledWith({ + TableName: tableName, + Name: "John" + }) + }) + + it("calls the read method with the correct params", async () => { + const indexName = "Test" + + const response = await config.integration.read({ + table: tableName, + index: indexName, + json: {} + }) + expect(config.integration.client.query).toHaveBeenCalledWith({ + TableName: tableName, + IndexName: indexName, + }) + expect(response).toEqual([]) + }) + + it("calls the scan method with the correct params", async () => { + const indexName = "Test" + + const response = await config.integration.scan({ + table: tableName, + index: indexName, + json: {} + }) + expect(config.integration.client.scan).toHaveBeenCalledWith({ + TableName: tableName, + IndexName: indexName, + }) + expect(response).toEqual([{ + Name: "test" + }]) + }) + + it("calls the get method with the correct params", async () => { + const response = await config.integration.get({ + table: tableName, + json: { + Id: 123 + } + }) + + expect(config.integration.client.get).toHaveBeenCalledWith({ + TableName: tableName, + Id: 123 + }) + }) + + it("calls the update method with the correct params", async () => { + const response = await config.integration.update({ + table: tableName, + json: { + Name: "John" + } + }) + expect(config.integration.client.update).toHaveBeenCalledWith({ + TableName: tableName, + Name: "John" + }) + }) + + it("calls the delete method with the correct params", async () => { + const response = await config.integration.delete({ + table: tableName, + json: { + Name: "John" + } + }) + expect(config.integration.client.delete).toHaveBeenCalledWith({ + TableName: tableName, + Name: "John" + }) + }) +}) \ No newline at end of file diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 4537e7efb8..6c15b0d61f 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1014,10 +1014,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.0.105-alpha.40": - version "1.0.105-alpha.40" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.105-alpha.40.tgz#7e8e3c548d09001a002364d2a9fa4dabf2d1bcce" - integrity sha512-lOUJx5yFAcBld+SNwbO1hUV2ucM2J+Y4AIG0BQeNH2kPul74sHlZpEocbmNu+R88NgKinTLcnB0wCdoD0MP+4g== +"@budibase/backend-core@1.0.105-alpha.42": + version "1.0.105-alpha.42" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.105-alpha.42.tgz#732daf9234312261c91158303459bb02f95656e0" + integrity sha512-takLU6UcUVVzcF8EZEazxmY37Th8DwjG8CEtBrlYZn+yrAO+27XixOws72P+6Xr9IxGyAWxMpIQ8E5uZi6Zl9w== dependencies: "@techpass/passport-openidconnect" "^0.3.0" aws-sdk "^2.901.0" @@ -1087,12 +1087,12 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.0.105-alpha.40": - version "1.0.105-alpha.40" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.105-alpha.40.tgz#155952a2645b547cb974a3c1bccb17f3075849e2" - integrity sha512-qrd7vxBkLcLoxWVtakg1P8M7NZUVM5d/ROveUsS1pDAVQndiI8fVrc7YeOfIiHmqdaFQXbwp9tn6ZviMuihVsA== +"@budibase/pro@1.0.105-alpha.42": + version "1.0.105-alpha.42" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.105-alpha.42.tgz#b616b24d9008c268f87b532b89493670d5a0a915" + integrity sha512-ibiJRm+22B4t8XZVkDQz8RU8Jd3XSS0M0K8vLRqdFaB632Vt/dnnMx6GbUvurjSfqxsa72R2+jNOME64oUl0Gg== dependencies: - "@budibase/backend-core" "1.0.105-alpha.40" + "@budibase/backend-core" "1.0.105-alpha.42" node-fetch "^2.6.1" "@budibase/standard-components@^0.9.139":