@tachybase/plugin-action-custom-request 0.23.8
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/.turbo/turbo-build.log +14 -0
- package/LICENSE +201 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/components/CustomRequestAction.d.ts +7 -0
- package/dist/client/components/CustomRequestActionDesigner.d.ts +12 -0
- package/dist/client/components/index.d.ts +1 -0
- package/dist/client/constants.d.ts +1 -0
- package/dist/client/hooks/index.d.ts +3 -0
- package/dist/client/hooks/useCustomRequestVariableOptions.d.ts +5 -0
- package/dist/client/hooks/useCustomRequestsResource.d.ts +2 -0
- package/dist/client/hooks/useCustomizeRequestActionProps.d.ts +3 -0
- package/dist/client/hooks/useGetCustomRequest.d.ts +7 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.js +1 -0
- package/dist/client/initializer/CustomRequestInitializer.d.ts +2 -0
- package/dist/client/initializer/index.d.ts +1 -0
- package/dist/client/locale.d.ts +4 -0
- package/dist/client/schemaSettings.d.ts +2 -0
- package/dist/client/schemas/CustomRequestACL.d.ts +26 -0
- package/dist/client/schemas/CustomRequestConfigurationFields.d.ts +175 -0
- package/dist/client/schemas/index.d.ts +2 -0
- package/dist/externalVersion.js +17 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/ko_KR.json +26 -0
- package/dist/locale/zh-CN.json +26 -0
- package/dist/server/actions/listByCurrentRole.d.ts +2 -0
- package/dist/server/actions/listByCurrentRole.js +42 -0
- package/dist/server/actions/send.d.ts +3 -0
- package/dist/server/actions/send.js +189 -0
- package/dist/server/collections/customRequest.d.ts +2 -0
- package/dist/server/collections/customRequest.js +50 -0
- package/dist/server/collections/customRequestsRoles.d.ts +2 -0
- package/dist/server/collections/customRequestsRoles.js +27 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/plugin.d.ts +14 -0
- package/dist/server/plugin.js +71 -0
- package/package.json +36 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @tachybase/plugin-action-custom-request@0.23.2 build /Users/seal/Documents/projects/tachybase/packages/plugin-action-custom-request
|
|
4
|
+
> tachybase-build --no-dts @tachybase/plugin-action-custom-request
|
|
5
|
+
|
|
6
|
+
[33m[33mThe CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.[39m[39m
|
|
7
|
+
[4m[95m@tachybase/plugin-action-custom-request[39m[24m: [1mplugin-action-custom-request[22m build start
|
|
8
|
+
[4m[95m@tachybase/plugin-action-custom-request[39m[24m: build plugin client
|
|
9
|
+
[4m[95m@tachybase/plugin-action-custom-request[39m[24m: build plugin server source
|
|
10
|
+
[4m[95m@tachybase/plugin-action-custom-request[39m[24m: delete server files
|
|
11
|
+
[4m[95m@tachybase/plugin-action-custom-request[39m[24m: build plugin server dependencies
|
|
12
|
+
[4m[95m@tachybase/plugin-action-custom-request[39m[24m: These packages [33m@tachybase/logger, @tachybase/server, @tachybase/actions, @tachybase/evaluators, @tachybase/utils, axios, @tachybase/database[39m will be [3mexclude[23m.
|
|
13
|
+
[4m[95m@tachybase/plugin-action-custom-request[39m[24m: write external version
|
|
14
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2023-2024] [Tachybase team]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client/index.js');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SchemaSettings } from '@tachybase/client';
|
|
3
|
+
export declare function CustomRequestSettingsItem(): React.JSX.Element;
|
|
4
|
+
export declare function CustomRequestACL(): React.JSX.Element;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated
|
|
7
|
+
*/
|
|
8
|
+
export declare const customRequestActionSettings: SchemaSettings<{}>;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
12
|
+
export declare const CustomRequestActionDesigner: React.FC;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CustomRequestAction';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const listByCurrentRoleUrl = "customRequests:listByCurrentRole";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(o,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@tachybase/client"),require("@tachybase/schema"),require("@tachybase/utils/client"),require("antd"),require("react-router-dom"),require("react-i18next"),require("react"),require("@tachybase/components")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@tachybase/client","@tachybase/schema","@tachybase/utils/client","antd","react-router-dom","react-i18next","react","@tachybase/components"],r):(o=typeof globalThis!="undefined"?globalThis:o||self,r(o["@tachybase/plugin-action-custom-request"]={},o.jsxRuntime,o["@tachybase/client"],o["@tachybase/schema"],o["@tachybase/utils"],o.antd,o["react-router-dom"],o["react-i18next"],o.react,o["@tachybase/components"]))})(this,function(o,r,e,l,T,S,B,I,b,F){"use strict";var ge=Object.defineProperty,be=Object.defineProperties;var Re=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var oe=(o,r,e)=>r in o?ge(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,v=(o,r)=>{for(var e in r||(r={}))se.call(r,e)&&oe(o,e,r[e]);if(D)for(var e of D(r))ne.call(r,e)&&oe(o,e,r[e]);return o},A=(o,r)=>be(o,Re(r));var re=(o,r)=>{var e={};for(var l in o)se.call(o,l)&&r.indexOf(l)<0&&(e[l]=o[l]);if(o!=null&&D)for(var l of D(o))r.indexOf(l)<0&&ne.call(o,l)&&(e[l]=o[l]);return e};var q=(o,r,e)=>new Promise((l,T)=>{var S=b=>{try{I(e.next(b))}catch(F){T(F)}},B=b=>{try{I(e.throw(b))}catch(F){T(F)}},I=b=>b.done?l(b.value):Promise.resolve(b.value).then(S,B);I((e=e.apply(o,r)).next())});const P="customRequests:listByCurrentRole";var O=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},z={exports:{}};(function(s,m){(function(i,c){c()})(O,function(){function i(n,a){return typeof a=="undefined"?a={autoBom:!1}:typeof a!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(n.type)?new Blob(["\uFEFF",n],{type:n.type}):n}function c(n,a,h){var u=new XMLHttpRequest;u.open("GET",n),u.responseType="blob",u.onload=function(){x(u.response,a,h)},u.onerror=function(){console.error("could not download file")},u.send()}function p(n){var a=new XMLHttpRequest;a.open("HEAD",n,!1);try{a.send()}catch(h){}return 200<=a.status&&299>=a.status}function d(n){try{n.dispatchEvent(new MouseEvent("click"))}catch(h){var a=document.createEvent("MouseEvents");a.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),n.dispatchEvent(a)}}var f=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof O=="object"&&O.global===O?O:void 0,g=f.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),x=f.saveAs||(typeof window!="object"||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!g?function(n,a,h){var u=f.URL||f.webkitURL,C=document.createElement("a");a=a||n.name||"download",C.download=a,C.rel="noopener",typeof n=="string"?(C.href=n,C.origin===location.origin?d(C):p(C.href)?c(n,a,h):d(C,C.target="_blank")):(C.href=u.createObjectURL(n),setTimeout(function(){u.revokeObjectURL(C.href)},4e4),setTimeout(function(){d(C)},0))}:"msSaveOrOpenBlob"in navigator?function(n,a,h){if(a=a||n.name||"download",typeof n!="string")navigator.msSaveOrOpenBlob(i(n,h),a);else if(p(n))c(n,a,h);else{var u=document.createElement("a");u.href=n,u.target="_blank",setTimeout(function(){d(u)})}}:function(n,a,h,u){if(u=u||open("","_blank"),u&&(u.document.title=u.document.body.innerText="downloading..."),typeof n=="string")return c(n,a,h);var C=n.type==="application/octet-stream",L=/constructor/i.test(f.HTMLElement)||f.safari,w=/CriOS\/[\d]+/.test(navigator.userAgent);if((w||C&&L||g)&&typeof FileReader!="undefined"){var U=new FileReader;U.onloadend=function(){var R=U.result;R=w?R:R.replace(/^data:[^;]*;/,"data:attachment/file;"),u?u.location.href=R:location=R,u=null},U.readAsDataURL(n)}else{var j=f.URL||f.webkitURL,t=j.createObjectURL(n);u?u.location=t:location.href=t,u=null,setTimeout(function(){j.revokeObjectURL(t)},4e4)}});f.saveAs=x.saveAs=x,s.exports=x})})(z);var ae=z.exports;const H="action-custom-request";function y(s){return`{{t('${s}', { ns: '${H}', nsMode: 'fallback' })}}`}function k(){return I.useTranslation(H,{nsMode:"fallback"})}const ie=()=>{const s=e.useAPIClient(),m=B.useNavigate(),i=l.useFieldSchema(),c=e.useCompile(),p=l.useForm(),{getPrimaryKey:d}=e.useCollection_deprecated(),{resource:f,__parent:g,service:x}=e.useBlockRequestContext(),n=e.useRecord(),a=l.useFieldSchema(),h=l.useField(),{setVisible:u}=e.useActionContext(),{modal:C,message:L}=S.App.useApp(),{t:w}=k();return{onClick(){return q(this,null,function*(){var X,Q,Y,M,Z,ee,te;const{skipValidator:j,onSuccess:t}=(X=i==null?void 0:i["x-action-settings"])!=null?X:{},R=i==null?void 0:i["x-action"];j!==!0&&R==="customize:form:request"&&(yield p.submit());let W={};R==="customize:form:request"&&(W=p.values),(Q=h.data)!=null||(h.data={}),h.data.loading=!0;try{const V=yield s.request({url:`/customRequests:send/${a["x-uid"]}`,method:"POST",responseType:t!=null&&t.down?"blob":"json",data:{currentRecord:{id:n[d()],appends:(Y=x.params[0])==null?void 0:Y.appends,data:W}}}),Ce=V.headers.getContentType();if(t!=null&&t.down)if(Ce==="application/octet-stream"){const xe=t.downTitle;ae.saveAs(V.data,xe)}else L.error(w("The current return type is not a document type"));if(h.data.loading=!1,f instanceof e.TableFieldResource||(Z=(M=g==null?void 0:g.service)==null?void 0:M.refresh)==null||Z.call(M),(ee=x==null?void 0:x.refresh)==null||ee.call(x),R==="customize:form:request"&&(u==null||u(!1)),(te=i==null?void 0:i["x-component-props"])!=null&&te.showData)C.confirm({title:"Test Data",content:`${JSON.stringify(V.data)}`,okText:w("Confirm"),cancelText:w("Cancel")});else{if(!(t!=null&&t.successMessage))return;t!=null&&t.manualClose?C.success({title:c(t==null?void 0:t.successMessage),onOk:()=>q(this,null,function*(){t!=null&&t.redirecting&&(t!=null&&t.redirectTo)&&(T.isURL(t.redirectTo)?window.location.href=t.redirectTo:m(t.redirectTo))})}):(L.success(c(t==null?void 0:t.successMessage)),t!=null&&t.redirecting&&(t!=null&&t.redirectTo)&&(T.isURL(t.redirectTo)?window.location.href=t.redirectTo:m(t.redirectTo)))}}finally{h.data.loading=!1}})}}},K=()=>{const m=`customRequests:get/${l.useFieldSchema()["x-uid"]}`;return e.useRequest({url:m,params:{appends:["roles"]}},{manual:!0,cacheKey:m})},ue=()=>{const s=e.useCollection_deprecated(),{t:m}=k(),i=e.useCollectionFilterOptions(s),c=e.useCollectionFilterOptions("users"),p=e.useCompile(),[d,f]=b.useMemo(()=>[p(i),p(c)],[i,c]);return b.useMemo(()=>[{name:"currentRecord",title:m("Current record",{ns:"core"}),children:[...d]},{name:"currentUser",title:m("Current user",{ns:"core"}),children:f},{name:"currentTime",title:m("Current time",{ns:"core"}),children:null}],[d,f])},E=()=>e.useAPIClient().resource("customRequests"),_={type:"object",properties:{method:{type:"string",required:!0,title:y("HTTP method"),"x-decorator-props":{tooltip:y("When the HTTP method is Post, Put or Patch, and this custom request inside the form, the request body will be automatically filled in with the form data")},"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:y("URL"),"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:"{{useCustomRequestVariableOptions}}",autoSize:!0,fieldNames:{value:"name",label:"title"},placeholder:"https://www.tachybase.com"}},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:y("Headers"),description:y('"Content-Type" only support "application/json", and no need to specify'),items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:y("Name")}},value:{type:"string","x-decorator":"FormItem","x-component":"Variable.Input","x-component-props":{scope:"{{useCustomRequestVariableOptions}}",fieldNames:{value:"name",label:"title"},useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:y("Add request header"),"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:y("Parameters"),items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:y("Name")}},value:{type:"string","x-decorator":"FormItem","x-component":"Variable.Input","x-component-props":{scope:"{{useCustomRequestVariableOptions}}",fieldNames:{value:"name",label:"title"},useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:y("Add parameter"),"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:y("Body"),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Variable.JSON","x-component-props":{scope:"{{useCustomRequestVariableOptions}}",fieldNames:{value:"name",label:"title"},changeOnSelect:!0,autoSize:{minRows:10},placeholder:y("Input request data")},description:y("Only support standard JSON data")},timeout:{type:"number",title:y("Timeout config"),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:y("ms"),min:1,step:1e3,defaultValue:5e3}}}},ce={type:"object",properties:{roles:{type:"array",title:y("Roles"),"x-decorator":"FormItem","x-decorator-props":{tooltip:y("If not set, all roles can see this action")},"x-component":"RemoteSelect","x-component-props":{multiple:!0,objectValue:!0,service:{resource:"roles"},manual:!1,fieldNames:{label:"title",value:"name"}}}}};function G(){var g;const{t:s}=k(),{name:m}=e.useCollection_deprecated(),i=l.useFieldSchema(),c=E(),{message:p}=S.App.useApp(),{data:d,refresh:f}=K();return r.jsx(r.Fragment,{children:r.jsx(e.SchemaSettingsActionModalItem,{title:s("Request settings"),components:{ArrayItems:F.ArrayItems},beforeOpen:()=>!d&&f(),scope:{useCustomRequestVariableOptions:ue},schema:_,initialValues:v({},(g=d==null?void 0:d.data)==null?void 0:g.options),onSubmit:x=>q(this,null,function*(){const n=re(x,[]);return yield c.updateOrCreate({values:{key:i["x-uid"],options:A(v({},n),{collectionName:m})},filterKeys:["key"]}),f(),p.success(s("Saved successfully"))})})})}function $(){var g;const{t:s}=k(),m=l.useFieldSchema(),i=E(),{message:c}=S.App.useApp(),{data:p,refresh:d}=K(),{refresh:f}=e.useRequest({url:P},{manual:!0,cacheKey:P});return r.jsx(r.Fragment,{children:r.jsx(e.SchemaSettingsActionModalItem,{title:s("Access control"),schema:ce,initialValues:{roles:(g=p==null?void 0:p.data)==null?void 0:g.roles},beforeOpen:()=>!p&&d(),onSubmit:n=>q(this,[n],function*({roles:x}){return yield i.updateOrCreate({values:{key:m["x-uid"],roles:x},filterKeys:["key"]}),d(),f(),c.success(s("Saved successfully"))})})})}const le=new e.SchemaSettings({name:"CustomRequestActionSettings",items:[A(v({},e.actionSettingsItems[0]),{children:[...e.actionSettingsItems[0].children,{name:"request settings",Component:G},{name:"accessControl",Component:$}]})]}),me=()=>{const s=E(),m=l.useFieldSchema();return r.jsx(e.Action.Designer,{linkageAction:!0,schemaSettings:"CustomRequestActionSettings",buttonEditorProps:{isLink:m["x-action"]==="customize:table:request"},linkageRulesProps:{type:"button"},removeButtonProps:{onConfirmOk(){return s.destroy({filterByTk:m["x-uid"]})}}})},pe=s=>{var d;const i=e.useAPIClient().auth.role==="root",c=l.useFieldSchema(),{data:p}=e.useRequest({url:P},{manual:i,cacheKey:P});return!i&&!((d=p==null?void 0:p.data)!=null&&d.includes(c==null?void 0:c["x-uid"]))?null:s.children},de={"customize:table:request":e.Action.Link},N=s=>{const i=l.useFieldSchema()["x-action"],c=de[i]||e.Action;return r.jsx(c,A(v({},s),{useProps:ie}))};N.Designer=me,N.Decorator=pe;const fe=s=>{const m=E(),i={title:'{{ t("Custom request") }}',"x-component":"CustomRequestAction","x-action":"customize:form:request","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:customRequest","x-decorator":"CustomRequestAction.Decorator","x-uid":l.uid(),"x-action-settings":{onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Request success")}}'}}},c=e.useSchemaInitializerItem();return r.jsx(e.BlockInitializer,A(v({},c),{item:c,onClick:p=>q(this,null,function*(){yield m.create({values:{key:p["x-uid"]}})}),schema:i}))},ye=new e.SchemaSettings({name:"actionSettings:customRequest",items:[{name:"editButton",Component:e.ButtonEditor,useComponentProps(){const{buttonEditorProps:s}=e.useSchemaToolbar();return v({isLink:!0},s)}},{name:"linkageRules",Component:e.SchemaSettingsLinkageRules,useComponentProps(){const{name:s}=e.useCollection(),{linkageRulesProps:m}=e.useSchemaToolbar();return A(v({},m),{collectionName:s})}},{name:"secondConFirm",Component:e.SecondConFirm},{name:"isDownLoad",Component:e.IsDownLoad},{name:"settingDownTitle",Component:e.SettingDownTitle,useVisible(){var i,c;const s=l.useFieldSchema();return(c=(i=s==null?void 0:s["x-action-settings"])==null?void 0:i.onSuccess)==null?void 0:c.down}},{name:"showData",Component:e.ShowData},{name:"afterSuccessfulSubmission",Component:e.AfterSuccess},{name:"request settings",Component:G},{name:"accessControl",Component:$},{name:"delete",sort:100,Component:e.RemoveButton,useComponentProps(){const{removeButtonProps:s}=e.useSchemaToolbar();return s}}]}),he=s=>r.jsx(e.SchemaComponentOptions,{scope:{CustomRequestConfigurationFieldsSchema:_},components:{CustomRequestAction:N,CustomRequestInitializer:fe},children:s.children});class J extends e.Plugin{load(){return q(this,null,function*(){this.app.use(he),this.app.schemaSettingsManager.add(ye),this.app.schemaSettingsManager.add(le)})}}o.CustomRequestPlugin=J,o.default=J,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CustomRequestInitializer';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const NAMESPACE = "action-custom-request";
|
|
2
|
+
export declare function lang(key: string): string;
|
|
3
|
+
export declare function generateNTemplate(key: string): string;
|
|
4
|
+
export declare function useTranslation(): import("react-i18next").UseTranslationResponse<"action-custom-request", undefined>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const CustomRequestACLSchema: {
|
|
2
|
+
type: string;
|
|
3
|
+
properties: {
|
|
4
|
+
roles: {
|
|
5
|
+
type: string;
|
|
6
|
+
title: string;
|
|
7
|
+
'x-decorator': string;
|
|
8
|
+
'x-decorator-props': {
|
|
9
|
+
tooltip: string;
|
|
10
|
+
};
|
|
11
|
+
'x-component': string;
|
|
12
|
+
'x-component-props': {
|
|
13
|
+
multiple: boolean;
|
|
14
|
+
objectValue: boolean;
|
|
15
|
+
service: {
|
|
16
|
+
resource: string;
|
|
17
|
+
};
|
|
18
|
+
manual: boolean;
|
|
19
|
+
fieldNames: {
|
|
20
|
+
label: string;
|
|
21
|
+
value: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
export declare const CustomRequestConfigurationFieldsSchema: {
|
|
2
|
+
type: string;
|
|
3
|
+
properties: {
|
|
4
|
+
method: {
|
|
5
|
+
type: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
title: string;
|
|
8
|
+
'x-decorator-props': {
|
|
9
|
+
tooltip: string;
|
|
10
|
+
};
|
|
11
|
+
'x-decorator': string;
|
|
12
|
+
'x-component': string;
|
|
13
|
+
'x-component-props': {
|
|
14
|
+
showSearch: boolean;
|
|
15
|
+
allowClear: boolean;
|
|
16
|
+
className: string;
|
|
17
|
+
};
|
|
18
|
+
enum: {
|
|
19
|
+
label: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|
|
22
|
+
default: string;
|
|
23
|
+
};
|
|
24
|
+
url: {
|
|
25
|
+
type: string;
|
|
26
|
+
required: boolean;
|
|
27
|
+
title: string;
|
|
28
|
+
'x-decorator': string;
|
|
29
|
+
'x-component': string;
|
|
30
|
+
'x-component-props': {
|
|
31
|
+
scope: string;
|
|
32
|
+
autoSize: boolean;
|
|
33
|
+
fieldNames: {
|
|
34
|
+
value: string;
|
|
35
|
+
label: string;
|
|
36
|
+
};
|
|
37
|
+
placeholder: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
headers: {
|
|
41
|
+
type: string;
|
|
42
|
+
'x-component': string;
|
|
43
|
+
'x-decorator': string;
|
|
44
|
+
title: string;
|
|
45
|
+
description: string;
|
|
46
|
+
items: {
|
|
47
|
+
type: string;
|
|
48
|
+
properties: {
|
|
49
|
+
space: {
|
|
50
|
+
type: string;
|
|
51
|
+
'x-component': string;
|
|
52
|
+
properties: {
|
|
53
|
+
name: {
|
|
54
|
+
type: string;
|
|
55
|
+
'x-decorator': string;
|
|
56
|
+
'x-component': string;
|
|
57
|
+
'x-component-props': {
|
|
58
|
+
placeholder: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
value: {
|
|
62
|
+
type: string;
|
|
63
|
+
'x-decorator': string;
|
|
64
|
+
'x-component': string;
|
|
65
|
+
'x-component-props': {
|
|
66
|
+
scope: string;
|
|
67
|
+
fieldNames: {
|
|
68
|
+
value: string;
|
|
69
|
+
label: string;
|
|
70
|
+
};
|
|
71
|
+
useTypedConstant: boolean;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
remove: {
|
|
75
|
+
type: string;
|
|
76
|
+
'x-decorator': string;
|
|
77
|
+
'x-component': string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
properties: {
|
|
84
|
+
add: {
|
|
85
|
+
type: string;
|
|
86
|
+
title: string;
|
|
87
|
+
'x-component': string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
params: {
|
|
92
|
+
type: string;
|
|
93
|
+
'x-component': string;
|
|
94
|
+
'x-decorator': string;
|
|
95
|
+
title: string;
|
|
96
|
+
items: {
|
|
97
|
+
type: string;
|
|
98
|
+
properties: {
|
|
99
|
+
space: {
|
|
100
|
+
type: string;
|
|
101
|
+
'x-component': string;
|
|
102
|
+
properties: {
|
|
103
|
+
name: {
|
|
104
|
+
type: string;
|
|
105
|
+
'x-decorator': string;
|
|
106
|
+
'x-component': string;
|
|
107
|
+
'x-component-props': {
|
|
108
|
+
placeholder: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
value: {
|
|
112
|
+
type: string;
|
|
113
|
+
'x-decorator': string;
|
|
114
|
+
'x-component': string;
|
|
115
|
+
'x-component-props': {
|
|
116
|
+
scope: string;
|
|
117
|
+
fieldNames: {
|
|
118
|
+
value: string;
|
|
119
|
+
label: string;
|
|
120
|
+
};
|
|
121
|
+
useTypedConstant: boolean;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
remove: {
|
|
125
|
+
type: string;
|
|
126
|
+
'x-decorator': string;
|
|
127
|
+
'x-component': string;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
properties: {
|
|
134
|
+
add: {
|
|
135
|
+
type: string;
|
|
136
|
+
title: string;
|
|
137
|
+
'x-component': string;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
data: {
|
|
142
|
+
type: string;
|
|
143
|
+
title: string;
|
|
144
|
+
'x-decorator': string;
|
|
145
|
+
'x-decorator-props': {};
|
|
146
|
+
'x-component': string;
|
|
147
|
+
'x-component-props': {
|
|
148
|
+
scope: string;
|
|
149
|
+
fieldNames: {
|
|
150
|
+
value: string;
|
|
151
|
+
label: string;
|
|
152
|
+
};
|
|
153
|
+
changeOnSelect: boolean;
|
|
154
|
+
autoSize: {
|
|
155
|
+
minRows: number;
|
|
156
|
+
};
|
|
157
|
+
placeholder: string;
|
|
158
|
+
};
|
|
159
|
+
description: string;
|
|
160
|
+
};
|
|
161
|
+
timeout: {
|
|
162
|
+
type: string;
|
|
163
|
+
title: string;
|
|
164
|
+
'x-decorator': string;
|
|
165
|
+
'x-decorator-props': {};
|
|
166
|
+
'x-component': string;
|
|
167
|
+
'x-component-props': {
|
|
168
|
+
addonAfter: string;
|
|
169
|
+
min: number;
|
|
170
|
+
step: number;
|
|
171
|
+
defaultValue: number;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"react": "18.3.1",
|
|
3
|
+
"@tachybase/client": "0.23.8",
|
|
4
|
+
"react-i18next": "15.2.0",
|
|
5
|
+
"@tachybase/schema": "0.23.8",
|
|
6
|
+
"@tachybase/logger": "0.23.8",
|
|
7
|
+
"@tachybase/server": "0.23.8",
|
|
8
|
+
"@tachybase/test": "0.23.8",
|
|
9
|
+
"@tachybase/components": "0.23.8",
|
|
10
|
+
"antd": "5.22.5",
|
|
11
|
+
"@tachybase/utils": "0.23.8",
|
|
12
|
+
"react-router-dom": "6.28.1",
|
|
13
|
+
"@tachybase/actions": "0.23.8",
|
|
14
|
+
"@tachybase/evaluators": "0.23.8",
|
|
15
|
+
"axios": "1.7.9",
|
|
16
|
+
"@tachybase/database": "0.23.8"
|
|
17
|
+
};
|
package/dist/index.d.ts
ADDED
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,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"\"Content-Type\" only support \"application/json\", and no need to specify": "\"Content-Type\"은 \"application/json\"만 지원하며 지정할 필요가 없습니다",
|
|
3
|
+
"Access control": "접근 제어",
|
|
4
|
+
"Add parameter": "파라미터 추가",
|
|
5
|
+
"Add request header": "요청 헤더 추가",
|
|
6
|
+
"Body": "바디",
|
|
7
|
+
"Custom Request": "사용자 정의 요청",
|
|
8
|
+
"Enter description info": "설명 정보 입력",
|
|
9
|
+
"Format": "형식",
|
|
10
|
+
"HTTP method": "HTTP 메소드",
|
|
11
|
+
"Headers": "헤더",
|
|
12
|
+
"If not set, all roles can see this action": "설정되지 않은 경우 모든 역할이이 작업을 볼 수 있습니다",
|
|
13
|
+
"Input request data": "요청 데이터 입력",
|
|
14
|
+
"Insert": "삽입",
|
|
15
|
+
"Only support standard JSON data": "표준 JSON 데이터만 지원됩니다",
|
|
16
|
+
"Parameters": "파라미터",
|
|
17
|
+
"Please configure the request settings first": "먼저 요청 설정을 구성하십시오",
|
|
18
|
+
"Request settings": "요청 설정",
|
|
19
|
+
"Roles": "역할",
|
|
20
|
+
"Timeout config": "타임아웃 설정",
|
|
21
|
+
"Title": "제목",
|
|
22
|
+
"URL": "URL",
|
|
23
|
+
"Use variable": "변수 사용",
|
|
24
|
+
"When the HTTP method is Post, Put or Patch, and this custom request inside the form, the request body will be automatically filled in with the form data": "HTTP 메소드가 Post, Put 또는 Patch이고이 사용자 정의 요청이 양식 내에있는 경우 요청 본문은 자동으로 양식 데이터로 채워집니다",
|
|
25
|
+
"ms": "밀리초"
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"\"Content-Type\" only support \"application/json\", and no need to specify": "\"Content-Type\" 请求头仅支持 \"application/json\",无需填写",
|
|
3
|
+
"Access control": "权限控制",
|
|
4
|
+
"Add parameter": "添加参数",
|
|
5
|
+
"Add request header": "添加请求头",
|
|
6
|
+
"Body": "请求体",
|
|
7
|
+
"Custom Request": "自定义请求",
|
|
8
|
+
"Enter description info": "输入描述信息",
|
|
9
|
+
"Format": "格式化",
|
|
10
|
+
"HTTP method": "HTTP 方法",
|
|
11
|
+
"Headers": "请求头",
|
|
12
|
+
"If not set, all roles can see this action": "如果不设置,所有角色都可以看到这个自定义请求",
|
|
13
|
+
"Input request data": "输入请求数据",
|
|
14
|
+
"Insert": "插入",
|
|
15
|
+
"Only support standard JSON data": "仅支持标准 JSON 数据",
|
|
16
|
+
"Parameters": "参数",
|
|
17
|
+
"Please configure the request settings first": "请先配置请求设置",
|
|
18
|
+
"Request settings": "请求设置",
|
|
19
|
+
"Roles": "角色",
|
|
20
|
+
"Timeout config": "超时设置",
|
|
21
|
+
"Title": "标题",
|
|
22
|
+
"URL": "URL",
|
|
23
|
+
"Use variable": "使用变量",
|
|
24
|
+
"When the HTTP method is Post, Put or Patch, and this custom request inside the form, the request body will be automatically filled in with the form data": "当请求方法为 Post、Put 或 Patch 时,且此自定义请求在表单内,请求体将自动填充表单数据",
|
|
25
|
+
"ms": "毫秒"
|
|
26
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 listByCurrentRole_exports = {};
|
|
19
|
+
__export(listByCurrentRole_exports, {
|
|
20
|
+
listByCurrentRole: () => listByCurrentRole
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(listByCurrentRole_exports);
|
|
23
|
+
async function listByCurrentRole(ctx) {
|
|
24
|
+
const repo = ctx.db.getRepository("customRequests");
|
|
25
|
+
const data = await repo.find({
|
|
26
|
+
appends: ["roles"]
|
|
27
|
+
});
|
|
28
|
+
const crRepo = ctx.db.getRepository("customRequestsRoles");
|
|
29
|
+
ctx.body = data.filter((item) => {
|
|
30
|
+
return !item.roles.length;
|
|
31
|
+
}).map((item) => item.key).concat(
|
|
32
|
+
(await crRepo.find({
|
|
33
|
+
filter: {
|
|
34
|
+
roleName: ctx.state.currentRole
|
|
35
|
+
}
|
|
36
|
+
})).map((item) => item.customRequestKey)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
listByCurrentRole
|
|
42
|
+
});
|
|
@@ -0,0 +1,189 @@
|
|
|
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 send_exports = {};
|
|
29
|
+
__export(send_exports, {
|
|
30
|
+
send: () => send
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(send_exports);
|
|
33
|
+
var import_evaluators = require("@tachybase/evaluators");
|
|
34
|
+
var import_utils = require("@tachybase/utils");
|
|
35
|
+
var import_axios = __toESM(require("axios"));
|
|
36
|
+
const getHeaders = (headers) => {
|
|
37
|
+
return Object.keys(headers).reduce((hds, key) => {
|
|
38
|
+
if (key.toLocaleLowerCase().startsWith("x-")) {
|
|
39
|
+
hds[key] = headers[key];
|
|
40
|
+
}
|
|
41
|
+
return hds;
|
|
42
|
+
}, {});
|
|
43
|
+
};
|
|
44
|
+
const arrayToObject = (arr) => {
|
|
45
|
+
return arr.reduce((acc, cur) => {
|
|
46
|
+
acc[cur.name] = cur.value;
|
|
47
|
+
return acc;
|
|
48
|
+
}, {});
|
|
49
|
+
};
|
|
50
|
+
const omitNullAndUndefined = (obj) => {
|
|
51
|
+
return Object.keys(obj).reduce((acc, cur) => {
|
|
52
|
+
if (obj[cur] !== null && typeof obj[cur] !== "undefined") {
|
|
53
|
+
acc[cur] = obj[cur];
|
|
54
|
+
}
|
|
55
|
+
return acc;
|
|
56
|
+
}, {});
|
|
57
|
+
};
|
|
58
|
+
const CurrentUserVariableRegExp = /{{\s*(currentUser[^}]+)\s*}}/g;
|
|
59
|
+
const getCurrentUserAppends = (str, user) => {
|
|
60
|
+
const matched = str.matchAll(CurrentUserVariableRegExp);
|
|
61
|
+
return Array.from(matched).map((item) => {
|
|
62
|
+
const keys = (item == null ? void 0 : item[1].split(".")) || [];
|
|
63
|
+
const appendKey = keys[1];
|
|
64
|
+
if (keys.length > 2 && !Reflect.has(user || {}, appendKey)) {
|
|
65
|
+
return appendKey;
|
|
66
|
+
}
|
|
67
|
+
}).filter(Boolean);
|
|
68
|
+
};
|
|
69
|
+
async function send(ctx, next) {
|
|
70
|
+
var _a, _b, _c, _d;
|
|
71
|
+
const { filterByTk, resourceName, values = {} } = ctx.action.params;
|
|
72
|
+
const {
|
|
73
|
+
currentRecord = {
|
|
74
|
+
id: 0,
|
|
75
|
+
appends: [],
|
|
76
|
+
data: {}
|
|
77
|
+
}
|
|
78
|
+
} = values;
|
|
79
|
+
if (ctx.state.currentRole !== "root") {
|
|
80
|
+
const crRepo = ctx.db.getRepository("customRequestsRoles");
|
|
81
|
+
const hasRoles = await crRepo.find({
|
|
82
|
+
filter: {
|
|
83
|
+
customRequestKey: filterByTk
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
if (hasRoles.length) {
|
|
87
|
+
if (!hasRoles.find((item) => item.roleName === ctx.state.currentRole)) {
|
|
88
|
+
return ctx.throw(403, "custom request no permission");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const repo = ctx.db.getRepository(resourceName);
|
|
93
|
+
const requestConfig = await repo.findOne({
|
|
94
|
+
filter: {
|
|
95
|
+
key: filterByTk
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
if (!requestConfig) {
|
|
99
|
+
ctx.throw(404, "request config not found");
|
|
100
|
+
}
|
|
101
|
+
ctx.withoutDataWrapping = true;
|
|
102
|
+
const { collectionName, url, headers = [], params = [], data = {}, ...options } = requestConfig.options || {};
|
|
103
|
+
if (!url) {
|
|
104
|
+
return ctx.throw(400, ctx.t("Please configure the request settings first", { ns: "action-custom-request" }));
|
|
105
|
+
}
|
|
106
|
+
let currentRecordValues = {};
|
|
107
|
+
if (collectionName && typeof currentRecord.id !== "undefined") {
|
|
108
|
+
const recordRepo = ctx.db.getRepository(collectionName);
|
|
109
|
+
currentRecordValues = ((_a = await recordRepo.findOne({
|
|
110
|
+
filterByTk: currentRecord.id,
|
|
111
|
+
appends: currentRecord.appends
|
|
112
|
+
})) == null ? void 0 : _a.toJSON()) || {};
|
|
113
|
+
}
|
|
114
|
+
let currentUser = ctx.auth.user;
|
|
115
|
+
const userAppends = getCurrentUserAppends(
|
|
116
|
+
JSON.stringify(url) + JSON.stringify(headers) + JSON.stringify(params) + JSON.stringify(data),
|
|
117
|
+
ctx.auth.user
|
|
118
|
+
);
|
|
119
|
+
if (userAppends.length) {
|
|
120
|
+
currentUser = ((_b = await ctx.db.getRepository("users").findOne({
|
|
121
|
+
filterByTk: ctx.auth.user.id,
|
|
122
|
+
appends: userAppends
|
|
123
|
+
})) == null ? void 0 : _b.toJSON()) || {};
|
|
124
|
+
}
|
|
125
|
+
const variables = {
|
|
126
|
+
currentRecord: {
|
|
127
|
+
...currentRecordValues,
|
|
128
|
+
...currentRecord.data
|
|
129
|
+
},
|
|
130
|
+
currentUser,
|
|
131
|
+
currentTime: (/* @__PURE__ */ new Date()).toISOString()
|
|
132
|
+
};
|
|
133
|
+
const getParsedValue = (value) => {
|
|
134
|
+
const template = (0, import_utils.parse)(value);
|
|
135
|
+
template.parameters.forEach(({ key }) => {
|
|
136
|
+
(0, import_evaluators.appendArrayColumn)(variables, key);
|
|
137
|
+
});
|
|
138
|
+
return template(variables);
|
|
139
|
+
};
|
|
140
|
+
const axiosRequestConfig = {
|
|
141
|
+
baseURL: ctx.origin,
|
|
142
|
+
...options,
|
|
143
|
+
url: getParsedValue(url),
|
|
144
|
+
headers: {
|
|
145
|
+
Authorization: "Bearer " + ctx.getBearerToken(),
|
|
146
|
+
...getHeaders(ctx.headers),
|
|
147
|
+
...omitNullAndUndefined(getParsedValue(arrayToObject(headers)))
|
|
148
|
+
},
|
|
149
|
+
params: getParsedValue(arrayToObject(params)),
|
|
150
|
+
data: getParsedValue(data)
|
|
151
|
+
};
|
|
152
|
+
const requestUrl = import_axios.default.getUri(axiosRequestConfig);
|
|
153
|
+
this.logger.info(`action-custom-request:send:${filterByTk} request url ${requestUrl}`);
|
|
154
|
+
this.logger.info(
|
|
155
|
+
`action-custom-request:send:${filterByTk} request config ${JSON.stringify({
|
|
156
|
+
...axiosRequestConfig,
|
|
157
|
+
headers: {
|
|
158
|
+
...axiosRequestConfig.headers,
|
|
159
|
+
Authorization: null
|
|
160
|
+
}
|
|
161
|
+
})}`
|
|
162
|
+
);
|
|
163
|
+
try {
|
|
164
|
+
const res = await (0, import_axios.default)({ ...axiosRequestConfig, responseType: "stream" });
|
|
165
|
+
ctx.set("Content-Type", `${res.headers["content-type"]}`);
|
|
166
|
+
ctx.set("Content-disposition", `${res.headers["content-disposition"]}`);
|
|
167
|
+
this.logger.info(`action-custom-request:send:${filterByTk} success`);
|
|
168
|
+
const readable = res.data;
|
|
169
|
+
ctx.body = readable;
|
|
170
|
+
} catch (err) {
|
|
171
|
+
if (import_axios.default.isAxiosError(err)) {
|
|
172
|
+
ctx.status = ((_c = err.response) == null ? void 0 : _c.status) || 500;
|
|
173
|
+
ctx.body = ((_d = err.response) == null ? void 0 : _d.data) || { message: err.message };
|
|
174
|
+
this.logger.error(
|
|
175
|
+
`action-custom-request:send:${filterByTk} error. status: ${ctx.status}, body: ${typeof ctx.body === "string" ? ctx.body : JSON.stringify(ctx.body)}`
|
|
176
|
+
);
|
|
177
|
+
} else {
|
|
178
|
+
this.logger.error(
|
|
179
|
+
`action-custom-request:send:${filterByTk} error. status: ${ctx.status}, message: ${err.message}`
|
|
180
|
+
);
|
|
181
|
+
ctx.throw(500, err == null ? void 0 : err.message);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return next();
|
|
185
|
+
}
|
|
186
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
+
0 && (module.exports = {
|
|
188
|
+
send
|
|
189
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
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 customRequest_exports = {};
|
|
19
|
+
__export(customRequest_exports, {
|
|
20
|
+
default: () => customRequest_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(customRequest_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var customRequest_default = (0, import_database.defineCollection)({
|
|
25
|
+
dumpRules: "required",
|
|
26
|
+
name: "customRequests",
|
|
27
|
+
fields: [
|
|
28
|
+
{
|
|
29
|
+
type: "uid",
|
|
30
|
+
name: "key",
|
|
31
|
+
primaryKey: true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: "belongsToMany",
|
|
35
|
+
name: "roles",
|
|
36
|
+
onDelete: "CASCADE",
|
|
37
|
+
through: "customRequestsRoles",
|
|
38
|
+
target: "roles",
|
|
39
|
+
foreignKey: "customRequestKey",
|
|
40
|
+
otherKey: "roleName",
|
|
41
|
+
sourceKey: "key",
|
|
42
|
+
targetKey: "name"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: "json",
|
|
46
|
+
name: "options"
|
|
47
|
+
// 配置的请求参数都放这里
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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 customRequestsRoles_exports = {};
|
|
19
|
+
__export(customRequestsRoles_exports, {
|
|
20
|
+
default: () => customRequestsRoles_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(customRequestsRoles_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var customRequestsRoles_default = (0, import_database.defineCollection)({
|
|
25
|
+
dumpRules: "required",
|
|
26
|
+
name: "customRequestsRoles"
|
|
27
|
+
});
|
|
@@ -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"));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Logger } from '@tachybase/logger';
|
|
2
|
+
import { InstallOptions, Plugin } from '@tachybase/server';
|
|
3
|
+
export declare class CustomRequestPlugin extends Plugin {
|
|
4
|
+
logger: Logger;
|
|
5
|
+
afterAdd(): void;
|
|
6
|
+
beforeLoad(): void;
|
|
7
|
+
getLogger(): Logger;
|
|
8
|
+
load(): Promise<void>;
|
|
9
|
+
install(options?: InstallOptions): Promise<void>;
|
|
10
|
+
afterEnable(): Promise<void>;
|
|
11
|
+
afterDisable(): Promise<void>;
|
|
12
|
+
remove(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export default CustomRequestPlugin;
|
|
@@ -0,0 +1,71 @@
|
|
|
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 plugin_exports = {};
|
|
19
|
+
__export(plugin_exports, {
|
|
20
|
+
CustomRequestPlugin: () => CustomRequestPlugin,
|
|
21
|
+
default: () => plugin_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
24
|
+
var import_path = require("path");
|
|
25
|
+
var import_server = require("@tachybase/server");
|
|
26
|
+
var import_listByCurrentRole = require("./actions/listByCurrentRole");
|
|
27
|
+
var import_send = require("./actions/send");
|
|
28
|
+
class CustomRequestPlugin extends import_server.Plugin {
|
|
29
|
+
logger;
|
|
30
|
+
afterAdd() {
|
|
31
|
+
}
|
|
32
|
+
beforeLoad() {
|
|
33
|
+
this.logger = this.getLogger();
|
|
34
|
+
}
|
|
35
|
+
getLogger() {
|
|
36
|
+
const logger = this.createLogger({
|
|
37
|
+
dirname: "action-custom-request",
|
|
38
|
+
filename: "%DATE%.log",
|
|
39
|
+
transports: process.env.NODE_ENV === "production" ? ["dailyRotateFile"] : ["console"]
|
|
40
|
+
});
|
|
41
|
+
return logger;
|
|
42
|
+
}
|
|
43
|
+
async load() {
|
|
44
|
+
await this.importCollections((0, import_path.resolve)(__dirname, "collections"));
|
|
45
|
+
this.app.resource({
|
|
46
|
+
name: "customRequests",
|
|
47
|
+
actions: {
|
|
48
|
+
send: import_send.send.bind(this),
|
|
49
|
+
listByCurrentRole: import_listByCurrentRole.listByCurrentRole
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
this.app.acl.registerSnippet({
|
|
53
|
+
name: `ui.${this.name}`,
|
|
54
|
+
actions: ["customRequests:*", "roles:list"]
|
|
55
|
+
});
|
|
56
|
+
this.app.acl.allow("customRequests", ["send", "listByCurrentRole"], "loggedIn");
|
|
57
|
+
}
|
|
58
|
+
async install(options) {
|
|
59
|
+
}
|
|
60
|
+
async afterEnable() {
|
|
61
|
+
}
|
|
62
|
+
async afterDisable() {
|
|
63
|
+
}
|
|
64
|
+
async remove() {
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
var plugin_default = CustomRequestPlugin;
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
CustomRequestPlugin
|
|
71
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tachybase/plugin-action-custom-request",
|
|
3
|
+
"displayName": "Action: Custom request",
|
|
4
|
+
"version": "0.23.8",
|
|
5
|
+
"description": "Sending a request to any HTTP service supports sending context data to the target service.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"Actions"
|
|
8
|
+
],
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"main": "dist/server/index.js",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"antd": "5.22.5",
|
|
13
|
+
"file-saver": "^2.0.5",
|
|
14
|
+
"lodash": "~4.17.21",
|
|
15
|
+
"react-i18next": "^15.2.0",
|
|
16
|
+
"react-router-dom": "6.28.1",
|
|
17
|
+
"@tachybase/schema": "0.23.8",
|
|
18
|
+
"@tachybase/components": "0.23.8"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@tachybase/client": "0.23.8",
|
|
22
|
+
"@tachybase/database": "0.23.8",
|
|
23
|
+
"@tachybase/test": "0.23.8",
|
|
24
|
+
"@tachybase/evaluators": "0.23.8",
|
|
25
|
+
"@tachybase/utils": "0.23.8",
|
|
26
|
+
"@tachybase/server": "0.23.8",
|
|
27
|
+
"@tachybase/sdk": "0.23.8",
|
|
28
|
+
"@tachybase/logger": "0.23.8",
|
|
29
|
+
"@tachybase/actions": "0.23.8"
|
|
30
|
+
},
|
|
31
|
+
"description.zh-CN": "向任意 HTTP 服务发送请求,支持将上下文数据发送给目标服务。",
|
|
32
|
+
"displayName.zh-CN": "操作:自定义请求",
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tachybase-build --no-dts @tachybase/plugin-action-custom-request"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/server.d.ts
ADDED
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/server/index.js');
|