vanilla/knowledge-porter

此包最新版本(v2.1)没有可用的许可证信息。

Vanilla知识的命令行porter

安装次数: 10 139

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 4

分支: 0

类型:项目

v2.1 2024-02-08 18:36 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.jsondomainsScreen Shot 2020-03-25 at 5 22 12 PM

template.json 是此porter的常规配置json文件。但是具有两个特殊值 prefixsource-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
  • 在新配置文件中替换 prefixsource-domain
  • 在后台使用为每个域准备好的配置运行 knowledge-porter 命令

示例

./bin/multi-import.sh gink

multi-import 脚本在后台启动许多php进程(每个域一个进程)。

我们可以使用此工具在目标 {folder}/log 中创建的各种日志文件来检查进度。

有一个特殊的日志文件 {folder}/log/import.log

它包含运行中的php进程的PID,以便开发人员可以停止它们或调查任何事件。