vanilla / knowledge-porter
Vanilla知识的命令行porter
Requires
- php: ^8.1
- ext-dom: *
- ext-json: *
- ext-libxml: *
- ext-mbstring: *
- ext-simplexml: *
- psr/log: ^3.0
- psr/simple-cache: *
- symfony/cache: ^6.2
- vanilla/garden-cli: ^4.0
- vanilla/garden-container: ^4.0
- vanilla/garden-http: ^2.1
- vanilla/garden-schema: ^3.0
Requires (Dev)
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.5
- vanilla/standards: ^1.3
- vimeo/psalm: ^4.9
- dev-master
- v2.1
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.0
- dev-fix/vnla-5468.2
- dev-fix/vnla-5468
- dev-fix-vanilla-mock-destination
- dev-VNLA-3506_optimize-kb-porter-for-queue
- dev-upgrade-garden-container
- dev-remove-garden-cli-lock
- dev-set-psr-simple-cache-to-wildcard
- dev-set-psr-log-to-wildcard
- dev-fix/on-date-update-not-working
- dev-fix/throttling
- dev-revert-69-add-throttle-to-vanilla
- dev-add-throttle-to-vanilla
- dev-fix/add-base-rate-limiting
- dev-fix/debug-import-20220701
- dev-fix/locale-not-available
- dev-feature/oracle-kb
- dev-feature/destination-locale
- dev-fix/zendesk-private-file-download
- dev-feature/load-attachments-files
- dev-add/source-phpdoc
- dev-fix/import-bugs
- dev-feature/fetch-all
- dev-fix/php-notice
- dev-feature/hostedQueueAdaptation
- dev-feature/import-recommended-articles
- dev-feature/32-authors-disable
- dev-fix/articles-onDate-patch
- dev-feature/1675-helpful-votes
- dev-feature/1683-kb-demo-feedback
- dev-feature/1671-allow-api-insert-update-dates
- dev-feature/zendesk-sync-mode
- dev-fix/rerun-failed-categories
- dev-fix/skip-articles
- dev-fix/add-article-importlimit
- dev-fix/update-fields-date-updated
- dev-feature/validtion-error-strings
- dev-fix/remove-html-tags
- dev-feature/rate-limit
- dev-feature/config-schema-validation
- dev-fix/map-zendesk-locales
- dev-feature/work-in-progress
This package is auto-updated.
Last update: 2024-09-13 01:29:02 UTC
README
Vanilla知识的命令行porter。
示例
./bin/knowledge-porter import --config="./customer1.zendesk.json"
其中 ./customer1.zendesk.json
是您的配置文件相对路径。
配置文件包含porter配置源和目标(数据 & api)的功能标志集。示例
{
"source": {
"type": "zendesk",
"protocol": "http", // For local setup only
"prefix": "{PREFIX}", // prefix to set foreign id on destination records
"domain": "{ZENDESK_API_DOMAIN}", // eg: help.gink.com
"token": "{EMAIL_TOKEN}", // eg: dev@mail.com/token:xxQWERTYptodnoL
"targetDomain": "{NEW_DOMAIN_PATH}", // eg: dev.vanilla.localhost
"perPage": 2,
"pageFrom": 1,
"pageTo": 100,
"sourceLocale": {Zendesk locale} // eg: "en-us"
"destinationLocale": {locale} // eg: "en-us"
"import": {
"categories": true,
"retrySections": true,
"sections": true,
"authors": true,
"articles": true,
"translations": true,
"attachments": true,
"helpful": true,
"fetchPrivateArticles": false,
"fetchDraft": false
},
"api": {
"cache": true,
"log": true
}
},
"destination": {
"type": "vanilla",
"domain": "{VANILLA_API_DESTINATION_DOMAIN}", // ex: dev.vanilla.localhost
"token": "va.{VANILLA_API_TOKEN}",
"update": "onChange",
"api": {
"cache": false,
"log": true,
"verbose": false // Display more informations for each request
}
// by default we don't want KB to be patched after 1st sync
// that will allow to avoid kb-url-slug update if edited on vanilla side
"patchKnowledgeBase": false,
"syncUserByEmailOnly": false
}
}
或者,您可以将porter配置设置为环境变量,并告诉porter使用变量而不是配置文件。
示例,假设您的配置已设置为变量CONFIG
./bin/knowledge-porter import --config="ENV:CONFIG"
注意:环境变量必须包含与文件配置相同方式的有效的JSON配置。
Vanilla基础设施的速率限制绕过
如果目标是类型 vanilla
,您可能希望使用 rate_limit_bypass_token
(可选)配置参数来设置您的速率限制绕过令牌。
用户和作者
当porter导入文章时,它通过 email
搜索现有用户,如果找到则使用。
如果通过电子邮件未找到用户,porter将检查配置功能标志 syncUserByEmailOnly
,如果该标志为false(默认值),则通过 name
搜索用户。
如果用户仍然找不到,porter将创建新用户。
从多个域导入
如果我们需要从不同的域导入数据,并且它们都可以使用相同的api凭据/令牌访问,则还有一个名为 mulit-import.sh
的工具。
此脚本接收一个参数,即包含特殊配置文件的文件夹名称。例如 gink
。
该文件夹应包含两个文件:template.json
和 domains
。
template.json
是此porter的常规配置json文件。但是具有两个特殊值 prefix
和 source-domain
{
"source": {
"type": "zendesk",
"foreignIDPrefix": "{prefix}",
"domain": "{source-domain}",
...
},
"destination": {
"type": "vanilla",
...
}
}
而 domains
文件具有非常扁平的结构 domain.com=prefix
,例如
diamond.gink.com=diamond
digger.gink.com=digger
betty.gink.com=betty
此bash脚本将
- 读取
domains
并循环遍历 - 获取每个域和前缀值
- 将
template.json
复制到/conf
子文件夹,并使用新名称。例如:diamond.gink.com.json
- 在新配置文件中替换
prefix
和source-domain
- 在后台使用为每个域准备好的配置运行
knowledge-porter
命令
示例
./bin/multi-import.sh gink
此 multi-import
脚本在后台启动许多php进程(每个域一个进程)。
我们可以使用此工具在目标 {folder}/log
中创建的各种日志文件来检查进度。
有一个特殊的日志文件 {folder}/log/import.log
。
它包含运行中的php进程的PID,以便开发人员可以停止它们或调查任何事件。