@nocobase/plugin-workflow-request 0.17.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client';
2
+ export { default } from './dist/client';
package/client.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client/index.js');
@@ -0,0 +1,180 @@
1
+ import { Instruction, WorkflowVariableInput, WorkflowVariableJSON } from '@nocobase/plugin-workflow/client';
2
+ export default class extends Instruction {
3
+ title: string;
4
+ type: string;
5
+ group: string;
6
+ description: string;
7
+ fieldset: {
8
+ method: {
9
+ type: string;
10
+ required: boolean;
11
+ title: string;
12
+ 'x-decorator': string;
13
+ 'x-component': string;
14
+ 'x-component-props': {
15
+ showSearch: boolean;
16
+ allowClear: boolean;
17
+ className: string;
18
+ };
19
+ enum: {
20
+ label: string;
21
+ value: string;
22
+ }[];
23
+ default: string;
24
+ };
25
+ url: {
26
+ type: string;
27
+ required: boolean;
28
+ title: string;
29
+ 'x-decorator': string;
30
+ 'x-decorator-props': {};
31
+ 'x-component': string;
32
+ 'x-component-props': {
33
+ placeholder: string;
34
+ };
35
+ };
36
+ headers: {
37
+ type: string;
38
+ 'x-component': string;
39
+ 'x-decorator': string;
40
+ title: string;
41
+ description: string;
42
+ items: {
43
+ type: string;
44
+ properties: {
45
+ space: {
46
+ type: string;
47
+ 'x-component': string;
48
+ properties: {
49
+ name: {
50
+ type: string;
51
+ 'x-decorator': string;
52
+ 'x-component': string;
53
+ 'x-component-props': {
54
+ placeholder: string;
55
+ };
56
+ };
57
+ value: {
58
+ type: string;
59
+ 'x-decorator': string;
60
+ 'x-component': string;
61
+ 'x-component-props': {
62
+ useTypedConstant: boolean;
63
+ };
64
+ };
65
+ remove: {
66
+ type: string;
67
+ 'x-decorator': string;
68
+ 'x-component': string;
69
+ };
70
+ };
71
+ };
72
+ };
73
+ };
74
+ properties: {
75
+ add: {
76
+ type: string;
77
+ title: string;
78
+ 'x-component': string;
79
+ };
80
+ };
81
+ };
82
+ params: {
83
+ type: string;
84
+ 'x-component': string;
85
+ 'x-decorator': string;
86
+ title: string;
87
+ items: {
88
+ type: string;
89
+ properties: {
90
+ space: {
91
+ type: string;
92
+ 'x-component': string;
93
+ properties: {
94
+ name: {
95
+ type: string;
96
+ 'x-decorator': string;
97
+ 'x-component': string;
98
+ 'x-component-props': {
99
+ placeholder: string;
100
+ };
101
+ };
102
+ value: {
103
+ type: string;
104
+ 'x-decorator': string;
105
+ 'x-component': string;
106
+ 'x-component-props': {
107
+ useTypedConstant: boolean;
108
+ };
109
+ };
110
+ remove: {
111
+ type: string;
112
+ 'x-decorator': string;
113
+ 'x-component': string;
114
+ };
115
+ };
116
+ };
117
+ };
118
+ };
119
+ properties: {
120
+ add: {
121
+ type: string;
122
+ title: string;
123
+ 'x-component': string;
124
+ };
125
+ };
126
+ };
127
+ data: {
128
+ type: string;
129
+ title: string;
130
+ 'x-decorator': string;
131
+ 'x-decorator-props': {};
132
+ 'x-component': string;
133
+ 'x-component-props': {
134
+ changeOnSelect: boolean;
135
+ autoSize: {
136
+ minRows: number;
137
+ };
138
+ placeholder: string;
139
+ };
140
+ description: string;
141
+ };
142
+ timeout: {
143
+ type: string;
144
+ title: string;
145
+ 'x-decorator': string;
146
+ 'x-decorator-props': {};
147
+ 'x-component': string;
148
+ 'x-component-props': {
149
+ addonAfter: string;
150
+ min: number;
151
+ step: number;
152
+ defaultValue: number;
153
+ };
154
+ };
155
+ ignoreFail: {
156
+ type: string;
157
+ title: string;
158
+ 'x-decorator': string;
159
+ 'x-component': string;
160
+ };
161
+ };
162
+ components: {
163
+ ArrayItems: import("@formily/reactive-react").ReactFC<import("react").HTMLAttributes<HTMLDivElement>> & import("@formily/antd-v5").ArrayBaseMixins & {
164
+ Item: import("@formily/reactive-react").ReactFC<import("react").HTMLAttributes<HTMLDivElement> & {
165
+ type?: "card" | "divide";
166
+ }>;
167
+ };
168
+ WorkflowVariableInput: typeof WorkflowVariableInput;
169
+ WorkflowVariableJSON: typeof WorkflowVariableJSON;
170
+ };
171
+ useVariables({ key, title }: {
172
+ key: any;
173
+ title: any;
174
+ }, { types, fieldNames }: {
175
+ types: any;
176
+ fieldNames?: import("@nocobase/client").FieldNames;
177
+ }): {
178
+ [x: string]: any;
179
+ };
180
+ }
@@ -0,0 +1,6 @@
1
+ import { Plugin } from '@nocobase/client';
2
+ export default class extends Plugin {
3
+ afterAdd(): Promise<void>;
4
+ beforeLoad(): Promise<void>;
5
+ load(): Promise<void>;
6
+ }
@@ -0,0 +1 @@
1
+ (function(t,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("@nocobase/client"),require("@formily/antd-v5"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@formily/antd-v5","@nocobase/plugin-workflow/client","react-i18next"],o):(t=typeof globalThis!="undefined"?globalThis:t||self,o(t["@nocobase/plugin-workflow-request"]={},t["@nocobase/client"],t["@formily/antd-v5"],t["@nocobase/plugin-workflow"]))})(this,function(t,o,r,p){"use strict";var x=Object.defineProperty;var y=(t,o,r)=>o in t?x(t,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[o]=r;var s=(t,o,r)=>(y(t,typeof o!="symbol"?o+"":o,r),r);var d=(t,o,r)=>new Promise((p,e)=>{var l=n=>{try{i(r.next(n))}catch(a){e(a)}},c=n=>{try{i(r.throw(n))}catch(a){e(a)}},i=n=>n.done?p(n.value):Promise.resolve(n.value).then(l,c);i((r=r.apply(t,o)).next())});const e="workflow-request";class l extends p.Instruction{constructor(){super(...arguments);s(this,"title",`{{t("HTTP request", { ns: "${e}" })}}`);s(this,"type","request");s(this,"group","extended");s(this,"description",`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${e}" })}}`);s(this,"fieldset",{method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${e}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${e}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Input","x-component-props":{placeholder:"https://www.nocobase.com"}},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${e}" })}}`,description:`{{t('"Content-Type" only support "application/json", and no need to specify', { ns: "${e}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${e}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${e}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${e}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${e}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${e}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${e}" })}}`},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${e}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${e}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${e}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}});s(this,"components",{ArrayItems:r.ArrayItems,WorkflowVariableInput:p.WorkflowVariableInput,WorkflowVariableJSON:p.WorkflowVariableJSON})}useVariables({key:a,title:u},{types:f,fieldNames:m=o.defaultFieldNames}){return{[m.value]:a,[m.label]:u}}}class c extends o.Plugin{afterAdd(){return d(this,null,function*(){})}beforeLoad(){return d(this,null,function*(){})}load(){return d(this,null,function*(){const n=this.app.pm.get("workflow"),a=new l;n.instructions.register(a.type,a)})}}t.default=c,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ "@formily/antd-v5": "1.1.7",
3
+ "@nocobase/client": "0.17.0-alpha.4",
4
+ "@nocobase/plugin-workflow": "0.17.0-alpha.4",
5
+ "react-i18next": "11.18.6",
6
+ "@nocobase/server": "0.17.0-alpha.4",
7
+ "axios": "0.26.1"
8
+ };
@@ -0,0 +1,2 @@
1
+ export * from './server';
2
+ export { default } from './server';
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ default: () => import_server.default
32
+ });
33
+ module.exports = __toCommonJS(src_exports);
34
+ __reExport(src_exports, require("./server"), module.exports);
35
+ var import_server = __toESM(require("./server"));
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ ...require("./server")
39
+ });
@@ -0,0 +1,20 @@
1
+ {
2
+ "HTTP request": "HTTP request",
3
+ "Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.": "Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.",
4
+ "HTTP method": "HTTP method",
5
+ "URL": "URL",
6
+ "Headers": "Headers",
7
+ "Add request header": "Add request header",
8
+ "Parameters": "Parameters",
9
+ "Add parameter": "Add parameter",
10
+ "Body": "Body",
11
+ "Use variable": "Use variable",
12
+ "Format": "Format",
13
+ "Insert": "Insert",
14
+ "Timeout config": "Timeout config",
15
+ "ms": "ms",
16
+ "Input request data": "Input request data",
17
+ "Only support standard JSON data": "Only support standard JSON data",
18
+ "\"Content-Type\" only support \"application/json\", and no need to specify": "\"Content-Type\" only support \"application/json\", and no need to specify",
19
+ "Ignore failed request and continue workflow": "Ignore failed request and continue workflow"
20
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "HTTP request": "Petición HTTP",
3
+ "HTTP method": "Método HTTP",
4
+ "URL": "URL",
5
+ "Headers": "Encabezados",
6
+ "Add request header": "Añadir encabezado de petición",
7
+ "Parameters": "Parámetros",
8
+ "Add parameter": "Añadir parámetro",
9
+ "Body": "Cuerpo",
10
+ "Use variable": "Utilizar variable",
11
+ "Format": "Formato",
12
+ "Insert": "Insertar",
13
+ "Timeout config": "Tiempo de espera config",
14
+ "ms": "ms",
15
+ "Input request data": "Datos de solicitud de entrada",
16
+ "Only support standard JSON data": "Sólo admite datos JSON estándar",
17
+ "\"Content-Type\" only support \"application/json\", and no need to specify": "\"Content-Type\" sólo admite \"application/json\", y no es necesario especificar",
18
+ "Ignore fail request and continue workflow": "Ignorar solicitud fallida y continuar flujo de trabajo"
19
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "HTTP request": "Requête HTTP",
3
+ "HTTP method": "Méthode HTTP",
4
+ "URL": "URL",
5
+ "Headers": "En-têtes",
6
+ "Add request header": "Ajouter un en-tête de requête",
7
+ "Parameters": "Paramètres",
8
+ "Add parameter": "Ajouter un paramètre",
9
+ "Body": "Corps",
10
+ "Use variable": "Utiliser une variable",
11
+ "Format": "Format",
12
+ "Insert": "Insérer",
13
+ "Timeout config": "Configuration du délai d'expiration",
14
+ "ms": "ms",
15
+ "Input request data": "Entrée des données de requête",
16
+ "Only support standard JSON data": "Prend uniquement en charge les données JSON standard",
17
+ "\"Content-Type\" only support \"application/json\", and no need to specify": "\"Content-Type\" prend uniquement en charge \"application/json\" et n'a pas besoin d'être spécifié",
18
+ "Ignore fail request and continue workflow": "Ignorer l'échec de la requête et continuer le workflow"
19
+ }
@@ -0,0 +1,3 @@
1
+ export declare const NAMESPACE = "workflow-request";
2
+ export declare function useLang(key: string, options?: {}): string;
3
+ export declare function usePluginTranslation(options: any): import("react-i18next").UseTranslationResponse<"workflow-request", undefined>;
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var locale_exports = {};
19
+ __export(locale_exports, {
20
+ NAMESPACE: () => NAMESPACE,
21
+ useLang: () => useLang,
22
+ usePluginTranslation: () => usePluginTranslation
23
+ });
24
+ module.exports = __toCommonJS(locale_exports);
25
+ var import_react_i18next = require("react-i18next");
26
+ const NAMESPACE = "workflow-request";
27
+ function useLang(key, options = {}) {
28
+ const { t } = usePluginTranslation(options);
29
+ return t(key);
30
+ }
31
+ function usePluginTranslation(options) {
32
+ return (0, import_react_i18next.useTranslation)(NAMESPACE, options);
33
+ }
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ NAMESPACE,
37
+ useLang,
38
+ usePluginTranslation
39
+ });
@@ -0,0 +1,19 @@
1
+ {
2
+ "HTTP request": "Requisição HTTP",
3
+ "HTTP method": "Método HTTP",
4
+ "URL": "URL",
5
+ "Headers": "Cabeçalhos",
6
+ "Add request header": "Adicionar cabeçalho de requisição",
7
+ "Parameters": "Parâmetros",
8
+ "Add parameter": "Adicionar parâmetro",
9
+ "Body": "Corpo",
10
+ "Use variable": "Usar variável",
11
+ "Format": "Formato",
12
+ "Insert": "Inserir",
13
+ "Timeout config": "Configuração de tempo limite",
14
+ "ms": "ms",
15
+ "Input request data": "Dados de entrada da requisição",
16
+ "Only support standard JSON data": "Suporta somente dados JSON padrão",
17
+ "\"Content-Type\" only support \"application/json\", and no need to specify": "\"Content-Type\" somente suporta \"application/json\" e não precisa ser especificado",
18
+ "Ignore fail request and continue workflow": "Ignorar falhas na requisição e continuar o fluxo de trabalho"
19
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "HTTP request": "HTTP 请求",
3
+ "Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.": "向指定 URL 发送 HTTP 请求。可以使用上游节点里的变量作为请求头、参数和请求体。",
4
+ "HTTP method": "HTTP 方法",
5
+ "URL": "地址",
6
+ "Headers": "请求头",
7
+ "Add request header": "添加请求头",
8
+ "Parameters": "参数",
9
+ "Add parameter": "添加参数",
10
+ "Body": "请求体",
11
+ "Use variable": "使用变量",
12
+ "Format": "格式化",
13
+ "Insert": "插入",
14
+ "Timeout config": "超时设置",
15
+ "ms": "毫秒",
16
+ "Input request data": "输入请求数据",
17
+ "Only support standard JSON data": "仅支持标准 JSON 数据",
18
+ "\"Content-Type\" only support \"application/json\", and no need to specify": "\"Content-Type\" 请求头仅支持 \"application/json\",无需填写",
19
+ "Ignore failed request and continue workflow": "忽略失败的请求并继续工作流"
20
+ }
@@ -0,0 +1,6 @@
1
+ import { Plugin } from '@nocobase/server';
2
+ import WorkflowPlugin from '@nocobase/plugin-workflow';
3
+ export default class extends Plugin {
4
+ workflow: WorkflowPlugin;
5
+ load(): Promise<void>;
6
+ }
@@ -0,0 +1,42 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var Plugin_exports = {};
29
+ __export(Plugin_exports, {
30
+ default: () => Plugin_default
31
+ });
32
+ module.exports = __toCommonJS(Plugin_exports);
33
+ var import_server = require("@nocobase/server");
34
+ var import_RequestInstruction = __toESM(require("./RequestInstruction"));
35
+ class Plugin_default extends import_server.Plugin {
36
+ workflow;
37
+ async load() {
38
+ const workflowPlugin = this.app.getPlugin("workflow");
39
+ this.workflow = workflowPlugin;
40
+ workflowPlugin.instructions.register("request", new import_RequestInstruction.default(workflowPlugin));
41
+ }
42
+ }
@@ -0,0 +1,14 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { Processor, Instruction, FlowNodeModel } from '@nocobase/plugin-workflow';
3
+ export interface Header {
4
+ name: string;
5
+ value: string;
6
+ }
7
+ export type RequestConfig = Pick<AxiosRequestConfig, 'url' | 'method' | 'params' | 'data' | 'timeout'> & {
8
+ headers: Array<Header>;
9
+ ignoreFail: boolean;
10
+ };
11
+ export default class extends Instruction {
12
+ run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<any>;
13
+ resume(node: FlowNodeModel, job: any, processor: Processor): Promise<any>;
14
+ }
@@ -0,0 +1,89 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var RequestInstruction_exports = {};
29
+ __export(RequestInstruction_exports, {
30
+ default: () => RequestInstruction_default
31
+ });
32
+ module.exports = __toCommonJS(RequestInstruction_exports);
33
+ var import_axios = __toESM(require("axios"));
34
+ var import_plugin_workflow = require("@nocobase/plugin-workflow");
35
+ async function request(config) {
36
+ const { url, method = "POST", data, timeout = 5e3 } = config;
37
+ const headers = (config.headers ?? []).reduce((result, header) => {
38
+ if (header.name.toLowerCase() === "content-type") {
39
+ return result;
40
+ }
41
+ return Object.assign(result, { [header.name]: header.value });
42
+ }, {});
43
+ const params = (config.params ?? []).reduce(
44
+ (result, param) => Object.assign(result, { [param.name]: param.value }),
45
+ {}
46
+ );
47
+ headers["Content-Type"] = "application/json";
48
+ return import_axios.default.request({
49
+ url,
50
+ method,
51
+ headers,
52
+ params,
53
+ data,
54
+ timeout
55
+ });
56
+ }
57
+ class RequestInstruction_default extends import_plugin_workflow.Instruction {
58
+ async run(node, prevJob, processor) {
59
+ const job = await processor.saveJob({
60
+ status: import_plugin_workflow.JOB_STATUS.PENDING,
61
+ nodeId: node.id,
62
+ upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
63
+ });
64
+ const config = processor.getParsedValue(node.config, node.id);
65
+ request(config).then((response) => {
66
+ job.set({
67
+ status: import_plugin_workflow.JOB_STATUS.RESOLVED,
68
+ result: response.data
69
+ });
70
+ }).catch((error) => {
71
+ job.set({
72
+ status: import_plugin_workflow.JOB_STATUS.FAILED,
73
+ result: error.isAxiosError ? error.toJSON() : error.message
74
+ });
75
+ }).finally(() => {
76
+ processor.logger.info(`request (#${node.id}) response received, status: ${job.get("status")}`);
77
+ this.plugin.resume(job);
78
+ });
79
+ processor.logger.info(`request (#${node.id}) sent to "${config.url}", waiting for response...`);
80
+ return processor.exit();
81
+ }
82
+ async resume(node, job, processor) {
83
+ const { ignoreFail } = node.config;
84
+ if (ignoreFail) {
85
+ job.set("status", import_plugin_workflow.JOB_STATUS.RESOLVED);
86
+ }
87
+ return job;
88
+ }
89
+ }
@@ -0,0 +1 @@
1
+ export { default } from './Plugin';
@@ -0,0 +1,33 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var server_exports = {};
29
+ __export(server_exports, {
30
+ default: () => import_Plugin.default
31
+ });
32
+ module.exports = __toCommonJS(server_exports);
33
+ var import_Plugin = __toESM(require("./Plugin"));
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@nocobase/plugin-workflow-request",
3
+ "displayName": "Workflow: HTTP request node",
4
+ "displayName.zh-CN": "工作流:HTTP 请求节点",
5
+ "description": "Send HTTP requests to any HTTP service for data interaction in workflow.",
6
+ "description.zh-CN": "可用于在工作流中向任意 HTTP 服务发送请求,进行数据交互。",
7
+ "version": "0.17.0-alpha.4",
8
+ "license": "AGPL-3.0",
9
+ "main": "./dist/server/index.js",
10
+ "devDependencies": {
11
+ "antd": "5.x",
12
+ "react": "18.x",
13
+ "react-i18next": "^11.15.1"
14
+ },
15
+ "peerDependencies": {
16
+ "@nocobase/client": "0.x",
17
+ "@nocobase/database": "0.x",
18
+ "@nocobase/plugin-workflow": ">=0.17.0-alpha.3",
19
+ "@nocobase/plugin-workflow-test": ">=0.17.0-alpha.3",
20
+ "@nocobase/server": "0.x",
21
+ "@nocobase/test": "0.x"
22
+ },
23
+ "gitHead": "663b03a3799a70ba1a2bc6a0d686e679331a50ad"
24
+ }
package/server.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/server';
2
+ export { default } from './dist/server';
package/server.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/server/index.js');