Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion components/nile_database/actions/create-user/create-user.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -18,6 +18,9 @@ export default {
propDefinition: [
nile,
"database",
(c) => ({
workspace: c.workspace,
}),
],
},
email: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -18,6 +18,9 @@ export default {
propDefinition: [
nile,
"database",
(c) => ({
workspace: c.workspace,
}),
],
},
user: {
Expand Down
17 changes: 15 additions & 2 deletions components/nile_database/nile_database.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) || [];
},
},
Expand Down Expand Up @@ -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`,
Expand Down
2 changes: 1 addition & 1 deletion components/nile_database/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
19 changes: 18 additions & 1 deletion components/nile_database/sources/common/base.mjs
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading