Skip to content

Commit

Permalink
New Components - v7_go (#12949)
Browse files Browse the repository at this point in the history
* v7_go init

* [Components] v7_go #12930
Sources
 - New Entity (Instant)
 - New Complete Entity (Instant)
 - New Complete Field (Instant)

Actions
 - Create Project
 - Create Entity
 - Update Entity

* pnpm update
  • Loading branch information
luancazarine authored Jul 25, 2024
1 parent 1538170 commit 9826e64
Show file tree
Hide file tree
Showing 14 changed files with 685 additions and 8 deletions.
56 changes: 56 additions & 0 deletions components/v7_go/actions/create-entity/create-entity.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import v7Go from "../../v7_go.app.mjs";

export default {
key: "v7_go-create-entity",
name: "Create Entity",
description: "Triggers the creation of a new entity. [See the documentation](https://docs.go.v7labs.com/reference/create-entities-programmatically)",
version: "0.0.1",
type: "action",
props: {
v7Go,
workspaceId: {
propDefinition: [
v7Go,
"workspaceId",
],
},
projectId: {
propDefinition: [
v7Go,
"projectId",
({ workspaceId }) => ({
workspaceId,
}),
],
reloadProps: true,
},
},
async additionalProps() {
if (this.projectId) {
return await this.v7Go.prepareProps({
workspaceId: this.workspaceId,
projectId: this.projectId,
});
}
},
async run({ $ }) {
const {
v7Go,
workspaceId,
projectId,
...fields
} = this;

const response = await v7Go.createEntity({
$,
workspaceId,
projectId,
data: {
fields: v7Go.parseObject(fields),
},
});

$.export("$summary", `Successfully created entity with ID ${response.id}`);
return response;
},
};
34 changes: 34 additions & 0 deletions components/v7_go/actions/create-project/create-project.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import v7Go from "../../v7_go.app.mjs";

export default {
key: "v7_go-create-project",
name: "Create Project",
description: "Initiates the creation of a new project with a unique project identifier. [See the documentation](https://docs.go.v7labs.com/reference/project-create)",
version: "0.0.1",
type: "action",
props: {
v7Go,
workspaceId: {
propDefinition: [
v7Go,
"workspaceId",
],
},
name: {
type: "string",
label: "Name",
description: "The name of the project.",
},
},
async run({ $ }) {
const response = await this.v7Go.createProject({
$,
workspaceId: this.workspaceId,
data: {
name: this.name,
},
});
$.export("$summary", `Successfully created project with ID ${response.id}`);
return response;
},
};
71 changes: 71 additions & 0 deletions components/v7_go/actions/update-entity/update-entity.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import v7Go from "../../v7_go.app.mjs";

export default {
key: "v7_go-update-entity",
name: "Update Entity",
description: "Executes an update on an existing entity. [See the documentation](https://docs.go.v7labs.com/reference/entity-update-values)",
version: "0.0.1",
type: "action",
props: {
v7Go,
workspaceId: {
propDefinition: [
v7Go,
"workspaceId",
],
},
projectId: {
propDefinition: [
v7Go,
"projectId",
({ workspaceId }) => ({
workspaceId,
}),
],
},
entityId: {
propDefinition: [
v7Go,
"entityId",
({
workspaceId, projectId,
}) => ({
workspaceId,
projectId,
}),
],
reloadProps: true,
},
},
async additionalProps() {
if (this.entityId) {
return await this.v7Go.prepareProps({
workspaceId: this.workspaceId,
projectId: this.projectId,
entityId: this.entityId,
});
}
},
async run({ $ }) {
const {
v7Go,
workspaceId,
projectId,
entityId,
...fields
} = this;

const response = await v7Go.updateEntity({
$,
workspaceId,
projectId,
entityId,
data: {
fields: v7Go.parseObject(fields),
},
});

$.export("$summary", `Successfully updated entity with ID ${response.id}`);
return response;
},
};
1 change: 1 addition & 0 deletions components/v7_go/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const LIMIT = 100;
8 changes: 6 additions & 2 deletions components/v7_go/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/v7_go",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream V7 Go Components",
"main": "v7_go.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,9 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.0"
}
}
}

58 changes: 58 additions & 0 deletions components/v7_go/sources/common/base.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import v7Go from "../../v7_go.app.mjs";

export default {
props: {
v7Go,
http: {
type: "$.interface.http",
customResponse: false,
},
db: "$.service.db",
workspaceId: {
propDefinition: [
v7Go,
"workspaceId",
],
},
projectId: {
propDefinition: [
v7Go,
"projectId",
({ workspaceId }) => ({
workspaceId,
}),
],
},
},
hooks: {
async activate() {
const data = await this.v7Go.createWebhook({
workspaceId: this.workspaceId,
data: {
action: {
type: "webhook",
url: this.http.endpoint,
},
events: this.getEvents(),
project_id: this.projectId,
},
});
this.db.set("webhookId", data.id);
},
async deactivate() {
const webhookId = this.db.get("webhookId");
await this.v7Go.deleteWebhook({
workspaceId: this.workspaceId,
webhookId,
});
},
},
async run({ body }) {
const ts = Date.parse(new Date());
this.$emit(body, {
id: `${body.entity.id}-${ts}`,
summary: this.getSummary(body),
ts: ts,
});
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "v7_go-complete-entity-instant",
name: "New Complete Entity (Instant)",
description: "Emit new event when all fields of an entity are completed in V7 Go.",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEvents() {
return {
"entity.all_fields_completed": true,
};
},
getSummary({ entity }) {
return `Entity all fields completed: ${entity.id}`;
},
},
sampleEmit,
};
25 changes: 25 additions & 0 deletions components/v7_go/sources/complete-entity-instant/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export default {
"type": "entity.all_fields_completed",
"entity": {
"id": "12345678-1234-1234-1234-123456789012",
"fields": {
"text-field-test": {
"data": {
"value": "field value",
"value_type": "manual",
"additional_value": null,
"additional_value_type": null
},
"status": "complete",
"error_message": null,
"inserted_at": "2024-07-23T14:28:53.480497Z",
"updated_at": "2024-07-23T14:28:55.255082Z",
"property_id": "12345678-1234-1234-1234-123456789012",
"property_type": "text"
}
},
"inserted_at": "2024-07-23T14:28:53.479981Z",
"updated_at": "2024-07-23T14:28:53.479981Z",
"project_id": "12345678-1234-1234-1234-123456789012"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "v7_go-complete-field-instant",
name: "New Field Completion (Instant)",
description: "Emit new event when a field within an entity is completed in V7 Go.",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEvents() {
return {
"entity.field_completed": true,
};
},
getSummary({ entity }) {
return `Field completed for entity ${entity.id}`;
},
},
sampleEmit,
};
39 changes: 39 additions & 0 deletions components/v7_go/sources/complete-field-instant/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export default {
"type": "entity.field_completed",
"entity": {
"id": "12345678-1234-1234-1234-123456789012",
"fields": {
"text-field-test-1": {
"data": {
"value": "field value",
"value_type": "manual",
"additional_value": null,
"additional_value_type": null
},
"status": "complete",
"error_message": null,
"inserted_at": "2024-07-23T14:35:21.061761Z",
"updated_at": "2024-07-23T14:35:37.057732Z",
"property_id": "12345678-1234-1234-1234-123456789012",
"property_type": "text"
},
"text-field-test-2": {
"data": {
"value": "field value",
"value_type": "manual",
"additional_value": null,
"additional_value_type": null
},
"status": "complete",
"error_message": null,
"inserted_at": "2024-07-23T14:28:53.480497Z",
"updated_at": "2024-07-23T14:28:55.255082Z",
"property_id": "12345678-1234-1234-1234-123456789012",
"property_type": "text"
}
},
"inserted_at": "2024-07-23T14:28:53.479981Z",
"updated_at": "2024-07-23T14:28:53.479981Z",
"project_id": "12345678-1234-1234-1234-123456789012"
}
}
24 changes: 24 additions & 0 deletions components/v7_go/sources/new-entity-instant/new-entity-instant.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "v7_go-new-entity-instant",
name: "New Entity Created (Instant)",
description: "Emit new event when an entity is created.",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEvents() {
return {
"entity.created": true,
};
},
getSummary({ entity }) {
return `New entity created: ${entity.id}`;
},
},
sampleEmit,
};
Loading

0 comments on commit 9826e64

Please sign in to comment.