-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] plecto #13237 #17366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Components] plecto #13237 #17366
Changes from 3 commits
ada410b
100ba05
c1541a4
7d75959
3696e5c
9058588
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import app from "../../plecto.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "plecto-create-registration", | ||
| name: "Create Registration", | ||
| description: "Creates a new registration in Plecto. [See the documentation](https://docs.plecto.com/kb/guide/en/overview-of-plecto-api-endpoints-Qvm3c3ucy1/Steps/3879885,3896454)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| dataSource: { | ||
| propDefinition: [ | ||
| app, | ||
| "dataSource", | ||
| ], | ||
| }, | ||
| member: { | ||
| propDefinition: [ | ||
| app, | ||
| "member", | ||
| ], | ||
| }, | ||
| externalId: { | ||
| propDefinition: [ | ||
| app, | ||
| "externalId", | ||
| ], | ||
| }, | ||
| date: { | ||
| propDefinition: [ | ||
| app, | ||
| "date", | ||
| ], | ||
| }, | ||
| productName: { | ||
| propDefinition: [ | ||
| app, | ||
| "productName", | ||
| ], | ||
| }, | ||
| unitsSold: { | ||
| propDefinition: [ | ||
| app, | ||
| "unitsSold", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.createRegistration({ | ||
| $, | ||
| data: { | ||
| "data_source": this.dataSource, | ||
| "member": this.member, | ||
| "external_id": this.externalId, | ||
| "date": this.date, | ||
| "Product Name": this.productName, | ||
| "Units Sold": this.unitsSold, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully created registration with ID: " + response.id); | ||
| return response; | ||
| }, | ||
| }; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,102 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { axios } from "@pipedream/platform"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "app", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| app: "plecto", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinitions: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dataSource: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Data Source", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "ID of the data source of the registration", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| async options() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const response = await this.getDataSources(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return response.map(({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| uuid, title, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| value: uuid, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| label: title, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling to the options() function. The async options function lacks error handling, which could cause the UI to break if the API request fails. async options() {
- const response = await this.getDataSources();
- return response.map(({
- uuid, title,
- }) => ({
- value: uuid,
- label: title,
- }));
+ try {
+ const response = await this.getDataSources();
+ return response.map(({
+ uuid, title,
+ }) => ({
+ value: uuid,
+ label: title,
+ }));
+ } catch (error) {
+ console.error("Failed to fetch data sources:", error);
+ return [];
+ }
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| member: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Member", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "ID of the member associated with this registration", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| async options() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const response = await this.getMembers(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return response.map(({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| uuid, name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| value: uuid, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| label: name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling to the options() function. Similar to the dataSource prop, this async options function needs error handling. async options() {
- const response = await this.getMembers();
- return response.map(({
- uuid, name,
- }) => ({
- value: uuid,
- label: name,
- }));
+ try {
+ const response = await this.getMembers();
+ return response.map(({
+ uuid, name,
+ }) => ({
+ value: uuid,
+ label: name,
+ }));
+ } catch (error) {
+ console.error("Failed to fetch members:", error);
+ return [];
+ }
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Update member prop to support Plecto API requirements. Based on the Plecto API documentation, member identification requires separate Consider splitting this into two separate props: - member: {
- type: "string",
- label: "Member",
- description: "ID of the member associated with this registration",
- async options() {
- const response = await this.getMembers();
- return response.map(({
- uuid, name,
- }) => ({
- value: uuid,
- label: name,
- }));
- },
- },
+ memberApiProvider: {
+ type: "string",
+ label: "Member API Provider",
+ description: "The system name that provides the member ID",
+ },
+ memberApiId: {
+ type: "string",
+ label: "Member API ID",
+ description: "The member's ID in your system",
+ },Or keep the existing structure but update the action to map the selected member UUID to the required API format. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| externalId: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "External ID", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "External ID to prevent duplicate registrations", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| date: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Date", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Date and time of the registration in ISO 8601 format", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| productName: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Product Name", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Custom field representing the product name", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| unitsSold: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Units Sold", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Custom field representing the number of units sold", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| methods: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| _baseUrl() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return "https://app.plecto.com/api/v2"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| async _makeRequest(opts = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| $ = this, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| path, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| auth, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ...otherOpts | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } = opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return axios($, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ...otherOpts, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| url: this._baseUrl() + path, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| auth: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| username: `${this.$auth.username}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| password: `${this.$auth.password}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ...auth, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| async createRegistration(args = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| path: "/registrations/", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| method: "post", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ...args, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| async getDataSources(args = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| path: "/datasources/", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ...args, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| async getMembers(args = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| path: "/members/", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ...args, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix inconsistent field naming in the data object.
The data object uses inconsistent naming conventions - some fields use snake_case while others use title case. This could cause API errors if the Plecto API expects consistent formatting.
Please verify the expected field format from the Plecto API documentation and apply consistent naming:
data: { "data_source": this.dataSource, "member": this.member, "external_id": this.externalId, "date": this.date, - "Product Name": this.productName, - "Units Sold": this.unitsSold, + "product_name": this.productName, + "units_sold": this.unitsSold, },OR if the API expects title case for custom fields:
data: { - "data_source": this.dataSource, - "member": this.member, - "external_id": this.externalId, - "date": this.date, + "Data Source": this.dataSource, + "Member": this.member, + "External ID": this.externalId, + "Date": this.date, "Product Name": this.productName, "Units Sold": this.unitsSold, },🤖 Prompt for AI Agents
💡 Verification agent
🧩 Analysis chain
Verify the Plecto API registration endpoint data format.
Please confirm the expected field names and structure for the registration creation endpoint to ensure the data mapping is correct.
🌐 Web query:
💡 Result:
To create a registration in the Plecto API, certain fields are required while others are optional. The expected naming convention for fields is snake_case (all lowercase with underscores between words).
Required Fields in Plecto Registration
The following fields are required for creating a registration through the Plecto API:
Optional Fields
Field Naming Convention
Plecto uses snake_case for all field names in its API. This means all letters are lowercase and words are separated by underscores (e.g., "data_source", "external_id")[2][3]. This convention matches standard API practices for clarity and consistency, and no field names should be in Title Case or CamelCase.
Example Registration Payload
{ "data_source": "your-data-source-uuid", "external_id": "unique-registration-id", "member_api_provider": "your-system-name", "member_api_id": "employee-id-in-your-system", "member_name": "Employee Name", "date": "2025-06-30T18:00:00", "Value": 100, "custom_field_1": "custom_value" }Summary:
Citations:
Ensure Plecto API registration payload uses correct snake_case fields
Please update the payload to match Plecto’s snake_case naming convention and include the required member identifiers:
• Replace the single
"member"key with the two required fields:–
member_api_provider(e.g. your system name)–
member_api_id(the user’s ID in your system)• Convert custom field names from Title Case/with spaces to snake_case, matching your data‐source definitions (e.g.
"product_name","units_sold").• Confirm you still include the required metric field (often
"Value"or your custom equivalent) if that isn’t one of these custom fields.Proposed snippet:
data: { - "data_source": this.dataSource, - "member": this.member, - "external_id": this.externalId, - "date": this.date, - "Product Name": this.productName, - "Units Sold": this.unitsSold, + data_source: this.dataSource, + external_id: this.externalId, + member_api_provider: this.memberApiProvider, + member_api_id: this.memberApiId, + date: this.date, + product_name: this.productName, + units_sold: this.unitsSold, },📝 Committable suggestion
🤖 Prompt for AI Agents