|
| 1 | +import crowdin from "../../crowdin.app.mjs"; |
| 2 | +import { axios } from "@pipedream/platform"; |
| 3 | + |
| 4 | +export default { |
| 5 | + key: "crowdin-create-project", |
| 6 | + name: "Create Project", |
| 7 | + description: "Creates a new project within Crowdin. [See the documentation](https://support.crowdin.com/developer/api/v2/#/projects-api/create-project)", |
| 8 | + version: "0.0.{{ts}}", |
| 9 | + type: "action", |
| 10 | + props: { |
| 11 | + crowdin, |
| 12 | + name: { |
| 13 | + type: "string", |
| 14 | + label: "Project Name", |
| 15 | + description: "The name of the project to be created", |
| 16 | + }, |
| 17 | + sourceLanguageId: { |
| 18 | + propDefinition: [ |
| 19 | + crowdin, |
| 20 | + "sourceLanguageId", |
| 21 | + ], |
| 22 | + }, |
| 23 | + targetLanguageIds: { |
| 24 | + propDefinition: [ |
| 25 | + crowdin, |
| 26 | + "targetLanguageIds", |
| 27 | + ], |
| 28 | + optional: true, |
| 29 | + }, |
| 30 | + identifier: { |
| 31 | + type: "string", |
| 32 | + label: "Identifier", |
| 33 | + description: "A custom identifier for the project", |
| 34 | + optional: true, |
| 35 | + }, |
| 36 | + type: { |
| 37 | + type: "integer", |
| 38 | + label: "Type", |
| 39 | + description: "Defines the project type. To create a file-based project, use 0.", |
| 40 | + optional: true, |
| 41 | + }, |
| 42 | + visibility: { |
| 43 | + type: "string", |
| 44 | + label: "Visibility", |
| 45 | + description: "Defines how users can join the project.", |
| 46 | + optional: true, |
| 47 | + options: [ |
| 48 | + "open", |
| 49 | + "private", |
| 50 | + ], |
| 51 | + default: "private", |
| 52 | + }, |
| 53 | + languageAccessPolicy: { |
| 54 | + type: "string", |
| 55 | + label: "Language Access Policy", |
| 56 | + description: "Defines access to project languages.", |
| 57 | + optional: true, |
| 58 | + options: [ |
| 59 | + "open", |
| 60 | + "moderate", |
| 61 | + ], |
| 62 | + default: "open", |
| 63 | + }, |
| 64 | + cname: { |
| 65 | + type: "string", |
| 66 | + label: "Custom Domain Name", |
| 67 | + description: "Custom domain name for the project.", |
| 68 | + optional: true, |
| 69 | + }, |
| 70 | + description: { |
| 71 | + type: "string", |
| 72 | + label: "Project Description", |
| 73 | + description: "The description of the project.", |
| 74 | + optional: true, |
| 75 | + }, |
| 76 | + tagsDetection: { |
| 77 | + type: "integer", |
| 78 | + label: "Tags Detection", |
| 79 | + description: "Values available: 0 - Auto, 1 - Count tags, 2 - Skip tags.", |
| 80 | + optional: true, |
| 81 | + default: 0, |
| 82 | + }, |
| 83 | + isMtAllowed: { |
| 84 | + type: "boolean", |
| 85 | + label: "Allow Machine Translation", |
| 86 | + description: "Allows machine translations to be visible for translators.", |
| 87 | + optional: true, |
| 88 | + default: true, |
| 89 | + }, |
| 90 | + taskBasedAccessControl: { |
| 91 | + type: "boolean", |
| 92 | + label: "Task Based Access Control", |
| 93 | + description: "Allow project members to work with tasks they're assigned to.", |
| 94 | + optional: true, |
| 95 | + default: false, |
| 96 | + }, |
| 97 | + autoSubstitution: { |
| 98 | + type: "boolean", |
| 99 | + label: "Auto Substitution", |
| 100 | + description: "Allows auto-substitution.", |
| 101 | + optional: true, |
| 102 | + default: true, |
| 103 | + }, |
| 104 | + autoTranslateDialects: { |
| 105 | + type: "boolean", |
| 106 | + label: "Auto Translate Dialects", |
| 107 | + description: "Automatically fill in regional dialects.", |
| 108 | + optional: true, |
| 109 | + default: false, |
| 110 | + }, |
| 111 | + publicDownloads: { |
| 112 | + type: "boolean", |
| 113 | + label: "Public Downloads", |
| 114 | + description: "Allows translators to download source files.", |
| 115 | + optional: true, |
| 116 | + default: true, |
| 117 | + }, |
| 118 | + hiddenStringsProofreadersAccess: { |
| 119 | + type: "boolean", |
| 120 | + label: "Hidden Strings Proofreaders Access", |
| 121 | + description: "Allows proofreaders to work with hidden strings.", |
| 122 | + optional: true, |
| 123 | + default: true, |
| 124 | + }, |
| 125 | + useGlobalTm: { |
| 126 | + type: "boolean", |
| 127 | + label: "Use Global Translation Memory", |
| 128 | + description: "If true, machine translations from connected MT engines will appear as suggestions.", |
| 129 | + optional: true, |
| 130 | + }, |
| 131 | + showTmSuggestionsDialects: { |
| 132 | + type: "boolean", |
| 133 | + label: "Show TM Suggestions for Dialects", |
| 134 | + description: "Show primary language TM suggestions for dialects if there are no dialect-specific ones.", |
| 135 | + optional: true, |
| 136 | + default: true, |
| 137 | + }, |
| 138 | + skipUntranslatedStrings: { |
| 139 | + type: "boolean", |
| 140 | + label: "Skip Untranslated Strings", |
| 141 | + description: "Defines whether to skip untranslated strings.", |
| 142 | + optional: true, |
| 143 | + }, |
| 144 | + exportApprovedOnly: { |
| 145 | + type: "boolean", |
| 146 | + label: "Export Approved Only", |
| 147 | + description: "Defines whether to export only approved strings.", |
| 148 | + optional: true, |
| 149 | + }, |
| 150 | + qaCheckIsActive: { |
| 151 | + type: "boolean", |
| 152 | + label: "QA Check Is Active", |
| 153 | + description: "If true, QA checks are active.", |
| 154 | + optional: true, |
| 155 | + default: true, |
| 156 | + }, |
| 157 | + savingsReportSettingsTemplateId: { |
| 158 | + type: "integer", |
| 159 | + label: "Savings Report Settings Template ID", |
| 160 | + description: "Report Settings Templates Identifier.", |
| 161 | + optional: true, |
| 162 | + async options() { |
| 163 | + const templates = await this.crowdin.listSavingsReportSettingsTemplates(); |
| 164 | + return templates.map((template) => ({ |
| 165 | + label: template.name, |
| 166 | + value: template.id, |
| 167 | + })); |
| 168 | + }, |
| 169 | + }, |
| 170 | + defaultTmId: { |
| 171 | + type: "integer", |
| 172 | + label: "Default TM ID", |
| 173 | + description: "Translation Memory ID. If omitted, a new translation memory will be created.", |
| 174 | + optional: true, |
| 175 | + async options() { |
| 176 | + const tms = await this.crowdin.listTMs(); |
| 177 | + return tms.map((tm) => ({ |
| 178 | + label: tm.name, |
| 179 | + value: tm.id, |
| 180 | + })); |
| 181 | + }, |
| 182 | + }, |
| 183 | + defaultGlossaryId: { |
| 184 | + type: "integer", |
| 185 | + label: "Default Glossary ID", |
| 186 | + description: "Glossary ID. If omitted, a new Glossary will be created.", |
| 187 | + optional: true, |
| 188 | + async options() { |
| 189 | + const glossaries = await this.crowdin.listGlossaries(); |
| 190 | + return glossaries.map((glossary) => ({ |
| 191 | + label: glossary.name, |
| 192 | + value: glossary.id, |
| 193 | + })); |
| 194 | + }, |
| 195 | + }, |
| 196 | + }, |
| 197 | + async run({ $ }) { |
| 198 | + const data = { |
| 199 | + name: this.name, |
| 200 | + sourceLanguageId: this.sourceLanguageId, |
| 201 | + identifier: this.identifier, |
| 202 | + type: this.type, |
| 203 | + targetLanguageIds: this.targetLanguageIds, |
| 204 | + visibility: this.visibility, |
| 205 | + languageAccessPolicy: this.languageAccessPolicy, |
| 206 | + cname: this.cname, |
| 207 | + description: this.description, |
| 208 | + tagsDetection: this.tagsDetection, |
| 209 | + isMtAllowed: this.isMtAllowed, |
| 210 | + taskBasedAccessControl: this.taskBasedAccessControl, |
| 211 | + autoSubstitution: this.autoSubstitution, |
| 212 | + autoTranslateDialects: this.autoTranslateDialects, |
| 213 | + publicDownloads: this.publicDownloads, |
| 214 | + hiddenStringsProofreadersAccess: this.hiddenStringsProofreadersAccess, |
| 215 | + useGlobalTm: this.useGlobalTm, |
| 216 | + showTmSuggestionsDialects: this.showTmSuggestionsDialects, |
| 217 | + skipUntranslatedStrings: this.skipUntranslatedStrings, |
| 218 | + exportApprovedOnly: this.exportApprovedOnly, |
| 219 | + qaCheckIsActive: this.qaCheckIsActive, |
| 220 | + savingsReportSettingsTemplateId: this.savingsReportSettingsTemplateId, |
| 221 | + defaultTmId: this.defaultTmId, |
| 222 | + defaultGlossaryId: this.defaultGlossaryId, |
| 223 | + }; |
| 224 | + |
| 225 | + const response = await this.crowdin.createProject(data); |
| 226 | + $.export("$summary", `Project "${response.name}" created successfully`); |
| 227 | + return response; |
| 228 | + }, |
| 229 | +}; |
0 commit comments