diff --git a/components/nile_database/actions/create-user/create-user.mjs b/components/nile_database/actions/create-user/create-user.mjs index dcaf2e06c2c02..18920f39208d2 100644 --- a/components/nile_database/actions/create-user/create-user.mjs +++ b/components/nile_database/actions/create-user/create-user.mjs @@ -4,7 +4,7 @@ export default { key: "nile_database-create-user", name: "Create User", description: "Create a new database user by providing an email address and password. [See the documentation](https://www.thenile.dev/docs/reference/api-reference/users/create-user)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { nile, @@ -18,6 +18,9 @@ export default { propDefinition: [ nile, "database", + (c) => ({ + workspace: c.workspace, + }), ], }, email: { diff --git a/components/nile_database/actions/execute-query/execute-query.mjs b/components/nile_database/actions/execute-query/execute-query.mjs index 1b8c0ca926268..68c13f60a0d1b 100644 --- a/components/nile_database/actions/execute-query/execute-query.mjs +++ b/components/nile_database/actions/execute-query/execute-query.mjs @@ -4,7 +4,7 @@ export default { name: "Execute Query", key: "nile_database-execute-query", description: "Execute a custom PostgreSQL query.", - version: "0.0.1", + version: "0.0.2", type: "action", props: { nile, @@ -18,6 +18,9 @@ export default { propDefinition: [ nile, "database", + (c) => ({ + workspace: c.workspace, + }), ], }, user: { diff --git a/components/nile_database/nile_database.app.mjs b/components/nile_database/nile_database.app.mjs index 0bad4b5983bc6..0e58af09fada9 100644 --- a/components/nile_database/nile_database.app.mjs +++ b/components/nile_database/nile_database.app.mjs @@ -18,8 +18,13 @@ export default { type: "string", label: "Database", description: "The database name", - async options() { - const { databases } = await this.getAuthenticatedUser(); + async options({ workspace }) { + if (!workspace) { + return []; + } + const databases = await this.listDatabases({ + workspace, + }); return databases?.map(({ name }) => name) || []; }, }, @@ -68,6 +73,14 @@ export default { ...opts, }); }, + listDatabases({ + workspace, ...opts + }) { + return this._makeRequest({ + url: `${this._globalBaseUrl()}/workspaces/${workspace}/databases`, + ...opts, + }); + }, getAuthenticatedUser(opts = {}) { return this._makeRequest({ url: `${this._globalBaseUrl()}/developers/me/full`, diff --git a/components/nile_database/package.json b/components/nile_database/package.json index 1d24c129fc4a7..b948c4735f286 100644 --- a/components/nile_database/package.json +++ b/components/nile_database/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/nile_database", - "version": "0.1.0", + "version": "0.1.1", "description": "Pipedream Nile Database Components", "main": "nile_database.app.mjs", "keywords": [ diff --git a/components/nile_database/sources/common/base.mjs b/components/nile_database/sources/common/base.mjs index 9d43dfb69515b..3a787d79281f2 100644 --- a/components/nile_database/sources/common/base.mjs +++ b/components/nile_database/sources/common/base.mjs @@ -1,5 +1,7 @@ import nile from "../../nile_database.app.mjs"; -import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import { + DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, ConfigurationError, +} from "@pipedream/platform"; export default { props: { @@ -21,9 +23,24 @@ export default { propDefinition: [ nile, "database", + (c) => ({ + workspace: c.workspace, + }), ], }, }, + hooks: { + async deploy() { + try { + await this.nile.getDatabase({ + workspace: this.workspace, + database: this.database, + }); + } catch { + throw new ConfigurationError(`Database "${this.database}" with workspace "${this.workspace}" not found`); + } + }, + }, methods: { getResourceFn() { throw new Error("getResourceFn is not implemented"); diff --git a/components/nile_database/sources/new-tenant-created/new-tenant-created.mjs b/components/nile_database/sources/new-tenant-created/new-tenant-created.mjs index fb0cd1c0249e9..067cc870d5926 100644 --- a/components/nile_database/sources/new-tenant-created/new-tenant-created.mjs +++ b/components/nile_database/sources/new-tenant-created/new-tenant-created.mjs @@ -5,7 +5,7 @@ export default { key: "nile_database-new-tenant-created", name: "New Tenant Created", description: "Emit new event when a new tenant is added to a Nile Database", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: { diff --git a/components/nile_database/sources/new-user-created/new-user-created.mjs b/components/nile_database/sources/new-user-created/new-user-created.mjs index 2e7f3b6c29007..b37d2fcfe8b27 100644 --- a/components/nile_database/sources/new-user-created/new-user-created.mjs +++ b/components/nile_database/sources/new-user-created/new-user-created.mjs @@ -5,7 +5,7 @@ export default { key: "nile_database-new-user-created", name: "New User Created", description: "Emit new event when a new user is added in a Nile Database", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: {