Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions components/evernote/actions/create-note/create-note.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { ConfigurationError } from "@pipedream/platform";
import { parseObject } from "../../common/utils.mjs";
import evernote from "../../evernote.app.mjs";

export default {
key: "evernote-create-note",
name: "Create Note",
description: "Creates a new note in Evernote. [See the documentation](https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_createNote)",
version: "0.0.1",
type: "action",
props: {
evernote,
title: {
type: "string",
label: "Title",
description: "The subject of the note. Can't begin or end with a space.",
},
content: {
type: "string",
label: "Content",
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.",
default: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"><en-note></en-note>",
optional: true,
},
active: {
type: "boolean",
label: "Active",
description: "If the note is available for normal actions and viewing",
optional: true,
},
notebookGuid: {
propDefinition: [
evernote,
"notebookGuid",
],
optional: true,
},
tagGuids: {
propDefinition: [
evernote,
"tagGuids",
],
optional: true,
},
attributes: {
type: "object",
label: "Attributes",
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.",
optional: true,
},
noUpdateTitle: {
type: "boolean",
label: "No Update Title",
description: "The client may not update the note's title.",
optional: true,
},
noUpdateContent: {
type: "boolean",
label: "No Update Content",
description: "The client may not update the note's content. Content includes `content` and `resources`, as well as the related fields `contentHash` and `contentLength`.",
optional: true,
},
noUpdateEmail: {
type: "boolean",
label: "No Update Email",
description: "The client may not email the note.",
optional: true,
},
noUpdateShare: {
type: "boolean",
label: "No Update Share",
description: "The client may not share the note with specific recipients.",
optional: true,
},
noUpdateSharePublicly: {
type: "boolean",
label: "No Update Share Publicly",
description: "The client may not make the note public.",
optional: true,
},
},
async run({ $ }) {
try {
const note = await this.evernote.createNote({
title: this.title,
content: this.content,
active: this.active,
notebookGuid: this.notebookGuid,
tagGuids: this.tagGuids,
resources: this.resources,
attributes: parseObject(this.attributes),
restrictions: {
noUpdateTitle: this.noUpdateTitle,
noUpdateContent: this.noUpdateContent,
noUpdateEmail: this.noUpdateEmail,
noUpdateShare: this.noUpdateShare,
noUpdateSharePublicly: this.noUpdateSharePublicly,
},
});

$.export("$summary", `Created note "${note.title}" with ID ${note.guid}`);
return note;
} catch ({ parameter }) {
throw new ConfigurationError(parameter);
}
},
};
69 changes: 69 additions & 0 deletions components/evernote/actions/create-notebook/create-notebook.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { ConfigurationError } from "@pipedream/platform";
import { parseObject } from "../../common/utils.mjs";
import evernote from "../../evernote.app.mjs";

export default {
key: "evernote-create-notebook",
name: "Create Notebook",
description: "Creates a new notebook in Evernote. [See the documentation](https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_createNotebook)",
version: "0.0.1",
type: "action",
props: {
evernote,
name: {
type: "string",
label: "Name",
description: "The name of the notebook.",
},
defaultNotebook: {
type: "boolean",
label: "Default Notebook",
description: "If true, this notebook should be used for new notes whenever the user has not (or cannot) specify a desired target notebook.",
optional: true,
},
published: {
type: "boolean",
label: "Published",
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).",
optional: true,
reloadProps: true,
},
publishing: {
type: "object",
label: "Publishing",
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.",
hidden: true,
},
stack: {
type: "string",
label: "Stack",
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.",
optional: true,
},
},
async additionalProps(props) {
props.publishing.hidden = !this.published;

return {};
},
async run({ $ }) {
try {
const data = {
name: this.name,
defaultNotebook: this.defaultNotebook,
published: this.published,
stack: this.stack,
};
const publishing = parseObject(this.publishing);
if (publishing) data.publishing = publishing;
const response = await this.evernote.createNotebook({
...data,
});

$.export("$summary", `Created notebook ${response.name} with ID: ${response.guid}`);
return response;
} catch ({ parameter }) {
throw new ConfigurationError(parameter);
}
},
};
116 changes: 116 additions & 0 deletions components/evernote/actions/update-note/update-note.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { ConfigurationError } from "@pipedream/platform";
import { parseObject } from "../../common/utils.mjs";
import evernote from "../../evernote.app.mjs";

export default {
key: "evernote-update-note",
name: "Update Note",
description: "Updates an existing note in Evernote. [See the documentation](https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_updateNote)",
version: "0.0.1",
type: "action",
props: {
evernote,
noteId: {
propDefinition: [
evernote,
"noteId",
],
},
title: {
type: "string",
label: "Title",
description: "The subject of the note. Can't begin or end with a space.",
optional: true,
},
content: {
type: "string",
label: "Content",
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.",
default: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"><en-note></en-note>",
optional: true,
},
active: {
type: "boolean",
label: "Active",
description: "If the note is available for normal actions and viewing",
optional: true,
},
notebookGuid: {
propDefinition: [
evernote,
"notebookGuid",
],
optional: true,
},
tagGuids: {
propDefinition: [
evernote,
"tagGuids",
],
optional: true,
},
attributes: {
type: "object",
label: "Attributes",
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.",
optional: true,
},
noUpdateTitle: {
type: "boolean",
label: "No Update Title",
description: "The client may not update the note's title.",
optional: true,
},
noUpdateContent: {
type: "boolean",
label: "No Update Content",
description: "The client may not update the note's content. Content includes `content` and `resources`, as well as the related fields `contentHash` and `contentLength`.",
optional: true,
},
noUpdateEmail: {
type: "boolean",
label: "No Update Email",
description: "The client may not email the note.",
optional: true,
},
noUpdateShare: {
type: "boolean",
label: "No Update Share",
description: "The client may not share the note with specific recipients.",
optional: true,
},
noUpdateSharePublicly: {
type: "boolean",
label: "No Update Share Publicly",
description: "The client may not make the note public.",
optional: true,
},
},
async run({ $ }) {
try {
const response = await this.evernote.updateNote({
guid: this.noteId,
title: this.title,
content: this.content,
active: this.active,
notebookGuid: this.notebookGuid,
tagGuids: this.tagGuids,
resources: this.resources,
attributes: parseObject(this.attributes),
restrictions: {
noUpdateTitle: this.noUpdateTitle,
noUpdateContent: this.noUpdateContent,
noUpdateEmail: this.noUpdateEmail,
noUpdateShare: this.noUpdateShare,
noUpdateSharePublicly: this.noUpdateSharePublicly,
},
});
$.export("$summary", `Note ${this.noteId} updated successfully.`);
return response;
} catch ({
parameter, message,
}) {
throw new ConfigurationError(message || parameter);
}
},
};
1 change: 1 addition & 0 deletions components/evernote/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const LIMIT = 100;
24 changes: 24 additions & 0 deletions components/evernote/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const parseObject = (obj) => {
if (!obj) return undefined;

if (Array.isArray(obj)) {
return obj.map((item) => {
if (typeof item === "string") {
try {
return JSON.parse(item);
} catch (e) {
return item;
}
}
return item;
});
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch (e) {
return obj;
}
}
return obj;
};
Loading
Loading