From d2cd1e60c1483620302e643fa2afc26e7fad03d6 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Thu, 5 Sep 2024 12:49:44 -0300 Subject: [PATCH 1/9] Added actions --- components/xata/app/xata.app.ts | 13 ------------- components/xata/package.json | 7 +++---- 2 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 components/xata/app/xata.app.ts diff --git a/components/xata/app/xata.app.ts b/components/xata/app/xata.app.ts deleted file mode 100644 index a73142b8024ce..0000000000000 --- a/components/xata/app/xata.app.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineApp } from "@pipedream/types"; - -export default defineApp({ - type: "app", - app: "xata", - propDefinitions: {}, - methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); - }, - }, -}); diff --git a/components/xata/package.json b/components/xata/package.json index 4c2a8b50f0adc..57c53819e44e1 100644 --- a/components/xata/package.json +++ b/components/xata/package.json @@ -1,13 +1,12 @@ { "name": "@pipedream/xata", - "version": "0.0.2", - "description": "Pipedream Xata Components", - "main": "dist/app/xata.app.mjs", + "version": "0.1.0", + "description": "Pipedream xata Components", + "main": "xata.app.mjs", "keywords": [ "pipedream", "xata" ], - "files": ["dist"], "homepage": "https://pipedream.com/apps/xata", "author": "Pipedream (https://pipedream.com/)", "publishConfig": { From 76cc37e843018c8cfd0399d11b6a822577c0806f Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Thu, 5 Sep 2024 15:12:30 -0300 Subject: [PATCH 2/9] Added actions --- components/xata/.gitignore | 3 - .../actions/create-record/create-record.mjs | 69 ++++++++ .../actions/list-branches/list-branches.mjs | 44 ++++++ .../actions/replace-record/replace-record.mjs | 76 +++++++++ .../actions/update-record/update-record.mjs | 76 +++++++++ components/xata/xata.app.mjs | 148 ++++++++++++++++++ 6 files changed, 413 insertions(+), 3 deletions(-) delete mode 100644 components/xata/.gitignore create mode 100644 components/xata/actions/create-record/create-record.mjs create mode 100644 components/xata/actions/list-branches/list-branches.mjs create mode 100644 components/xata/actions/replace-record/replace-record.mjs create mode 100644 components/xata/actions/update-record/update-record.mjs create mode 100644 components/xata/xata.app.mjs diff --git a/components/xata/.gitignore b/components/xata/.gitignore deleted file mode 100644 index ec761ccab7595..0000000000000 --- a/components/xata/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.mjs -dist \ No newline at end of file diff --git a/components/xata/actions/create-record/create-record.mjs b/components/xata/actions/create-record/create-record.mjs new file mode 100644 index 0000000000000..a996a2d1e7b0f --- /dev/null +++ b/components/xata/actions/create-record/create-record.mjs @@ -0,0 +1,69 @@ +import app from "../../xata.app.mjs"; + +export default { + key: "xata-create-record", + name: "Create Record", + description: "Create a new Record in the specified database. [See the documentation](https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data#insert-record)", + version: "0.0.1", + type: "action", + props: { + app, + endpoint: { + propDefinition: [ + app, + "endpoint", + ], + }, + workspace: { + propDefinition: [ + app, + "workspace", + ], + }, + database: { + propDefinition: [ + app, + "database", + (c) => ({ + workspace: c.workspace, + }), + ], + }, + branch: { + propDefinition: [ + app, + "branch", + (c) => ({ + endpoint: c.endpoint, + database: c.database, + }), + ], + }, + table: { + propDefinition: [ + app, + "table", + ], + }, + recordData: { + propDefinition: [ + app, + "recordData", + ], + }, + }, + async run({ $ }) { + const response = await this.app.createRecord({ + $, + endpoint: this.endpoint, + database: this.database, + branch: this.branch, + table: this.table, + data: this.recordData, + }); + + $.export("$summary", `Successfully created Record with ID: '${response.id}'`); + + return response; + }, +}; diff --git a/components/xata/actions/list-branches/list-branches.mjs b/components/xata/actions/list-branches/list-branches.mjs new file mode 100644 index 0000000000000..f8c0f69a3570d --- /dev/null +++ b/components/xata/actions/list-branches/list-branches.mjs @@ -0,0 +1,44 @@ +import app from "../../xata.app.mjs"; + +export default { + key: "xata-list-branches", + name: "List Branches", + description: "List branches of the specified database. [See the documentation](https://xata.io/docs/api-reference/dbs/db_name#list-branches)", + version: "0.0.1", + type: "action", + props: { + app, + endpoint: { + propDefinition: [ + app, + "endpoint", + ], + }, + workspace: { + propDefinition: [ + app, + "workspace", + ], + }, + database: { + propDefinition: [ + app, + "database", + (c) => ({ + workspace: c.workspace, + }), + ], + }, + }, + async run({ $ }) { + const response = await this.app.listBranches({ + $, + endpoint: this.endpoint, + database: this.database, + }); + + $.export("$summary", `Successfully retrieved '${response.branchse.length}' branches`); + + return response; + }, +}; diff --git a/components/xata/actions/replace-record/replace-record.mjs b/components/xata/actions/replace-record/replace-record.mjs new file mode 100644 index 0000000000000..57ff34dd0ac63 --- /dev/null +++ b/components/xata/actions/replace-record/replace-record.mjs @@ -0,0 +1,76 @@ +import app from "../../xata.app.mjs"; + +export default { + key: "xata-replace-record", + name: "Replace Record", + description: "Replace a record with the specified ID. [See the documentation](https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data/record_id#insert-record-with-id)", + version: "0.0.1", + type: "action", + props: { + app, + endpoint: { + propDefinition: [ + app, + "endpoint", + ], + }, + workspace: { + propDefinition: [ + app, + "workspace", + ], + }, + database: { + propDefinition: [ + app, + "database", + (c) => ({ + workspace: c.workspace, + }), + ], + }, + branch: { + propDefinition: [ + app, + "branch", + (c) => ({ + endpoint: c.endpoint, + database: c.database, + }), + ], + }, + table: { + propDefinition: [ + app, + "table", + ], + }, + recordId: { + propDefinition: [ + app, + "recordId", + ], + }, + recordData: { + propDefinition: [ + app, + "recordData", + ], + }, + }, + async run({ $ }) { + const response = await this.app.replaceRecord({ + $, + endpoint: this.endpoint, + database: this.database, + branch: this.branch, + table: this.table, + recordId: this.recordId, + data: this.recordData, + }); + + $.export("$summary", `Successfully replaced Record with ID: '${response.id}'`); + + return response; + }, +}; diff --git a/components/xata/actions/update-record/update-record.mjs b/components/xata/actions/update-record/update-record.mjs new file mode 100644 index 0000000000000..9720ff079ff6c --- /dev/null +++ b/components/xata/actions/update-record/update-record.mjs @@ -0,0 +1,76 @@ +import app from "../../xata.app.mjs"; + +export default { + key: "xata-update-record", + name: "Update Record", + description: "Update or create a record with the specified ID. [See the documentation](https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data/record_id#upsert-record-with-id)", + version: "0.0.1", + type: "action", + props: { + app, + endpoint: { + propDefinition: [ + app, + "endpoint", + ], + }, + workspace: { + propDefinition: [ + app, + "workspace", + ], + }, + database: { + propDefinition: [ + app, + "database", + (c) => ({ + workspace: c.workspace, + }), + ], + }, + branch: { + propDefinition: [ + app, + "branch", + (c) => ({ + endpoint: c.endpoint, + database: c.database, + }), + ], + }, + table: { + propDefinition: [ + app, + "table", + ], + }, + recordId: { + propDefinition: [ + app, + "recordId", + ], + }, + recordData: { + propDefinition: [ + app, + "recordData", + ], + }, + }, + async run({ $ }) { + const response = await this.app.updateRecord({ + $, + endpoint: this.endpoint, + database: this.database, + branch: this.branch, + table: this.table, + recordId: this.recordId, + data: this.recordData, + }); + + $.export("$summary", `Successfully updated/created Record with ID: '${response.id}'`); + + return response; + }, +}; diff --git a/components/xata/xata.app.mjs b/components/xata/xata.app.mjs new file mode 100644 index 0000000000000..8f1e4ccdfc659 --- /dev/null +++ b/components/xata/xata.app.mjs @@ -0,0 +1,148 @@ +import { axios } from "@pipedream/platform"; + +export default { + type: "app", + app: "xata", + propDefinitions: { + recordId: { + type: "string", + label: "Record ID", + description: "ID of the record to create or update", + }, + table: { + type: "string", + label: "Table Name", + description: "Name of the table", + }, + endpoint: { + type: "string", + label: "HTTP Endpoint", + description: "The endpoint of your database, i.e.: `https://my-workspace-123456.us-east-1.xata.sh`. You can find your workspace domain by navigating to the Configuration tab in the Xata Web UI", + }, + recordData: { + type: "object", + label: "Record Data", + description: "The key and value of the data that will be recorded in the database", + }, + workspace: { + type: "string", + label: "Workspace ID", + description: "ID of your workspace", + async options() { + const response = await this.listWorkspaces(); + const workspaceIds = response.workspaces; + return workspaceIds.map(({ + id, name, + }) => ({ + value: id, + label: name, + })); + }, + }, + database: { + type: "string", + label: "Database Name", + description: "Name of the database", + async options({ workspace }) { + const response = await this.listDatabases({ + workspace, + }); + const databaseNames = response.databases; + return databaseNames.map(({ name }) => ({ + value: name, + label: name, + })); + }, + }, + branch: { + type: "string", + label: "Branch Name", + description: "Name of the branch", + async options({ + endpoint, database, + }) { + const response = await this.listBranches({ + endpoint, + database, + }); + const branchNames = response.branches; + return branchNames.map(({ name }) => ({ + value: name, + label: name, + })); + }, + }, + }, + methods: { + _baseUrl() { + return "https://api.xata.io"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + url, + headers, + ...otherOpts + } = opts; + const finalUrl = url || (this._baseUrl() + path); + return axios($, { + ...otherOpts, + url: finalUrl, + headers: { + ...headers, + Authorization: `Bearer ${this.$auth.api_key}`, + }, + }); + }, + async createRecord({ + endpoint, database, branch, table, ...args + }) { + return this._makeRequest({ + method: "post", + url: `${endpoint}/db/${database}:${branch}/tables/${table}/data`, + ...args, + }); + }, + async replaceRecord({ + endpoint, database, branch, table, recordId, ...args + }) { + return this._makeRequest({ + method: "put", + url: `${endpoint}/db/${database}:${branch}/tables/${table}/data/${recordId}`, + ...args, + }); + }, + async updateRecord({ + endpoint, database, branch, table, recordId, ...args + }) { + return this._makeRequest({ + method: "post", + url: `${endpoint}/db/${database}:${branch}/tables/${table}/data/${recordId}`, + ...args, + }); + }, + async listWorkspaces(args = {}) { + return this._makeRequest({ + path: "/workspaces", + ...args, + }); + }, + async listDatabases({ + workspace, ...args + }) { + return this._makeRequest({ + path: `/workspaces/${workspace}/dbs`, + ...args, + }); + }, + async listBranches({ + endpoint, database, ...args + }) { + return this._makeRequest({ + url: `${endpoint}/dbs/${database}`, + ...args, + }); + }, + }, +}; From c66dc88a8f0da07434a00e7de9bb13ce48ccb993 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Mon, 9 Sep 2024 10:35:45 -0300 Subject: [PATCH 3/9] Update components/xata/actions/list-branches/list-branches.mjs Co-authored-by: michelle0927 --- components/xata/actions/list-branches/list-branches.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/xata/actions/list-branches/list-branches.mjs b/components/xata/actions/list-branches/list-branches.mjs index f8c0f69a3570d..5be48d7224064 100644 --- a/components/xata/actions/list-branches/list-branches.mjs +++ b/components/xata/actions/list-branches/list-branches.mjs @@ -37,7 +37,8 @@ export default { database: this.database, }); - $.export("$summary", `Successfully retrieved '${response.branchse.length}' branches`); + $.export("$summary", `Successfully retrieved '${response.branches.length}' branches`); + return response; }, From c6e3ef9c669ed921af93afc407fe46bfae7466ee Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Mon, 16 Sep 2024 15:46:08 -0300 Subject: [PATCH 4/9] Requested changes done --- .../actions/create-record/create-record.mjs | 2 -- .../actions/list-branches/list-branches.mjs | 3 --- .../actions/replace-record/replace-record.mjs | 8 +++++-- .../actions/update-record/update-record.mjs | 8 +++++-- components/xata/package.json | 3 +++ components/xata/xata.app.mjs | 23 +++++++++++++++++++ pnpm-lock.yaml | 16 ++++++++++++- 7 files changed, 53 insertions(+), 10 deletions(-) diff --git a/components/xata/actions/create-record/create-record.mjs b/components/xata/actions/create-record/create-record.mjs index a996a2d1e7b0f..2c4c1911267dd 100644 --- a/components/xata/actions/create-record/create-record.mjs +++ b/components/xata/actions/create-record/create-record.mjs @@ -61,9 +61,7 @@ export default { table: this.table, data: this.recordData, }); - $.export("$summary", `Successfully created Record with ID: '${response.id}'`); - return response; }, }; diff --git a/components/xata/actions/list-branches/list-branches.mjs b/components/xata/actions/list-branches/list-branches.mjs index 5be48d7224064..38ff41d7a83ed 100644 --- a/components/xata/actions/list-branches/list-branches.mjs +++ b/components/xata/actions/list-branches/list-branches.mjs @@ -36,10 +36,7 @@ export default { endpoint: this.endpoint, database: this.database, }); - $.export("$summary", `Successfully retrieved '${response.branches.length}' branches`); - - return response; }, }; diff --git a/components/xata/actions/replace-record/replace-record.mjs b/components/xata/actions/replace-record/replace-record.mjs index 57ff34dd0ac63..3e1937bf235f3 100644 --- a/components/xata/actions/replace-record/replace-record.mjs +++ b/components/xata/actions/replace-record/replace-record.mjs @@ -49,6 +49,12 @@ export default { propDefinition: [ app, "recordId", + (c) => ({ + endpoint: c.endpoint, + database: c.database, + table: c.table, + branch: c.branch, + }), ], }, recordData: { @@ -68,9 +74,7 @@ export default { recordId: this.recordId, data: this.recordData, }); - $.export("$summary", `Successfully replaced Record with ID: '${response.id}'`); - return response; }, }; diff --git a/components/xata/actions/update-record/update-record.mjs b/components/xata/actions/update-record/update-record.mjs index 9720ff079ff6c..20a4060cc143a 100644 --- a/components/xata/actions/update-record/update-record.mjs +++ b/components/xata/actions/update-record/update-record.mjs @@ -49,6 +49,12 @@ export default { propDefinition: [ app, "recordId", + (c) => ({ + endpoint: c.endpoint, + database: c.database, + table: c.table, + branch: c.branch, + }), ], }, recordData: { @@ -68,9 +74,7 @@ export default { recordId: this.recordId, data: this.recordData, }); - $.export("$summary", `Successfully updated/created Record with ID: '${response.id}'`); - return response; }, }; diff --git a/components/xata/package.json b/components/xata/package.json index 57c53819e44e1..0d78426c25eb2 100644 --- a/components/xata/package.json +++ b/components/xata/package.json @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.2" } } diff --git a/components/xata/xata.app.mjs b/components/xata/xata.app.mjs index 8f1e4ccdfc659..ad104674e2741 100644 --- a/components/xata/xata.app.mjs +++ b/components/xata/xata.app.mjs @@ -8,6 +8,20 @@ export default { type: "string", label: "Record ID", description: "ID of the record to create or update", + async options({ + endpoint, database, branch, table, + }) { + const response = await this.listRecords({ + endpoint, + database, + branch, + table, + }); + const recordIds = response.records; + return recordIds.map(({ id }) => ({ + value: id, + })); + }, }, table: { type: "string", @@ -122,6 +136,15 @@ export default { ...args, }); }, + async listRecords({ + endpoint, database, branch, table, ...args + }) { + return this._makeRequest({ + method: "post", + url: `${endpoint}/db/${database}:${branch}/tables/${table}/query`, + ...args, + }); + }, async listWorkspaces(args = {}) { return this._makeRequest({ path: "/workspaces", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b6473fbdb843..5451281a149d7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10939,7 +10939,10 @@ importers: qs: 6.11.2 components/xata: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.2 + dependencies: + '@pipedream/platform': 3.0.2 components/xeggex: specifiers: {} @@ -17636,6 +17639,17 @@ packages: - debug dev: false + /@pipedream/platform/3.0.2: + resolution: {integrity: sha512-q/BYGJoNXOVaRlNTDWD7Gjgkcu114gbPrxQ5KCOFbuYfqnJu8AeDGMyMvEPaGPbrWUVwgxjvOnxw4EWqce8ZNQ==} + dependencies: + axios: 1.7.5 + fp-ts: 2.16.9 + io-ts: 2.2.21_fp-ts@2.16.9 + querystring: 0.2.1 + transitivePeerDependencies: + - debug + dev: false + /@pipedream/sdk/0.0.7: resolution: {integrity: sha512-o9TSoMqriYSm8gYOrwv0mkUtSgu3u4hX9rh0p8ssoYOZ6LLH5mvy5GX1ACD5BPwcaEUSHHzqJ+E7kJjq3eMtrw==} dev: false From 48bdf93bbc9960d9e084f9d25980065076626cb5 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 3 Oct 2024 14:30:26 -0400 Subject: [PATCH 5/9] updates --- components/xata/actions/common/common.mjs | 79 +++++++++++++++++++ .../actions/create-record/create-record.mjs | 44 +---------- .../actions/replace-record/replace-record.mjs | 46 ++--------- .../actions/update-record/update-record.mjs | 46 ++--------- components/xata/xata.app.mjs | 28 ++++--- 5 files changed, 111 insertions(+), 132 deletions(-) create mode 100644 components/xata/actions/common/common.mjs diff --git a/components/xata/actions/common/common.mjs b/components/xata/actions/common/common.mjs new file mode 100644 index 0000000000000..f7dabb6544e18 --- /dev/null +++ b/components/xata/actions/common/common.mjs @@ -0,0 +1,79 @@ +import app from "../../xata.app.mjs"; + +export default { + props: { + app, + endpoint: { + propDefinition: [ + app, + "endpoint", + ], + }, + workspace: { + propDefinition: [ + app, + "workspace", + ], + }, + database: { + propDefinition: [ + app, + "database", + (c) => ({ + workspace: c.workspace, + }), + ], + }, + branch: { + propDefinition: [ + app, + "branch", + (c) => ({ + endpoint: c.endpoint, + database: c.database, + }), + ], + }, + table: { + propDefinition: [ + app, + "table", + ], + reloadProps: true, + }, + }, + async additionalProps(props) { + const { + endpoint, + database, + branch, + table, + } = this; + + const description = "The keys and values of the data that will be recorded in the database."; + + if (endpoint && database && branch && table) { + try { + const { columns } = await this.app.listColumns({ + endpoint, + database, + branch, + table, + }); + if (columns?.length) { + let descriptionWithColumns = `${description} Available Columns:`; + for (const column of columns) { + descriptionWithColumns += ` \`${column.name}\``; + } + props.recordData.description = descriptionWithColumns; + return {}; + } + } catch (e) { + props.recordData.description = description; + // Columns not found. Occurs when the user hasn't finished entering the table name + } + } + props.recordData.description = description; + return {}; + }, +}; diff --git a/components/xata/actions/create-record/create-record.mjs b/components/xata/actions/create-record/create-record.mjs index 2c4c1911267dd..f82e19eb984f4 100644 --- a/components/xata/actions/create-record/create-record.mjs +++ b/components/xata/actions/create-record/create-record.mjs @@ -1,53 +1,17 @@ -import app from "../../xata.app.mjs"; +import common from "../common/common.mjs"; export default { + ...common, key: "xata-create-record", name: "Create Record", description: "Create a new Record in the specified database. [See the documentation](https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data#insert-record)", version: "0.0.1", type: "action", props: { - app, - endpoint: { - propDefinition: [ - app, - "endpoint", - ], - }, - workspace: { - propDefinition: [ - app, - "workspace", - ], - }, - database: { - propDefinition: [ - app, - "database", - (c) => ({ - workspace: c.workspace, - }), - ], - }, - branch: { - propDefinition: [ - app, - "branch", - (c) => ({ - endpoint: c.endpoint, - database: c.database, - }), - ], - }, - table: { - propDefinition: [ - app, - "table", - ], - }, + ...common.props, recordData: { propDefinition: [ - app, + common.props.app, "recordData", ], }, diff --git a/components/xata/actions/replace-record/replace-record.mjs b/components/xata/actions/replace-record/replace-record.mjs index 3e1937bf235f3..4f15dfc4db623 100644 --- a/components/xata/actions/replace-record/replace-record.mjs +++ b/components/xata/actions/replace-record/replace-record.mjs @@ -1,53 +1,17 @@ -import app from "../../xata.app.mjs"; +import common from "../common/common.mjs"; export default { + ...common, key: "xata-replace-record", name: "Replace Record", description: "Replace a record with the specified ID. [See the documentation](https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data/record_id#insert-record-with-id)", version: "0.0.1", type: "action", props: { - app, - endpoint: { - propDefinition: [ - app, - "endpoint", - ], - }, - workspace: { - propDefinition: [ - app, - "workspace", - ], - }, - database: { - propDefinition: [ - app, - "database", - (c) => ({ - workspace: c.workspace, - }), - ], - }, - branch: { - propDefinition: [ - app, - "branch", - (c) => ({ - endpoint: c.endpoint, - database: c.database, - }), - ], - }, - table: { - propDefinition: [ - app, - "table", - ], - }, + ...common.props, recordId: { propDefinition: [ - app, + common.props.app, "recordId", (c) => ({ endpoint: c.endpoint, @@ -59,7 +23,7 @@ export default { }, recordData: { propDefinition: [ - app, + common.props.app, "recordData", ], }, diff --git a/components/xata/actions/update-record/update-record.mjs b/components/xata/actions/update-record/update-record.mjs index 20a4060cc143a..b93dc7e52819f 100644 --- a/components/xata/actions/update-record/update-record.mjs +++ b/components/xata/actions/update-record/update-record.mjs @@ -1,53 +1,17 @@ -import app from "../../xata.app.mjs"; +import common from "../common/common.mjs"; export default { + ...common, key: "xata-update-record", name: "Update Record", description: "Update or create a record with the specified ID. [See the documentation](https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data/record_id#upsert-record-with-id)", version: "0.0.1", type: "action", props: { - app, - endpoint: { - propDefinition: [ - app, - "endpoint", - ], - }, - workspace: { - propDefinition: [ - app, - "workspace", - ], - }, - database: { - propDefinition: [ - app, - "database", - (c) => ({ - workspace: c.workspace, - }), - ], - }, - branch: { - propDefinition: [ - app, - "branch", - (c) => ({ - endpoint: c.endpoint, - database: c.database, - }), - ], - }, - table: { - propDefinition: [ - app, - "table", - ], - }, + ...common.props, recordId: { propDefinition: [ - app, + common.props.app, "recordId", (c) => ({ endpoint: c.endpoint, @@ -59,7 +23,7 @@ export default { }, recordData: { propDefinition: [ - app, + common.props.app, "recordData", ], }, diff --git a/components/xata/xata.app.mjs b/components/xata/xata.app.mjs index ad104674e2741..08193043db177 100644 --- a/components/xata/xata.app.mjs +++ b/components/xata/xata.app.mjs @@ -36,7 +36,7 @@ export default { recordData: { type: "object", label: "Record Data", - description: "The key and value of the data that will be recorded in the database", + description: "The keys and values of the data that will be recorded in the database", }, workspace: { type: "string", @@ -56,7 +56,7 @@ export default { database: { type: "string", label: "Database Name", - description: "Name of the database", + description: "Name of the database. Must be **non postgres enabled**.", async options({ workspace }) { const response = await this.listDatabases({ workspace, @@ -99,7 +99,7 @@ export default { headers, ...otherOpts } = opts; - const finalUrl = url || (this._baseUrl() + path); + const finalUrl = url || `${this._baseUrl()}${path}`; return axios($, { ...otherOpts, url: finalUrl, @@ -109,7 +109,7 @@ export default { }, }); }, - async createRecord({ + createRecord({ endpoint, database, branch, table, ...args }) { return this._makeRequest({ @@ -118,7 +118,7 @@ export default { ...args, }); }, - async replaceRecord({ + replaceRecord({ endpoint, database, branch, table, recordId, ...args }) { return this._makeRequest({ @@ -127,7 +127,7 @@ export default { ...args, }); }, - async updateRecord({ + updateRecord({ endpoint, database, branch, table, recordId, ...args }) { return this._makeRequest({ @@ -136,7 +136,7 @@ export default { ...args, }); }, - async listRecords({ + listRecords({ endpoint, database, branch, table, ...args }) { return this._makeRequest({ @@ -145,13 +145,13 @@ export default { ...args, }); }, - async listWorkspaces(args = {}) { + listWorkspaces(args = {}) { return this._makeRequest({ path: "/workspaces", ...args, }); }, - async listDatabases({ + listDatabases({ workspace, ...args }) { return this._makeRequest({ @@ -159,7 +159,7 @@ export default { ...args, }); }, - async listBranches({ + listBranches({ endpoint, database, ...args }) { return this._makeRequest({ @@ -167,5 +167,13 @@ export default { ...args, }); }, + listColumns({ + endpoint, database, branch, table, ...args + }) { + return this._makeRequest({ + url: `${endpoint}/db/${database}:${branch}/tables/${table}/columns`, + ...args, + }); + }, }, }; From 9c8d0de2cadd9c83c1f31240292a7b947cc7b691 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 3 Oct 2024 14:36:59 -0400 Subject: [PATCH 6/9] pnpm-lock.yaml --- pnpm-lock.yaml | 205 +++++++++++++++++++------------------------------ 1 file changed, 78 insertions(+), 127 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 65f21c6d455b8..50848b03987cd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -60,7 +60,7 @@ importers: pnpm: 7.33.6 putout: 32.2.0_typescript@5.2.2 renamer: 4.0.0 - ts-jest: 29.1.1_s6pp5jfszqvqftxetajx5tybba + ts-jest: 29.1.1_py5cyg2l76gggsf4xgc65fzuzq tsc-esm-fix: 2.20.17 tsc-watch: 5.0.3_typescript@5.2.2 typescript: 5.2.2 @@ -239,7 +239,7 @@ importers: specifiers: '@pipedream/platform': ^3.0.1 dependencies: - '@pipedream/platform': 3.0.1 + '@pipedream/platform': 3.0.3 components/adobe_pdf_services: specifiers: @@ -322,7 +322,7 @@ importers: specifiers: '@pipedream/platform': ^3.0.2 dependencies: - '@pipedream/platform': 3.0.2 + '@pipedream/platform': 3.0.3 components/agrello: specifiers: @@ -4269,7 +4269,7 @@ importers: specifiers: '@pipedream/platform': ^3.0.1 dependencies: - '@pipedream/platform': 3.0.1 + '@pipedream/platform': 3.0.3 components/groovehq: specifiers: {} @@ -6456,7 +6456,7 @@ importers: specifiers: '@pipedream/platform': ^3.0.1 dependencies: - '@pipedream/platform': 3.0.1 + '@pipedream/platform': 3.0.3 components/nocodb: specifiers: @@ -6778,7 +6778,7 @@ importers: specifiers: '@pipedream/platform': ^3.0.1 dependencies: - '@pipedream/platform': 3.0.1 + '@pipedream/platform': 3.0.3 components/optimoroute: specifiers: {} @@ -8765,7 +8765,7 @@ importers: specifiers: '@pipedream/platform': ^3.0.1 dependencies: - '@pipedream/platform': 3.0.1 + '@pipedream/platform': 3.0.3 components/seventodos: specifiers: @@ -10218,7 +10218,7 @@ importers: lodash-es: ^4.17.21 ms: ^2.1.3 dependencies: - '@pipedream/platform': 3.0.1 + '@pipedream/platform': 3.0.3 crypto: 1.0.1 form-data: 4.0.0 lodash-es: 4.17.21 @@ -12885,55 +12885,6 @@ packages: - aws-crt dev: false - /@aws-sdk/client-sso-oidc/3.600.0_tdq3komn4zwyd65w7klbptsu34: - resolution: {integrity: sha512-7+I8RWURGfzvChyNQSyj5/tKrqRbzRl7H+BnTOf/4Vsw1nFOi5ROhlhD4X/Y0QCTacxnaoNcIrqnY7uGGvVRzw==} - engines: {node: '>=16.0.0'} - dependencies: - '@aws-crypto/sha256-browser': 5.2.0 - '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sts': 3.600.0 - '@aws-sdk/core': 3.598.0 - '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 - '@aws-sdk/middleware-host-header': 3.598.0 - '@aws-sdk/middleware-logger': 3.598.0 - '@aws-sdk/middleware-recursion-detection': 3.598.0 - '@aws-sdk/middleware-user-agent': 3.598.0 - '@aws-sdk/region-config-resolver': 3.598.0 - '@aws-sdk/types': 3.598.0 - '@aws-sdk/util-endpoints': 3.598.0 - '@aws-sdk/util-user-agent-browser': 3.598.0 - '@aws-sdk/util-user-agent-node': 3.598.0 - '@smithy/config-resolver': 3.0.3 - '@smithy/core': 2.2.3 - '@smithy/fetch-http-handler': 3.2.1 - '@smithy/hash-node': 3.0.2 - '@smithy/invalid-dependency': 3.0.2 - '@smithy/middleware-content-length': 3.0.2 - '@smithy/middleware-endpoint': 3.0.4 - '@smithy/middleware-retry': 3.0.6 - '@smithy/middleware-serde': 3.0.3 - '@smithy/middleware-stack': 3.0.3 - '@smithy/node-config-provider': 3.1.3 - '@smithy/node-http-handler': 3.1.2 - '@smithy/protocol-http': 4.0.3 - '@smithy/smithy-client': 3.1.6 - '@smithy/types': 3.3.0 - '@smithy/url-parser': 3.0.3 - '@smithy/util-base64': 3.0.0 - '@smithy/util-body-length-browser': 3.0.0 - '@smithy/util-body-length-node': 3.0.0 - '@smithy/util-defaults-mode-browser': 3.0.6 - '@smithy/util-defaults-mode-node': 3.0.6 - '@smithy/util-endpoints': 2.0.3 - '@smithy/util-middleware': 3.0.3 - '@smithy/util-retry': 3.0.2 - '@smithy/util-utf8': 3.0.0 - tslib: 2.6.3 - transitivePeerDependencies: - - '@aws-sdk/client-sts' - - aws-crt - dev: false - /@aws-sdk/client-sso/3.423.0: resolution: {integrity: sha512-znIufHkwhCIePgaYciIs3x/+BpzR57CZzbCKHR9+oOvGyufEPPpUT5bFLvbwTgfiVkTjuk6sG/ES3U5Bc+xtrA==} engines: {node: '>=14.0.0'} @@ -13169,7 +13120,7 @@ packages: dependencies: '@aws-crypto/sha256-browser': 5.2.0 '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0_tdq3komn4zwyd65w7klbptsu34 + '@aws-sdk/client-sso-oidc': 3.600.0 '@aws-sdk/core': 3.598.0 '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 '@aws-sdk/middleware-host-header': 3.598.0 @@ -13211,6 +13162,55 @@ packages: - aws-crt dev: false + /@aws-sdk/client-sts/3.600.0_dseaa2p5u2yk67qiepewcq3hkq: + resolution: {integrity: sha512-KQG97B7LvTtTiGmjlrG1LRAY8wUvCQzrmZVV5bjrJ/1oXAU7DITYwVbSJeX9NWg6hDuSk0VE3MFwIXS2SvfLIA==} + engines: {node: '>=16.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 5.2.0 + '@aws-crypto/sha256-js': 5.2.0 + '@aws-sdk/client-sso-oidc': 3.600.0 + '@aws-sdk/core': 3.598.0 + '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 + '@aws-sdk/middleware-host-header': 3.598.0 + '@aws-sdk/middleware-logger': 3.598.0 + '@aws-sdk/middleware-recursion-detection': 3.598.0 + '@aws-sdk/middleware-user-agent': 3.598.0 + '@aws-sdk/region-config-resolver': 3.598.0 + '@aws-sdk/types': 3.598.0 + '@aws-sdk/util-endpoints': 3.598.0 + '@aws-sdk/util-user-agent-browser': 3.598.0 + '@aws-sdk/util-user-agent-node': 3.598.0 + '@smithy/config-resolver': 3.0.3 + '@smithy/core': 2.2.3 + '@smithy/fetch-http-handler': 3.2.1 + '@smithy/hash-node': 3.0.2 + '@smithy/invalid-dependency': 3.0.2 + '@smithy/middleware-content-length': 3.0.2 + '@smithy/middleware-endpoint': 3.0.4 + '@smithy/middleware-retry': 3.0.6 + '@smithy/middleware-serde': 3.0.3 + '@smithy/middleware-stack': 3.0.3 + '@smithy/node-config-provider': 3.1.3 + '@smithy/node-http-handler': 3.1.2 + '@smithy/protocol-http': 4.0.3 + '@smithy/smithy-client': 3.1.6 + '@smithy/types': 3.3.0 + '@smithy/url-parser': 3.0.3 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.6 + '@smithy/util-defaults-mode-node': 3.0.6 + '@smithy/util-endpoints': 2.0.3 + '@smithy/util-middleware': 3.0.3 + '@smithy/util-retry': 3.0.2 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.3 + transitivePeerDependencies: + - '@aws-sdk/client-sso-oidc' + - aws-crt + dev: false + /@aws-sdk/core/3.556.0: resolution: {integrity: sha512-vJaSaHw2kPQlo11j/Rzuz0gk1tEaKdz+2ser0f0qZ5vwFlANjt08m/frU17ctnVKC1s58bxpctO/1P894fHLrA==} engines: {node: '>=14.0.0'} @@ -14460,7 +14460,7 @@ packages: resolution: {integrity: sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==} engines: {node: '>=6.9.0'} dependencies: - '@babel/highlight': 7.22.20 + '@babel/highlight': 7.24.7 chalk: 2.4.2 /@babel/code-frame/7.24.7: @@ -14470,10 +14470,6 @@ packages: '@babel/highlight': 7.24.7 picocolors: 1.0.1 - /@babel/compat-data/7.22.20: - resolution: {integrity: sha512-BQYjKbpXjoXwFW5jGqiizJQQT/aC7pFm9Ok1OWssonuguICi264lbgMzRp2ZMmRSlfkX6DsWDDcsrctK8Rwfiw==} - engines: {node: '>=6.9.0'} - /@babel/compat-data/7.25.2: resolution: {integrity: sha512-bYcppcpKBvX4znYaPEeFau03bp89ShqNMLs+rmdptMw+heSZh9+z84d2YG+K7cYLbWwzdjtDoW/uqZmPjulClQ==} engines: {node: '>=6.9.0'} @@ -14573,8 +14569,8 @@ packages: resolution: {integrity: sha512-y6EEzULok0Qvz8yyLkCvVX+02ic+By2UdOhylwUOvOn9dvYc9mKICJuuU1n1XBI02YWsNsnrY1kc6DVbjcXbtw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/compat-data': 7.22.20 - '@babel/helper-validator-option': 7.22.15 + '@babel/compat-data': 7.25.2 + '@babel/helper-validator-option': 7.24.8 browserslist: 4.23.3 lru-cache: 5.1.1 semver: 6.3.1 @@ -14658,12 +14654,6 @@ packages: '@babel/types': 7.25.2 dev: false - /@babel/helper-module-imports/7.22.15: - resolution: {integrity: sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/types': 7.25.2 - /@babel/helper-module-imports/7.24.7: resolution: {integrity: sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==} engines: {node: '>=6.9.0'} @@ -14681,10 +14671,12 @@ packages: dependencies: '@babel/core': 7.23.0 '@babel/helper-environment-visitor': 7.22.20 - '@babel/helper-module-imports': 7.22.15 - '@babel/helper-simple-access': 7.22.5 + '@babel/helper-module-imports': 7.24.7 + '@babel/helper-simple-access': 7.24.7 '@babel/helper-split-export-declaration': 7.22.6 - '@babel/helper-validator-identifier': 7.22.20 + '@babel/helper-validator-identifier': 7.24.7 + transitivePeerDependencies: + - supports-color /@babel/helper-module-transforms/7.25.2_@babel+core@7.23.0: resolution: {integrity: sha512-BjyRAbix6j/wv83ftcVJmBt72QtHI56C7JXZoG2xATiLpmoC7dpd8WnkikExHDVPpi/3qCmO6WY1EaXOluiecQ==} @@ -14751,12 +14743,6 @@ packages: '@babel/helper-optimise-call-expression': 7.22.5 dev: false - /@babel/helper-simple-access/7.22.5: - resolution: {integrity: sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/types': 7.25.2 - /@babel/helper-simple-access/7.24.7: resolution: {integrity: sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==} engines: {node: '>=6.9.0'} @@ -14779,26 +14765,14 @@ packages: dependencies: '@babel/types': 7.25.2 - /@babel/helper-string-parser/7.22.5: - resolution: {integrity: sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==} - engines: {node: '>=6.9.0'} - /@babel/helper-string-parser/7.24.8: resolution: {integrity: sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==} engines: {node: '>=6.9.0'} - /@babel/helper-validator-identifier/7.22.20: - resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} - engines: {node: '>=6.9.0'} - /@babel/helper-validator-identifier/7.24.7: resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==} engines: {node: '>=6.9.0'} - /@babel/helper-validator-option/7.22.15: - resolution: {integrity: sha512-bMn7RmyFjY/mdECUbgn9eoSY4vqvacUnS9i9vGAGttgFWesO6B4CYWA7XlpbWgBt71iv/hfbPlynohStqnu5hA==} - engines: {node: '>=6.9.0'} - /@babel/helper-validator-option/7.24.8: resolution: {integrity: sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==} engines: {node: '>=6.9.0'} @@ -14816,8 +14790,8 @@ packages: resolution: {integrity: sha512-chNpneuK18yW5Oxsr+t553UZzzAs3aZnFm4bxhebsNTeshrC95yA7l5yl7GBAG+JG1rF0F7zzD2EixK9mWSDoA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/template': 7.22.15 - '@babel/traverse': 7.23.0 + '@babel/template': 7.25.0 + '@babel/traverse': 7.25.3 '@babel/types': 7.25.2 transitivePeerDependencies: - supports-color @@ -14830,14 +14804,6 @@ packages: '@babel/types': 7.25.2 dev: true - /@babel/highlight/7.22.20: - resolution: {integrity: sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/helper-validator-identifier': 7.24.7 - chalk: 2.4.2 - js-tokens: 4.0.0 - /@babel/highlight/7.24.7: resolution: {integrity: sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==} engines: {node: '>=6.9.0'} @@ -15849,7 +15815,7 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.24.7 - '@babel/parser': 7.23.0 + '@babel/parser': 7.25.3 '@babel/types': 7.25.2 /@babel/template/7.25.0: @@ -15870,7 +15836,7 @@ packages: '@babel/helper-function-name': 7.23.0 '@babel/helper-hoist-variables': 7.22.5 '@babel/helper-split-export-declaration': 7.22.6 - '@babel/parser': 7.23.0 + '@babel/parser': 7.25.3 '@babel/types': 7.25.2 debug: 4.3.6 globals: 11.12.0 @@ -15895,8 +15861,8 @@ packages: resolution: {integrity: sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-string-parser': 7.22.5 - '@babel/helper-validator-identifier': 7.22.20 + '@babel/helper-string-parser': 7.24.8 + '@babel/helper-validator-identifier': 7.24.7 to-fast-properties: 2.0.0 /@babel/types/7.25.2: @@ -17537,7 +17503,7 @@ packages: '@aws-sdk/client-sns': 3.423.0 '@aws-sdk/client-sqs': 3.423.0 '@aws-sdk/client-ssm': 3.423.0 - '@aws-sdk/client-sts': 3.600.0 + '@aws-sdk/client-sts': 3.600.0_dseaa2p5u2yk67qiepewcq3hkq '@aws-sdk/s3-request-presigner': 3.609.0 '@pipedream/helper_functions': 0.3.12 '@pipedream/platform': 1.6.6 @@ -17707,7 +17673,7 @@ packages: /@pipedream/platform/3.0.1: resolution: {integrity: sha512-xja1ZHUR/DpOQZZJY39daml8q1ZMzg8wKYwYbyxVPs7MiMqneHM7Bz+Lgj/QrjbNissIKsRSGXmkXbT+Y10L0w==} dependencies: - axios: 1.7.5 + axios: 1.7.7 fp-ts: 2.16.9 io-ts: 2.2.21_fp-ts@2.16.9 querystring: 0.2.1 @@ -17718,7 +17684,7 @@ packages: /@pipedream/platform/3.0.2: resolution: {integrity: sha512-q/BYGJoNXOVaRlNTDWD7Gjgkcu114gbPrxQ5KCOFbuYfqnJu8AeDGMyMvEPaGPbrWUVwgxjvOnxw4EWqce8ZNQ==} dependencies: - axios: 1.7.7 + axios: 1.7.5 fp-ts: 2.16.9 io-ts: 2.2.21_fp-ts@2.16.9 querystring: 0.2.1 @@ -17737,21 +17703,6 @@ packages: - debug dev: false - /@pipedream/platform/3.0.2: - resolution: {integrity: sha512-q/BYGJoNXOVaRlNTDWD7Gjgkcu114gbPrxQ5KCOFbuYfqnJu8AeDGMyMvEPaGPbrWUVwgxjvOnxw4EWqce8ZNQ==} - dependencies: - axios: 1.7.5 - fp-ts: 2.16.9 - io-ts: 2.2.21_fp-ts@2.16.9 - querystring: 0.2.1 - transitivePeerDependencies: - - debug - dev: false - - /@pipedream/sdk/0.0.7: - resolution: {integrity: sha512-o9TSoMqriYSm8gYOrwv0mkUtSgu3u4hX9rh0p8ssoYOZ6LLH5mvy5GX1ACD5BPwcaEUSHHzqJ+E7kJjq3eMtrw==} - dev: false - /@pipedream/snowflake-sdk/1.0.8_asn1.js@5.4.1: resolution: {integrity: sha512-/nLCQNjlSCz71MUnOUZqWmnjZTbEX7mie91mstPspb8uDG/GvaDk/RynLGhhYfgEP5d1KWj+OPaI71hmPSxReg==} dependencies: @@ -22342,7 +22293,7 @@ packages: /axios/1.7.5: resolution: {integrity: sha512-fZu86yCo+svH3uqJ/yTdQ0QHpQu5oL+/QE+QPSv6BZSkDAoky9vytxp7u5qk83OJFS3kEBcesWni9WTZAv3tSw==} dependencies: - follow-redirects: 1.15.6 + follow-redirects: 1.15.9 form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -34518,7 +34469,7 @@ packages: engines: {node: '>=6'} dev: true - /ts-jest/29.1.1_s6pp5jfszqvqftxetajx5tybba: + /ts-jest/29.1.1_py5cyg2l76gggsf4xgc65fzuzq: resolution: {integrity: sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -34539,7 +34490,7 @@ packages: esbuild: optional: true dependencies: - '@babel/core': 7.25.2 + '@babel/core': 7.23.0 bs-logger: 0.2.6 fast-json-stable-stringify: 2.1.0 jest: 29.7.0_@types+node@20.9.2 From e729dc72a1f74c8746c99b978aba83f5923a4dea Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Fri, 4 Oct 2024 13:21:59 -0400 Subject: [PATCH 7/9] format recordData --- components/xata/actions/common/common.mjs | 23 +++++++++++++++++++ .../actions/create-record/create-record.mjs | 2 +- .../actions/replace-record/replace-record.mjs | 2 +- .../actions/update-record/update-record.mjs | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/components/xata/actions/common/common.mjs b/components/xata/actions/common/common.mjs index f7dabb6544e18..203d582ed5761 100644 --- a/components/xata/actions/common/common.mjs +++ b/components/xata/actions/common/common.mjs @@ -76,4 +76,27 @@ export default { props.recordData.description = description; return {}; }, + methods: { + async formatRecordData() { + const recordData = this.recordData; + const { columns } = await this.app.listColumns({ + endpoint: this.endpoint, + database: this.database, + branch: this.branch, + table: this.table, + }); + if (!columns?.length) { + return this.recordData; + } + for (const column of columns) { + if (recordData[column.name] && (column.type === "int" || column.type === "float")) { + recordData[column.name] = +recordData[column.name]; + } + if (recordData[column.name] && column.type === "bool") { + recordData[column.name] = !(recordData[column.name] === "false" || recordData[column.name === "0"]); + } + } + return recordData; + }, + }, }; diff --git a/components/xata/actions/create-record/create-record.mjs b/components/xata/actions/create-record/create-record.mjs index f82e19eb984f4..e56cdbd7bd03b 100644 --- a/components/xata/actions/create-record/create-record.mjs +++ b/components/xata/actions/create-record/create-record.mjs @@ -23,7 +23,7 @@ export default { database: this.database, branch: this.branch, table: this.table, - data: this.recordData, + data: await this.formatRecordData(), }); $.export("$summary", `Successfully created Record with ID: '${response.id}'`); return response; diff --git a/components/xata/actions/replace-record/replace-record.mjs b/components/xata/actions/replace-record/replace-record.mjs index 4f15dfc4db623..2f15fad5a2822 100644 --- a/components/xata/actions/replace-record/replace-record.mjs +++ b/components/xata/actions/replace-record/replace-record.mjs @@ -36,7 +36,7 @@ export default { branch: this.branch, table: this.table, recordId: this.recordId, - data: this.recordData, + data: await this.formatRecordData(), }); $.export("$summary", `Successfully replaced Record with ID: '${response.id}'`); return response; diff --git a/components/xata/actions/update-record/update-record.mjs b/components/xata/actions/update-record/update-record.mjs index b93dc7e52819f..cff581a4eded7 100644 --- a/components/xata/actions/update-record/update-record.mjs +++ b/components/xata/actions/update-record/update-record.mjs @@ -36,7 +36,7 @@ export default { branch: this.branch, table: this.table, recordId: this.recordId, - data: this.recordData, + data: await this.formatRecordData(), }); $.export("$summary", `Successfully updated/created Record with ID: '${response.id}'`); return response; From 15187cbe128b81fdd03d226676d9708e59a378b3 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 7 Oct 2024 11:50:34 -0400 Subject: [PATCH 8/9] updates --- components/xata/actions/common/common.mjs | 44 +++++++++++++---------- components/xata/xata.app.mjs | 18 ++++++++++ 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/components/xata/actions/common/common.mjs b/components/xata/actions/common/common.mjs index 203d582ed5761..ee4e6a430dd27 100644 --- a/components/xata/actions/common/common.mjs +++ b/components/xata/actions/common/common.mjs @@ -38,6 +38,11 @@ export default { propDefinition: [ app, "table", + (c) => ({ + endpoint: c.endpoint, + database: c.database, + branch: c.branch, + }), ], reloadProps: true, }, @@ -53,24 +58,19 @@ export default { const description = "The keys and values of the data that will be recorded in the database."; if (endpoint && database && branch && table) { - try { - const { columns } = await this.app.listColumns({ - endpoint, - database, - branch, - table, - }); - if (columns?.length) { - let descriptionWithColumns = `${description} Available Columns:`; - for (const column of columns) { - descriptionWithColumns += ` \`${column.name}\``; - } - props.recordData.description = descriptionWithColumns; - return {}; + const { columns } = await this.app.listColumns({ + endpoint, + database, + branch, + table, + }); + if (columns?.length) { + let descriptionWithColumns = `${description} Available Columns:`; + for (const column of columns) { + descriptionWithColumns += ` \`${column.name}\``; } - } catch (e) { - props.recordData.description = description; - // Columns not found. Occurs when the user hasn't finished entering the table name + props.recordData.description = descriptionWithColumns; + return {}; } } props.recordData.description = description; @@ -89,12 +89,18 @@ export default { return this.recordData; } for (const column of columns) { - if (recordData[column.name] && (column.type === "int" || column.type === "float")) { + if (!recordData[column.name] || typeof recordData[column.name] !== "string") { + continue; + } + if ((column.type === "int" || column.type === "float")) { recordData[column.name] = +recordData[column.name]; } - if (recordData[column.name] && column.type === "bool") { + if (column.type === "bool") { recordData[column.name] = !(recordData[column.name] === "false" || recordData[column.name === "0"]); } + if (column.type === "multiple" || column.type === "vector") { + recordData[column.name] = JSON.parse(recordData[column.name]); + } } return recordData; }, diff --git a/components/xata/xata.app.mjs b/components/xata/xata.app.mjs index 08193043db177..d28bd551ad43b 100644 --- a/components/xata/xata.app.mjs +++ b/components/xata/xata.app.mjs @@ -27,6 +27,16 @@ export default { type: "string", label: "Table Name", description: "Name of the table", + async options({ + endpoint, database, branch, + }) { + const { schema: { tables } } = await this.getBranchSchema({ + endpoint, + database, + branch, + }); + return tables?.map(({ name }) => name ) || []; + }, }, endpoint: { type: "string", @@ -175,5 +185,13 @@ export default { ...args, }); }, + getBranchSchema({ + endpoint, database, branch, ...args + }) { + return this._makeRequest({ + url: `${endpoint}/db/${database}:${branch}`, + ...args, + }); + }, }, }; From b78c20c40eb766f7f83d6d33f320ee865cf6d409 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 8 Oct 2024 11:12:16 -0400 Subject: [PATCH 9/9] update --- components/xata/xata.app.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/xata/xata.app.mjs b/components/xata/xata.app.mjs index d28bd551ad43b..0713529ec5226 100644 --- a/components/xata/xata.app.mjs +++ b/components/xata/xata.app.mjs @@ -66,12 +66,12 @@ export default { database: { type: "string", label: "Database Name", - description: "Name of the database. Must be **non postgres enabled**.", + description: "Name of the database. Must be **NON POSTGRES ENABLED**.", async options({ workspace }) { const response = await this.listDatabases({ workspace, }); - const databaseNames = response.databases; + const databaseNames = response.databases.filter(({ postgresEnabled }) => !postgresEnabled); return databaseNames.map(({ name }) => ({ value: name, label: name,