-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] elevio - new components #15517
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
128 changes: 128 additions & 0 deletions
128
components/elevio/actions/create-article/create-article.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| import app from "../../elevio.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "elevio-create-article", | ||
| name: "Create Article", | ||
| description: "Creates a new article in the Elevio knowledge base. [See the documentation](https://api-docs.elevio.help/en/articles/71-rest-api-articles).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| categoryId: { | ||
| propDefinition: [ | ||
| app, | ||
| "categoryId", | ||
| ], | ||
| }, | ||
| restriction: { | ||
| propDefinition: [ | ||
| app, | ||
| "restriction", | ||
| ], | ||
| }, | ||
| discoverable: { | ||
| propDefinition: [ | ||
| app, | ||
| "discoverable", | ||
| ], | ||
| }, | ||
| isInternal: { | ||
| propDefinition: [ | ||
| app, | ||
| "isInternal", | ||
| ], | ||
| }, | ||
| notes: { | ||
| propDefinition: [ | ||
| app, | ||
| "notes", | ||
| ], | ||
| }, | ||
| status: { | ||
| propDefinition: [ | ||
| app, | ||
| "status", | ||
| ], | ||
| }, | ||
| title: { | ||
| propDefinition: [ | ||
| app, | ||
| "title", | ||
| ], | ||
| }, | ||
| body: { | ||
| propDefinition: [ | ||
| app, | ||
| "body", | ||
| ], | ||
| }, | ||
| keywords: { | ||
| propDefinition: [ | ||
| app, | ||
| "keywords", | ||
| ], | ||
| }, | ||
| tags: { | ||
| propDefinition: [ | ||
| app, | ||
| "tags", | ||
| ], | ||
| }, | ||
| externalId: { | ||
| propDefinition: [ | ||
| app, | ||
| "externalId", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| createArticle(args = {}) { | ||
| return this.app.post({ | ||
| path: "/articles", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| createArticle, | ||
| externalId, | ||
| restriction, | ||
| discoverable, | ||
| isInternal, | ||
| notes, | ||
| status, | ||
| title, | ||
| body, | ||
| keywords, | ||
| tags, | ||
| categoryId, | ||
| } = this; | ||
| const response = await createArticle({ | ||
| $, | ||
| data: { | ||
| article: { | ||
| external_id: externalId, | ||
| restriction, | ||
| discoverable, | ||
| is_internal: isInternal, | ||
| notes, | ||
| status, | ||
| category_id: categoryId, | ||
| keywords, | ||
| tags, | ||
| translations: [ | ||
| { | ||
| language_id: "en", | ||
| title, | ||
| body, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }); | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| $.export("$summary", `Successfully created article with ID \`${response.article.id}\`.`); | ||
| return response; | ||
| }, | ||
| }; | ||
41 changes: 41 additions & 0 deletions
41
components/elevio/actions/delete-article/delete-article.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import app from "../../elevio.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "elevio-delete-article", | ||
| name: "Delete Article", | ||
| description: "Deletes an existing article from the Elevio knowledge base. [See the documentation](https://api-docs.elevio.help/en/articles/71-rest-api-articles).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| articleId: { | ||
| propDefinition: [ | ||
| app, | ||
| "articleId", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| deleteArticle({ | ||
| articleId, ...args | ||
| }) { | ||
| return this.app.delete({ | ||
| path: `/articles/${articleId}`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| deleteArticle, | ||
| articleId, | ||
| } = this; | ||
|
|
||
| const response = await deleteArticle({ | ||
| $, | ||
| articleId, | ||
| }); | ||
| $.export("$summary", "Successfully deleted article."); | ||
| return response; | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
149 changes: 149 additions & 0 deletions
149
components/elevio/actions/update-article/update-article.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| import app from "../../elevio.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "elevio-update-article", | ||
| name: "Update Article", | ||
| description: "Updates an existing article in the Elevio knowledge base. [See the documentation](https://api-docs.elevio.help/en/articles/71-rest-api-articles).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| articleId: { | ||
| propDefinition: [ | ||
| app, | ||
| "articleId", | ||
| ], | ||
| }, | ||
| categoryId: { | ||
| propDefinition: [ | ||
| app, | ||
| "categoryId", | ||
| ], | ||
| }, | ||
| restriction: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "restriction", | ||
| ], | ||
| }, | ||
| discoverable: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "discoverable", | ||
| ], | ||
| }, | ||
| isInternal: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "isInternal", | ||
| ], | ||
| }, | ||
| notes: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "notes", | ||
| ], | ||
| }, | ||
| status: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "status", | ||
| ], | ||
| }, | ||
| title: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "title", | ||
| ], | ||
| }, | ||
| body: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "body", | ||
| ], | ||
| }, | ||
| keywords: { | ||
| propDefinition: [ | ||
| app, | ||
| "keywords", | ||
| ], | ||
| }, | ||
| tags: { | ||
| propDefinition: [ | ||
| app, | ||
| "tags", | ||
| ], | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| externalId: { | ||
| propDefinition: [ | ||
| app, | ||
| "externalId", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| updateArticle({ | ||
| articleId, ...args | ||
| } = {}) { | ||
| return this.app.put({ | ||
| path: `/articles/${articleId}`, | ||
| ...args, | ||
| }); | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| updateArticle, | ||
| articleId, | ||
| externalId, | ||
| restriction, | ||
| discoverable, | ||
| isInternal, | ||
| notes, | ||
| status, | ||
| title, | ||
| body, | ||
| keywords, | ||
| tags, | ||
| categoryId, | ||
| } = this; | ||
| const response = await updateArticle({ | ||
| $, | ||
| articleId, | ||
| data: { | ||
| article: { | ||
| external_id: externalId, | ||
| restriction, | ||
| discoverable, | ||
| is_internal: isInternal, | ||
| notes, | ||
| status, | ||
| keywords, | ||
| tags, | ||
| category_id: categoryId, | ||
| ...((title || body) | ||
| ? { | ||
| translations: [ | ||
| { | ||
| language_id: "en", | ||
| title, | ||
| body, | ||
| }, | ||
| ], | ||
| } | ||
| : {}), | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully updated article with ID \`${response.article.id}\`.`); | ||
| return response; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| const BASE_URL = "https://api.elev.io"; | ||
| const VERSION_PATH = "/v1"; | ||
| const IS_FIRST_RUN = "isFirstRun"; | ||
| const LAST_DATE_AT = "lastDateAt"; | ||
| const DEFAULT_LIMIT = 100; | ||
| const DEFAULT_MAX = 600; | ||
|
|
||
| export default { | ||
| BASE_URL, | ||
| VERSION_PATH, | ||
| IS_FIRST_RUN, | ||
| LAST_DATE_AT, | ||
| DEFAULT_LIMIT, | ||
| DEFAULT_MAX, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| async function iterate(iterations) { | ||
| const items = []; | ||
| for await (const item of iterations) { | ||
| items.push(item); | ||
| } | ||
| return items; | ||
| } | ||
|
|
||
| function getNestedProperty(obj, propertyString) { | ||
| const properties = propertyString.split("."); | ||
| return properties.reduce((prev, curr) => prev?.[curr], obj); | ||
| } | ||
|
|
||
| export default { | ||
| iterate, | ||
| getNestedProperty, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.