@rzdata/smart-flow (1.0.3)

Published 2025-07-16 15:13:50 +08:00 by jiangdingxuan

Installation

@rzdata:registry=
npm install @rzdata/smart-flow@1.0.3
"@rzdata/smart-flow": "1.0.3"

About this package

SmartFlow JS SDK

项目概述

SmartFlow JS SDK(以下简称SDK)是为了简化第三方应用客户端调用 SmartFlow 后端、基于 TypeScript 编写的、对部分 HTTP 请求的封装。使用 SDK 能够帮助第三方应用的前端开发人员简化开发流程,开发人员仅需要关注使用的方法、参数、返回值,而无需关注过多的细节。

如何使用

安装

该 SDK 并未发布到 npm 中央仓库,所以需要向项目的 .npmrc 配置文件中添加:

@rzdata:registry=https://git.rzdata.net/api/packages/rzdata/npm/

然后使用 npm 命令进行安装:

npm i -S @rzdata/smart-flow

使用

// api/index.js
import { SmartFlowClient } from '@rzdata/smart-flow'

export const smartFlowClient = SmartFlowClient({
    baseURL: 'https://www.rzdata.net/smart-flow-api',
})

// 配置拦截器
smartFlowClient.instance.interceptors.request.use(
    (config) => {
        return config;
    }
)
// 配置拦截器
smartFlowClient.instance.interceptors.response.use(
    (config) => {
        return config;
    }
)
<script setup>
  import { smartFlowClient } from '@/api'
  import { onMounted } from "vue";
  
  const data = ref();

  onMounted(() => {
    smartFlowClient.execute.toDoPage({
      definitionId: '',  // 流程定义ID
    }, 1, 15)
        .then((response) => response.data)
        .then((pageResult) => pageResult.list)
        .then((list) => data.value = list)
  });
</script>

认证相关

SDK 可以通过以下方式进行认证:

iv-user 请求头

将用户名放入 iv-user 请求头。方法如下:

smartFlowClient.instance.interceptors.request.use(
    (config) => {
        config.headers['iv-user'] = '<用户名>'
        return config;
    }
)

睿展网关 SSO(推荐)

如果应用集成了睿展网关,并且经过了 SSO 登录,网关会自动添加 iv-user 请求头,SDK 无需进行额外处理。

JWT

TODO 该方案后续可能会有变动,暂不支持。

项目维护指南

构建

rm -rf dist
npm run build

发布

参考: NPM Package Registry | Gitea Documentation

npm publish

Dependencies

Dependencies

ID Version
axios ^1.10.0

Development Dependencies

ID Version
@types/node ^24.0.8
typescript ^5.8.3
Details
npm
2025-07-16 15:13:50 +08:00
0
ISC
latest
4.4 KiB
Assets (1)
Versions (4) View all
1.0.3 2025-07-16
1.0.2 2025-07-10
1.0.1 2025-07-10
1.0.0 2025-07-08