Skip to content

Commit 3cbb2bc

Browse files
committed
[Components] evernote #15892
Sources - New Note - New Tag - New Notebook Actions - Create Note - Update Note - Create Notebook
1 parent 4d1afff commit 3cbb2bc

File tree

14 files changed

+586
-438
lines changed

14 files changed

+586
-438
lines changed
Lines changed: 87 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,107 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import { parseObject } from "../../common/utils.mjs";
13
import evernote from "../../evernote.app.mjs";
2-
import { axios } from "@pipedream/platform";
34

45
export default {
56
key: "evernote-create-note",
67
name: "Create Note",
7-
description: "Creates a new note in Evernote. [See the documentation]()",
8-
version: "0.0.{{ts}}",
8+
description: "Creates a new note in Evernote. [See the documentation](https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_createNote)",
9+
version: "0.0.1",
910
type: "action",
1011
props: {
1112
evernote,
12-
noteTitle: {
13-
propDefinition: [
14-
"evernote",
15-
"noteTitle",
16-
],
13+
title: {
14+
type: "string",
15+
label: "Title",
16+
description: "The subject of the note. Can't begin or end with a space.",
17+
},
18+
content: {
19+
type: "string",
20+
label: "Content",
21+
description: "The XHTML block that makes up the note. This is the canonical form of the note's contents, so will include abstract Evernote tags for internal resource references. A client may create a separate transformed version of this content for internal presentation, but the same canonical bytes should be used for transmission and comparison unless the user chooses to modify their content.",
22+
default: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"><en-note></en-note>",
23+
optional: true,
24+
},
25+
active: {
26+
type: "boolean",
27+
label: "Active",
28+
description: "If the note is available for normal actions and viewing",
29+
optional: true,
1730
},
18-
noteContent: {
31+
notebookGuid: {
1932
propDefinition: [
20-
"evernote",
21-
"noteContent",
33+
evernote,
34+
"notebookGuid",
2235
],
36+
optional: true,
2337
},
24-
noteAdditionalFields: {
38+
tagGuids: {
2539
propDefinition: [
26-
"evernote",
27-
"noteAdditionalFields",
40+
evernote,
41+
"tagGuids",
2842
],
2943
optional: true,
3044
},
45+
attributes: {
46+
type: "object",
47+
label: "Attributes",
48+
description: "A list of the attributes for this note. [See the documentation](https://dev.evernote.com/doc/reference/Types.html#Struct_NoteAttributes) for further details.",
49+
optional: true,
50+
},
51+
noUpdateTitle: {
52+
type: "boolean",
53+
label: "No Update Title",
54+
description: "The client may not update the note's title.",
55+
optional: true,
56+
},
57+
noUpdateContent: {
58+
type: "boolean",
59+
label: "No Update Content",
60+
description: "The client may not update the note's content. Content includes `content` and `resources`, as well as the related fields `contentHash` and `contentLength`.",
61+
optional: true,
62+
},
63+
noUpdateEmail: {
64+
type: "boolean",
65+
label: "No Update Email",
66+
description: "The client may not email the note.",
67+
optional: true,
68+
},
69+
noUpdateShare: {
70+
type: "boolean",
71+
label: "No Update Share",
72+
description: "The client may not share the note with specific recipients.",
73+
optional: true,
74+
},
75+
noUpdateSharePublicly: {
76+
type: "boolean",
77+
label: "No Update Share Publicly",
78+
description: "The client may not make the note public.",
79+
optional: true,
80+
},
3181
},
3282
async run({ $ }) {
33-
const note = await this.evernote.createNote();
34-
$.export("$summary", `Created note "${note.title}" with ID ${note.id}`);
35-
return note;
83+
try {
84+
const note = await this.evernote.createNote({
85+
title: this.title,
86+
content: this.content,
87+
active: this.active,
88+
notebookGuid: this.notebookGuid,
89+
tagGuids: this.tagGuids,
90+
resources: this.resources,
91+
attributes: parseObject(this.attributes),
92+
restrictions: {
93+
noUpdateTitle: this.noUpdateTitle,
94+
noUpdateContent: this.noUpdateContent,
95+
noUpdateEmail: this.noUpdateEmail,
96+
noUpdateShare: this.noUpdateShare,
97+
noUpdateSharePublicly: this.noUpdateSharePublicly,
98+
},
99+
});
100+
101+
$.export("$summary", `Created note "${note.title}" with ID ${note.guid}`);
102+
return note;
103+
} catch ({ parameter }) {
104+
throw new ConfigurationError(parameter);
105+
}
36106
},
37107
};
Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,69 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import { parseObject } from "../../common/utils.mjs";
13
import evernote from "../../evernote.app.mjs";
2-
import { axios } from "@pipedream/platform";
34

45
export default {
56
key: "evernote-create-notebook",
67
name: "Create Notebook",
7-
description: "Creates a new notebook in Evernote. [See the documentation]()",
8-
version: "0.0.{{ts}}",
8+
description: "Creates a new notebook in Evernote. [See the documentation](https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_createNotebook)",
9+
version: "0.0.1",
910
type: "action",
1011
props: {
1112
evernote,
12-
notebookName: {
13-
propDefinition: [
14-
"evernote",
15-
"notebookName",
16-
],
13+
name: {
14+
type: "string",
15+
label: "Name",
16+
description: "The name of the notebook.",
1717
},
18-
notebookAdditionalFields: {
19-
propDefinition: [
20-
"evernote",
21-
"notebookAdditionalFields",
22-
],
18+
defaultNotebook: {
19+
type: "boolean",
20+
label: "Default Notebook",
21+
description: "If true, this notebook should be used for new notes whenever the user has not (or cannot) specify a desired target notebook.",
2322
optional: true,
2423
},
24+
published: {
25+
type: "boolean",
26+
label: "Published",
27+
description: "If this is set to true, then the Notebook will be accessible either to the public, or for business users to their business, via the 'publishing' or 'businessNotebook' specifications, which must also be set. If this is set to false, the Notebook will not be available to the public (or business).",
28+
optional: true,
29+
reloadProps: true,
30+
},
31+
publishing: {
32+
type: "object",
33+
label: "Publishing",
34+
description: "If the Notebook has been opened for public access, then this will point to the set of publishing information for the Notebook (URI, description, etc.). A Notebook cannot be published without providing this information, but it will persist for later use if publishing is ever disabled on the Notebook. [See the documentation](https://dev.evernote.com/doc/reference/Types.html#Struct_Publishing) for further details.",
35+
hidden: true,
36+
},
37+
stack: {
38+
type: "string",
39+
label: "Stack",
40+
description: "If this is set, then the notebook is visually contained within a stack of notebooks with this name. All notebooks in the same account with the same 'stack' field are considered to be in the same stack. Notebooks with no stack set are \"top level\" and not contained within a stack.",
41+
optional: true,
42+
},
43+
},
44+
async additionalProps(props) {
45+
props.publishing.hidden = !this.published;
46+
47+
return {};
2548
},
2649
async run({ $ }) {
27-
const notebook = await this.evernote.createNotebook();
28-
$.export("$summary", `Created notebook ${notebook.name}`);
29-
return notebook;
50+
try {
51+
const data = {
52+
name: this.name,
53+
defaultNotebook: this.defaultNotebook,
54+
published: this.published,
55+
stack: this.stack,
56+
};
57+
const publishing = parseObject(this.publishing);
58+
if (publishing) data.publishing = publishing;
59+
const response = await this.evernote.createNotebook({
60+
...data,
61+
});
62+
63+
$.export("$summary", `Created notebook ${response.name} with ID: ${response.guid}`);
64+
return response;
65+
} catch ({ parameter }) {
66+
throw new ConfigurationError(parameter);
67+
}
3068
},
3169
};
Lines changed: 95 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,116 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import { parseObject } from "../../common/utils.mjs";
13
import evernote from "../../evernote.app.mjs";
2-
import { axios } from "@pipedream/platform";
34

45
export default {
56
key: "evernote-update-note",
67
name: "Update Note",
7-
description: "Updates an existing note in Evernote. [See the documentation](https://dev.evernote.com/doc/reference/notestore.html)",
8-
version: "0.0.{{ts}}",
8+
description: "Updates an existing note in Evernote. [See the documentation](https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_updateNote)",
9+
version: "0.0.1",
910
type: "action",
1011
props: {
1112
evernote,
1213
noteId: {
1314
propDefinition: [
14-
"evernote",
15+
evernote,
1516
"noteId",
1617
],
1718
},
18-
noteUpdateFields: {
19+
title: {
20+
type: "string",
21+
label: "Title",
22+
description: "The subject of the note. Can't begin or end with a space.",
23+
optional: true,
24+
},
25+
content: {
26+
type: "string",
27+
label: "Content",
28+
description: "The XHTML block that makes up the note. This is the canonical form of the note's contents, so will include abstract Evernote tags for internal resource references. A client may create a separate transformed version of this content for internal presentation, but the same canonical bytes should be used for transmission and comparison unless the user chooses to modify their content.",
29+
default: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"><en-note></en-note>",
30+
optional: true,
31+
},
32+
active: {
33+
type: "boolean",
34+
label: "Active",
35+
description: "If the note is available for normal actions and viewing",
36+
optional: true,
37+
},
38+
notebookGuid: {
1939
propDefinition: [
20-
"evernote",
21-
"noteUpdateFields",
40+
evernote,
41+
"notebookGuid",
2242
],
2343
optional: true,
2444
},
45+
tagGuids: {
46+
propDefinition: [
47+
evernote,
48+
"tagGuids",
49+
],
50+
optional: true,
51+
},
52+
attributes: {
53+
type: "object",
54+
label: "Attributes",
55+
description: "A list of the attributes for this note. [See the documentation](https://dev.evernote.com/doc/reference/Types.html#Struct_NoteAttributes) for further details.",
56+
optional: true,
57+
},
58+
noUpdateTitle: {
59+
type: "boolean",
60+
label: "No Update Title",
61+
description: "The client may not update the note's title.",
62+
optional: true,
63+
},
64+
noUpdateContent: {
65+
type: "boolean",
66+
label: "No Update Content",
67+
description: "The client may not update the note's content. Content includes `content` and `resources`, as well as the related fields `contentHash` and `contentLength`.",
68+
optional: true,
69+
},
70+
noUpdateEmail: {
71+
type: "boolean",
72+
label: "No Update Email",
73+
description: "The client may not email the note.",
74+
optional: true,
75+
},
76+
noUpdateShare: {
77+
type: "boolean",
78+
label: "No Update Share",
79+
description: "The client may not share the note with specific recipients.",
80+
optional: true,
81+
},
82+
noUpdateSharePublicly: {
83+
type: "boolean",
84+
label: "No Update Share Publicly",
85+
description: "The client may not make the note public.",
86+
optional: true,
87+
},
2588
},
2689
async run({ $ }) {
27-
const response = await this.evernote.updateNote();
28-
$.export("$summary", `Note ${this.noteId} updated successfully.`);
29-
return response;
90+
try {
91+
const response = await this.evernote.updateNote({
92+
guid: this.noteId,
93+
title: this.title,
94+
content: this.content,
95+
active: this.active,
96+
notebookGuid: this.notebookGuid,
97+
tagGuids: this.tagGuids,
98+
resources: this.resources,
99+
attributes: parseObject(this.attributes),
100+
restrictions: {
101+
noUpdateTitle: this.noUpdateTitle,
102+
noUpdateContent: this.noUpdateContent,
103+
noUpdateEmail: this.noUpdateEmail,
104+
noUpdateShare: this.noUpdateShare,
105+
noUpdateSharePublicly: this.noUpdateSharePublicly,
106+
},
107+
});
108+
$.export("$summary", `Note ${this.noteId} updated successfully.`);
109+
return response;
110+
} catch ({
111+
parameter, message,
112+
}) {
113+
throw new ConfigurationError(message || parameter);
114+
}
30115
},
31116
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const LIMIT = 100;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

0 commit comments

Comments
 (0)