diff --git a/components/document360/actions/create-document/create-document.mjs b/components/document360/actions/create-document/create-document.mjs index 5d772097f337f..17e9de3dcf850 100644 --- a/components/document360/actions/create-document/create-document.mjs +++ b/components/document360/actions/create-document/create-document.mjs @@ -4,7 +4,7 @@ export default { key: "document360-create-document", name: "Create Document", description: "Creates a new document in Document360 from text. [See the documentation](https://apidocs.document360.com/apidocs/how-to-create-and-publish-an-article)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { document360, @@ -34,6 +34,26 @@ export default { "userId", ], }, + contentType: { + type: "string", + label: "Content Type", + description: "The type of content of the new document.", + options: [ + { + value: "0", + label: "Markdown", + }, + { + value: "1", + label: "WYSIWYG(HTML)", + }, + { + value: "2", + label: "Advanced WYSIWYG(HTML)", + }, + ], + optional: true, + }, content: { type: "string", label: "Document Content", @@ -56,6 +76,7 @@ export default { user_id: this.userId, content: this.content, order: this.order, + content_type: this.contentType, }, }); diff --git a/components/document360/actions/drive-search-files-and-folders/drive-search-files-and-folders.mjs b/components/document360/actions/drive-search-files-and-folders/drive-search-files-and-folders.mjs new file mode 100644 index 0000000000000..0cd46f666924d --- /dev/null +++ b/components/document360/actions/drive-search-files-and-folders/drive-search-files-and-folders.mjs @@ -0,0 +1,93 @@ +import app from "../../document360.app.mjs"; + +export default { + key: "document360-drive-search-files-and-folders", + name: "Drive Search - Files and Folders", + description: "Search for files and folders in Document360 Drive. [See the documentation](https://apidocs.document360.com/apidocs/drive-search-files-and-folders)", + version: "0.0.1", + type: "action", + props: { + app, + searchKeyword: { + type: "string", + label: "Search Keyword", + description: "Keyword to search file items from drive", + }, + pageNo: { + type: "integer", + label: "Page Number", + description: "Specify the page to retrieve. Page numbers are zero-based. Therefore, to retrieve the 10th page, you need to set `9`", + optional: true, + }, + take: { + type: "integer", + label: "Take", + description: "The number of results per page", + optional: true, + }, + allowImagesOnly: { + type: "boolean", + label: "Allow Images Only", + description: "Allow images only in response", + optional: true, + }, + userIds: { + type: "string[]", + label: "User IDs", + description: "Find by userId", + optional: true, + propDefinition: [ + app, + "userId", + ], + }, + filterFromDate: { + type: "string", + label: "Filter From Date", + description: "Filter using from-date (date-time format). Example: `2025-01-01T00:00:00Z`", + optional: true, + }, + filterToDate: { + type: "string", + label: "Filter To Date", + description: "Filter using to-date (date-time format). Example: `2025-01-01T00:00:00Z`", + optional: true, + }, + filterTags: { + type: "string[]", + label: "Filter Tags", + description: "Filter using tagIds", + optional: true, + }, + }, + async run({ $ }) { + const { + app, + searchKeyword, + pageNo, + take, + allowImagesOnly, + userIds, + filterFromDate, + filterToDate, + filterTags, + } = this; + + const response = await app.driveSearchFilesAndFolders({ + $, + params: { + searchKeyword, + pageNo, + take, + allowImagesOnly, + userIds, + filterFromDate, + filterToDate, + filterTags, + }, + }); + + $.export("$summary", `Successfully searched for files and folders with keyword \`${searchKeyword}\``); + return response; + }, +}; diff --git a/components/document360/actions/get-article/get-article.mjs b/components/document360/actions/get-article/get-article.mjs new file mode 100644 index 0000000000000..d4abcde0df3ea --- /dev/null +++ b/components/document360/actions/get-article/get-article.mjs @@ -0,0 +1,79 @@ +import app from "../../document360.app.mjs"; + +export default { + key: "document360-get-article", + name: "Get Article", + description: "Gets an article from Document360. [See the documentation](https://apidocs.document360.com/apidocs/get-article)", + version: "0.0.1", + type: "action", + props: { + app, + projectVersionId: { + propDefinition: [ + app, + "projectVersionId", + ], + }, + articleId: { + propDefinition: [ + app, + "articleId", + ({ projectVersionId }) => ({ + projectVersionId, + }), + ], + }, + langCode: { + propDefinition: [ + app, + "langCode", + ({ projectVersionId }) => ({ + projectVersionId, + }), + ], + default: "en", + }, + isForDisplay: { + type: "boolean", + label: "Is For Display", + description: "Set this to `true`, if you are displaying the article to the end-user. If `, the content of snippets or variables appears in the article. Note: If the value is true, ensure that the article content is not passed for update article endpoints.", + optional: true, + }, + isPublished: { + type: "boolean", + label: "Is Published", + description: "`true` : You will get the latest published version of the article. (If there are no published versions, then it will return the latest version) `false` : To get the the latest version of the article", + optional: true, + }, + appendSASToken: { + type: "boolean", + label: "Append SAS Token", + description: "Set this to `false` to exclude appending SAS token for images/files", + optional: true, + }, + }, + async run({ $ }) { + const { + app, + articleId, + langCode, + isForDisplay, + isPublished, + appendSASToken, + } = this; + + const response = await app.getArticle({ + $, + articleId, + langCode, + params: { + isForDisplay, + isPublished, + appendSASToken, + }, + }); + + $.export("$summary", `Successfully retrieved article ID \`${articleId}\` (${langCode})`); + return response; + }, +}; diff --git a/components/document360/actions/get-file-information/get-file-information.mjs b/components/document360/actions/get-file-information/get-file-information.mjs new file mode 100644 index 0000000000000..07c3b51c7b2bb --- /dev/null +++ b/components/document360/actions/get-file-information/get-file-information.mjs @@ -0,0 +1,53 @@ +import app from "../../document360.app.mjs"; + +export default { + key: "document360-get-file-information", + name: "Get File Information", + description: "Gets file information from Document360 Drive. [See the documentation](https://apidocs.document360.com/apidocs/gets-file-information)", + version: "0.0.1", + type: "action", + props: { + app, + folderId: { + propDefinition: [ + app, + "folderId", + ], + }, + fileId: { + propDefinition: [ + app, + "fileId", + ({ folderId }) => ({ + folderId, + }), + ], + }, + appendSASToken: { + type: "boolean", + label: "Append SAS Token", + description: "Set this to false to exclude appending SAS token for images/files", + optional: true, + }, + }, + async run({ $ }) { + const { + app, + folderId, + fileId, + appendSASToken, + } = this; + + const response = await app.getFileInformation({ + $, + folderId, + fileId, + params: { + appendSASToken, + }, + }); + + $.export("$summary", `Successfully retrieved file information for file ID \`${fileId}\``); + return response; + }, +}; diff --git a/components/document360/document360.app.mjs b/components/document360/document360.app.mjs index c88aebb481a71..8dd22c8328345 100644 --- a/components/document360/document360.app.mjs +++ b/components/document360/document360.app.mjs @@ -34,11 +34,77 @@ export default { type: "string", label: "User ID", description: "Select a User or provide a custom User ID.", + async options({ page }) { + const users = await this.getUsers({ + params: { + skip: page * 100, + take: 100, + }, + }); + return users?.result?.map?.(({ + first_name, last_name, user_id, + }) => ({ + label: `${first_name || ""} ${last_name || ""}`.trim() || user_id, + value: user_id, + })) ?? []; + }, + }, + folderId: { + type: "string", + label: "Folder ID", + description: "Select a Folder or provide a custom Folder ID.", async options() { - const users = await this.getUsers(); - return users?.result?.map?.((user) => ({ - label: `${user.first_name} ${user.last_name} (${user.email_id})`, - value: user.user_id, + const folders = await this.getFolders(); + return this._flattenFolders(folders?.data) ?? []; + }, + }, + fileId: { + type: "string", + label: "File ID", + description: "Select a File or provide a custom File ID.", + async options({ folderId }) { + if (!folderId) { + return []; + } + const folderInfo = await this.getFolderInformation({ + folderId, + debug: true, + }); + return folderInfo?.data?.files?.map?.(({ + id: value, file_name: label, + }) => ({ + label, + value, + })) ?? []; + }, + }, + articleId: { + type: "string", + label: "Article ID", + description: "Select an Article or provide a custom Article ID.", + async options({ projectVersionId }) { + if (!projectVersionId) { + return []; + } + const articles = await this.getArticles(projectVersionId); + return articles?.data?.map?.((article) => ({ + label: article.title || article.id, + value: article.id, + })) ?? []; + }, + }, + langCode: { + type: "string", + label: "Language Code", + description: "Select a Language Code or provide a custom Language Code.", + async options({ projectVersionId }) { + if (!projectVersionId) { + return []; + } + const languages = await this.getProjectLanguages(projectVersionId); + return languages?.data?.map?.((language) => ({ + label: `${language.language_name} (${language.language_code})`, + value: language.language_code, })) ?? []; }, }, @@ -82,6 +148,11 @@ export default { path: `/ProjectVersions/${projectVersionId}/articles`, }); }, + getProjectLanguages(projectVersionId) { + return this._makeRequest({ + path: `/Language/${projectVersionId}`, + }); + }, createDocument(args) { return this._makeRequest({ method: "POST", @@ -89,5 +160,65 @@ export default { ...args, }); }, + getFileInformation({ + folderId, fileId, ...args + }) { + return this._makeRequest({ + path: `/Drive/Folders/${folderId}/${fileId}`, + ...args, + }); + }, + driveSearchFilesAndFolders(args) { + return this._makeRequest({ + path: "/Drive/Search", + ...args, + }); + }, + getArticle({ + articleId, langCode, ...args + }) { + return this._makeRequest({ + path: `/Articles/${articleId}/${langCode}`, + ...args, + }); + }, + getFolders(args) { + return this._makeRequest({ + path: "/Drive/Folders", + ...args, + }); + }, + getFolderInformation({ + folderId, ...args + }) { + return this._makeRequest({ + path: `/Drive/Folders/${folderId}`, + ...args, + }); + }, + _flattenFolders(folders, prefix = "") { + const result = []; + + folders?.forEach((folder) => { + const folderLabel = folder.title || folder.id; + const currentLabel = prefix + ? `${prefix} > ${folderLabel}` + : folderLabel; + + // Add the current folder + result.push({ + label: currentLabel, + value: folder.id, + }); + + // Recursively add sub-folders + if (folder.sub_folders && folder.sub_folders.length > 0) { + const subFolders = this._flattenFolders(folder.sub_folders, currentLabel); + result.push(...subFolders); + } + }); + + return result; + }, }, }; diff --git a/components/document360/package.json b/components/document360/package.json index 0ae656eca2f61..82f1d13d31669 100644 --- a/components/document360/package.json +++ b/components/document360/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/document360", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Document360 Components", "main": "document360.app.mjs", "keywords": [ @@ -13,6 +13,6 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^1.5.1" + "@pipedream/platform": "^3.1.0" } } diff --git a/components/document360/sources/new-article-in-project-version/new-article-in-project-version.mjs b/components/document360/sources/new-article-in-project-version/new-article-in-project-version.mjs index c2389511e795a..52b9db2990416 100644 --- a/components/document360/sources/new-article-in-project-version/new-article-in-project-version.mjs +++ b/components/document360/sources/new-article-in-project-version/new-article-in-project-version.mjs @@ -6,7 +6,7 @@ export default { name: "New Article in Project Version", description: "Emit new event when a new article is created within a project version. [See the documentation](https://apidocs.document360.com/apidocs/project-version-articles)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", props: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 927a88947673f..c75b3f6400594 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3983,8 +3983,8 @@ importers: components/document360: dependencies: '@pipedream/platform': - specifier: ^1.5.1 - version: 1.6.6 + specifier: ^3.1.0 + version: 3.1.0 components/documenterra: dependencies: