Skip to content

Commit 173a495

Browse files
committed
Implement CRUD operations for documents in Dart, including create, update, and delete functionalities. Add new properties for document management and update package version to 0.2.0. Enhance existing actions for task management with version updates.
1 parent ffab7aa commit 173a495

File tree

11 files changed

+209
-10
lines changed

11 files changed

+209
-10
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import dart from "../../dart.app.mjs";
2+
3+
export default {
4+
key: "dart-create-doc",
5+
name: "Create Doc",
6+
description: "Record a new doc that the user intends to write down. This will save the doc in Dart for later access, search, etc. By default the created doc will be in the Docs folder. More information can be included in the text. [See the documentation](https://app.dartai.com/api/v0/public/docs/#/Doc/createDoc)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
dart,
16+
title: {
17+
propDefinition: [
18+
dart,
19+
"title",
20+
],
21+
},
22+
folder: {
23+
propDefinition: [
24+
dart,
25+
"folder",
26+
],
27+
},
28+
text: {
29+
propDefinition: [
30+
dart,
31+
"text",
32+
],
33+
},
34+
},
35+
async run({ $ }) {
36+
const response = await this.dart.createDoc({
37+
$,
38+
data: {
39+
item: {
40+
title: this.title,
41+
folder: this.folder,
42+
text: this.text,
43+
},
44+
},
45+
});
46+
47+
$.export("$summary", `New doc successfully created with ID: ${response.item.id}`);
48+
return response;
49+
},
50+
};

components/dart/actions/create-task/create-task.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "dart-create-task",
55
name: "Create Task",
66
description: "Creates a new task within a dartboard. [See the documentation](https://app.itsdart.com/api/v0/docs/)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import dart from "../../dart.app.mjs";
2+
3+
export default {
4+
key: "dart-delete-doc",
5+
name: "Delete Doc",
6+
description: "Move an existing doc to the trash, where it can be recovered if needed. Nothing else about the doc will be changed. [See the documentation](https://app.dartai.com/api/v0/public/docs/#/Doc/deleteDoc)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
dart,
16+
docId: {
17+
propDefinition: [
18+
dart,
19+
"docId",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.dart.deleteDoc({
25+
$,
26+
docId: this.docId,
27+
});
28+
29+
$.export("$summary", `Successfully deleted doc with ID: ${this.docId}`);
30+
return response;
31+
},
32+
};

components/dart/actions/find-or-create-task/find-or-create-task.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "dart-find-or-create-task",
55
name: "Find or Create Task",
66
description: "Checks for an existing task within a dartboard using the 'task-name'. If it doesn't exist, a new task is created. [See the documentation](https://app.itsdart.com/api/v0/docs/)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import dart from "../../dart.app.mjs";
2+
3+
export default {
4+
key: "dart-update-doc",
5+
name: "Update Doc",
6+
description: "Update certain properties of an existing doc. This will save the doc in Dart for later access, search, etc. Any properties that are not specified will not be changed. [See the documentation](https://app.dartai.com/api/v0/public/docs/#/Doc/updateDoc)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
dart,
16+
docId: {
17+
propDefinition: [
18+
dart,
19+
"docId",
20+
],
21+
},
22+
title: {
23+
propDefinition: [
24+
dart,
25+
"title",
26+
],
27+
optional: true,
28+
},
29+
folder: {
30+
propDefinition: [
31+
dart,
32+
"folder",
33+
],
34+
},
35+
text: {
36+
propDefinition: [
37+
dart,
38+
"text",
39+
],
40+
},
41+
},
42+
async run({ $ }) {
43+
const response = await this.dart.updateDoc({
44+
$,
45+
data: {
46+
item: {
47+
id: this.docId,
48+
title: this.title,
49+
folder: this.folder,
50+
text: this.text,
51+
},
52+
},
53+
});
54+
55+
$.export("$summary", `Successfully updated doc with ID: ${this.docId}`);
56+
return response;
57+
},
58+
};

components/dart/actions/update-task/update-task.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "dart-update-task",
55
name: "Update Task",
66
description: "Updates an existing task within a dartboard. [See the documentation](https://app.itsdart.com/api/v0/docs/)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
annotations: {
99
destructiveHint: true,
1010
openWorldHint: true,

components/dart/dart.app.mjs

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,25 @@ export default {
6363
})) || [];
6464
},
6565
},
66+
docId: {
67+
type: "string",
68+
label: "Doc ID",
69+
description: "The ID of the doc",
70+
async options({ page }) {
71+
const { results } = await this.listDocs({
72+
params: {
73+
limit: constants.DEFAULT_LIMIT,
74+
offset: page * constants.DEFAULT_LIMIT,
75+
},
76+
});
77+
return results?.map(({
78+
id: value, title: label,
79+
}) => ({
80+
value,
81+
label,
82+
})) || [];
83+
},
84+
},
6685
taskName: {
6786
type: "string",
6887
label: "Task Name",
@@ -87,10 +106,27 @@ export default {
87106
optional: true,
88107
options: constants.TASK_PRIORITIES,
89108
},
109+
title: {
110+
type: "string",
111+
label: "Title",
112+
description: "The title, which is a short description of the doc",
113+
},
114+
folder: {
115+
type: "string",
116+
label: "Folder",
117+
description: "The full title of the folder, which is a project or list of docs",
118+
optional: true,
119+
},
120+
text: {
121+
type: "string",
122+
label: "Text",
123+
description: "The full content of the doc, which can include markdown formatting",
124+
optional: true,
125+
},
90126
},
91127
methods: {
92128
_baseUrl() {
93-
return "https://app.itsdart.com/api/v0";
129+
return "https://app.dartai.com/api/v0/public";
94130
},
95131
_makeRequest(opts = {}) {
96132
const {
@@ -108,7 +144,7 @@ export default {
108144
},
109145
listDocs(opts = {}) {
110146
return this._makeRequest({
111-
path: "/docs",
147+
path: "/docs/list",
112148
...opts,
113149
});
114150
},
@@ -137,6 +173,29 @@ export default {
137173
...opts,
138174
});
139175
},
176+
createDoc(opts = {}) {
177+
return this._makeRequest({
178+
method: "POST",
179+
path: "/docs",
180+
...opts,
181+
});
182+
},
183+
updateDoc(opts = {}) {
184+
return this._makeRequest({
185+
method: "PUT",
186+
path: `/docs/${opts.data.item.id}`,
187+
...opts,
188+
});
189+
},
190+
deleteDoc({
191+
docId, ...opts
192+
}) {
193+
return this._makeRequest({
194+
method: "DELETE",
195+
path: `/docs/${docId}`,
196+
...opts,
197+
});
198+
},
140199
async *paginate({
141200
resourceFn, params, max,
142201
}) {

components/dart/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/dart",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Dart Components",
55
"main": "dart.app.mjs",
66
"keywords": [
@@ -13,6 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^3.0.0"
16+
"@pipedream/platform": "^3.1.0"
1717
}
1818
}

components/dart/sources/new-doc-created/new-doc-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "dart-new-doc-created",
77
name: "New Document Created",
88
description: "Emit new event when a new document is created in Dart.",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
type: "source",
1111
dedupe: "unique",
1212
methods: {

components/dart/sources/new-doc-updated/new-doc-updated.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "dart-new-doc-updated",
88
name: "New Document Updated",
99
description: "Emit new event when any document is updated.",
10-
version: "0.0.1",
10+
version: "0.0.2",
1111
dedupe: "unique",
1212
methods: {
1313
...common.methods,

0 commit comments

Comments
 (0)