tadcode-wpsjs 1.1.0 → 1.2.1
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/README.md +23 -18
- package/index.js +4 -1
- package/index.ts +82 -57
- package/package.json +5 -18
- package/remoteCode/index.js +23 -23
- package/return.wpsjs.json +72 -0
- package/types/KSDrive.d.ts +72 -72
- package/types/TypeTools.d.ts +53 -0
- package/types/application/CriteriaValue.d.ts +31 -0
- package/types/application/Field.d.ts +25 -0
- package/types/application/FieldApi.d.ts +212 -0
- package/types/application/Fields.d.ts +20 -0
- package/types/application/Record.d.ts +22 -0
- package/types/application/RecordApi.d.ts +178 -0
- package/types/application/RecordRange.d.ts +77 -0
- package/types/application/Records.d.ts +28 -0
- package/types/application/SelectionApi.d.ts +29 -0
- package/types/application/Sheet.d.ts +73 -0
- package/types/application/SheetApi.d.ts +62 -0
- package/types/application/Sheets.d.ts +88 -0
- package/types/application/View.d.ts +51 -0
- package/types/application/ViewApi.d.ts +26 -0
- package/types/application/Views.d.ts +36 -0
- package/types/application/global.d.ts +28 -0
- package/types/application/index.d.ts +27 -0
- package/types/global.d.ts +36 -0
- package/types/index.d.ts +4 -63
- package/types/return.response.d.ts +34 -0
- package/types/DB_Application.d.ts +0 -49
- package/types/DB_Application_Field.d.ts +0 -212
- package/types/DB_Application_Record.d.ts +0 -178
- package/types/DB_Application_Selection.ts +0 -22
- package/types/DB_Application_Sheet.d.ts +0 -63
- package/types/DB_Application_View.d.ts +0 -24
- package/types/type-tools.ts +0 -50
package/README.md
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
# tadcode-wpsjs
|
|
2
2
|
|
|
3
|
-
##
|
|
4
|
-
- [**AirScript文档**](https://airsheet.wps.cn/docs/apitoken/intro.html)
|
|
5
|
-
- [**WPS多维表格:“开发”功能使用说明文档**](https://365.kdocs.cn/l/ctzsgDlAGF0l)
|
|
6
|
-
- [**执行AirScript脚本操作使用指南**](https://365.kdocs.cn/l/cdQOqc6TZuMk)
|
|
7
|
-
- [**快速入门多维表“开发”**](https://365.kdocs.cn/l/ctx1jAV1xJhR)
|
|
8
|
-
- [**WPS开放平台dbsheet-Api部分**](https://365.kdocs.cn/3rd/open/documents/app-integration-dev/guide/dbsheet/Api/api-instro)
|
|
3
|
+
## 介绍
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
项目地址:[https://gitcode.com/caisijian/tadcode-wpsjs](https://gitcode.com/caisijian/tadcode-wpsjs)
|
|
11
6
|
|
|
12
|
-
|
|
7
|
+
在部署远程代码的情况下,可以远程调用`WpsjsGlobal`,实现对支持`AirScript`的多维表,智能表格等远程操作。如果你对`AirScript`,感兴趣,也能帮助你学习`WpsjsGlobal`。
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
原理是使用代理收集调用信息,之后让远程代码进行调用并且返回结果。
|
|
10
|
+
远程代码在`tadcode-wpsjs/remoteCode`目录的`index.js`文件中。
|
|
11
|
+
将其复制粘贴到对应`webhook`的脚本中才能支持`WpsjsGlobal`对象的调用。
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
目前已经对多维表的基本操作,实现了全类型支持。
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
如果对你有用请在[gitcode](https://gitcode.com/caisijian/tadcode-wpsjs)给个`star`,谢谢。
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
## 联系我
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
**如你有业务需要wps代码,可以点此[联系我](https://f.kdocs.cn/g/SIdEy3GE/),三个工作日内必定回复。**
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
**如您公司存在敏感信息业务,需要长期人才,亦可来讯商谈。**
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+

|
|
27
24
|
|
|
28
25
|
## 安装
|
|
29
26
|
|
|
@@ -59,15 +56,16 @@ console.log(data)
|
|
|
59
56
|
### 重命名(远程赋值操作)
|
|
60
57
|
|
|
61
58
|
```ts
|
|
62
|
-
import { initRemoteCallWpsjsGlobal } from 'tadcode-wpsjs'
|
|
59
|
+
import { initRemoteCallWpsjsGlobal,setValue } from 'tadcode-wpsjs'
|
|
63
60
|
/* 脚本令牌 具体获取方式参考上面 */
|
|
64
61
|
const scriptToken = 'xxxx'
|
|
65
62
|
/* webhook url地址 具体获取方式参考上面 */
|
|
66
63
|
const webhookURL = 'xxxx'
|
|
67
64
|
const wpsjsGlobal = initRemoteCallWpsjsGlobal({ scriptToken, webhookURL, })
|
|
65
|
+
|
|
68
66
|
/* 类型完善中 */
|
|
69
|
-
wpsjsGlobal.Application.Sheets(1)
|
|
70
|
-
|
|
67
|
+
const sheet = wpsjsGlobal.Application.Sheets(1)
|
|
68
|
+
await setValue(sheet,'Name','table1001')
|
|
71
69
|
```
|
|
72
70
|
|
|
73
71
|
### 执行脚本并且返回(不用部署remoteCode代码)
|
|
@@ -86,3 +84,10 @@ console.log(data)
|
|
|
86
84
|
## 支持
|
|
87
85
|
|
|
88
86
|
如果对你有用请在[gitcode](https://gitcode.com/caisijian/tadcode-wpsjs)给个`star`
|
|
87
|
+
|
|
88
|
+
## 基于wps官方文档
|
|
89
|
+
- [**AirScript文档**](https://airsheet.wps.cn/docs/apitoken/intro.html)
|
|
90
|
+
- [**WPS多维表格:“开发”功能使用说明文档**](https://365.kdocs.cn/l/ctzsgDlAGF0l)
|
|
91
|
+
- [**执行AirScript脚本操作使用指南**](https://365.kdocs.cn/l/cdQOqc6TZuMk)
|
|
92
|
+
- [**快速入门多维表“开发”**](https://365.kdocs.cn/l/ctx1jAV1xJhR)
|
|
93
|
+
- [**WPS开放平台dbsheet-Api部分**](https://365.kdocs.cn/3rd/open/documents/app-integration-dev/guide/dbsheet/Api/api-instro)
|
package/index.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{writeFile as
|
|
1
|
+
import{writeFile as A}from"fs/promises";import I from"path";var Z=Symbol("info-tacode"),F=Symbol("then-tacode"),U=Symbol("raw-tacode"),L={then:1,catch:1,finally:1},R=(B)=>{let{scriptToken:H,webhookURL:z,isAsync:N=!1,printLog:Q=!1,writeLogFile:J=!1}=B;if(!H||!z)throw Error("scriptToken and webhookURL are both required");let $=async(D)=>{let K=await D.json();if(J)await j(K);if(x(K),Q)V(K);return K.data?.result},X=async(D)=>P({scriptToken:H,webhookURL:z,isAsync:N,argv:{info:D}}).then($),W=()=>{let D=()=>{};return D[F]=!1,D[Z]=[],D},v={get(D,K,q){if(K===U)return D;let G=D[Z],M=W(),Y=M[Z];if(Y.push(...G),K in L)M[F]=!0;return Y.push({method:"get",arguments:[K]}),new Proxy(M,v)},set(D,K,q,G){let Y=[...D[Z],{method:"set",arguments:[K,q]}];return _=X(Y),!0},apply(D,K,q){let G=D[F],M=D[Z],Y=W();if(G){let E=M[M.length-1].arguments[0];return M.pop(),X(M)[E](...q)}return Y[Z].push(...M,{method:"apply",arguments:q}),new Proxy(Y,v)}};return new Proxy(W(),v)},P=({scriptToken:B,webhookURL:H,isAsync:z,argv:N})=>{let Q=JSON.stringify({Context:{argv:N}}),J=I.parse(H);J.base=z?"task":"sync_task";let $=I.format(J);return fetch($,{method:"post",headers:{"Content-Type":"application/json","AirScript-Token":B},body:Q})},_=null,S=async()=>_,h=async(B,H,z)=>{return B[U][Z].push({method:"set",arguments:[H,z]}),B},w=(B)=>{let H=new URL("https://www.kdocs.cn/api/v3/script/task");return H.searchParams.append("task_id",B),fetch(H)},V=(B)=>{let{status:H,data:z}=B;if(console.log("===result==="),z?.result)console.log(z?.result);let N=z?.logs.filter((J)=>J.filename!=="<system>");if(N.length!==0){console.log("===console===");for(let J of N)console[J.level](...J.args)}let Q=z?.logs.at(-1).unix_time-z?.logs[1].unix_time;console.log("runtime:",Q),console.log("status:",H)},x=(B)=>{let{error:H,error_details:z,errno:N,result:Q,msg:J,reason:$}=B;if(H){let X=Error(z.msg,{cause:`${z.stack.join(`
|
|
2
|
+
`)}
|
|
3
|
+
unix_time:${z.unix_time}`});throw X.name=`Remote ${z.name}`,X}if("errno"in B){let X=Error(Q,{cause:`${J}
|
|
4
|
+
${$}`});throw X.name=`Remote Errno ${N}`,X}},j=(B)=>{return A("./return.wpsjs.json",JSON.stringify(B,void 0,2))};export{j as writeLogFileToCurrent,S as setValueOk,h as setValue,w as queryTask,R as initRemoteCallWpsjsGlobal,P as execution};
|
package/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InfoItem, RemoteCallWpsjsGlobalReturn, WpsjsGlobalApi } from '
|
|
1
|
+
import type { InfoItem, RemoteCallWpsjsGlobalReturn, WpsjsGlobalApi } from 'tadcode-wpsjs:global'
|
|
2
2
|
import { writeFile } from 'fs/promises'
|
|
3
3
|
import path from 'path'
|
|
4
4
|
|
|
@@ -15,58 +15,63 @@ interface Config {
|
|
|
15
15
|
writeLogFile?: boolean
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const infoSymbol = Symbol('info')
|
|
19
|
-
const
|
|
18
|
+
const infoSymbol = Symbol('info-tacode')
|
|
19
|
+
const promiseTagSymbol = Symbol('then-tacode')
|
|
20
|
+
const rawSymbol = Symbol('raw-tacode')
|
|
21
|
+
const promiseTypeObj = { then: 1, catch: 1, finally: 1 }
|
|
22
|
+
|
|
23
|
+
type ProxyTarget = { (): void;[infoSymbol]: InfoItem[], [promiseTagSymbol]: boolean }
|
|
20
24
|
|
|
21
25
|
const initRemoteCallWpsjsGlobal = (config: Config) => {
|
|
22
26
|
const { scriptToken, webhookURL, isAsync = false, printLog = false, writeLogFile = false, } = config
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
if (!scriptToken || !webhookURL) { throw new Error('scriptToken and webhookURL are both required') }
|
|
28
|
+
const handleResponse = async (response: Response) => {
|
|
29
|
+
const responseObj = await response.json()
|
|
30
|
+
if (writeLogFile) await writeLogFileToCurrent(responseObj)
|
|
31
|
+
handleError(responseObj)
|
|
32
|
+
if (printLog) printInfo(responseObj)
|
|
33
|
+
return responseObj['data']?.['result']
|
|
34
|
+
}
|
|
35
|
+
const startExecution = async (info: InfoItem[]) =>
|
|
36
|
+
execution({ scriptToken, webhookURL, isAsync, argv: { info } }).then(handleResponse)
|
|
37
|
+
const createProxyTarget = () => {
|
|
38
|
+
const func: ProxyTarget = () => { }
|
|
39
|
+
func[promiseTagSymbol] = false
|
|
40
|
+
func[infoSymbol] = []
|
|
41
|
+
return func
|
|
42
|
+
}
|
|
25
43
|
const handle: ProxyHandler<ProxyTarget> = {
|
|
26
|
-
get(target, p
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
func
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
func[isThenSymbol] = true
|
|
44
|
+
get(target, p, _receiver) {
|
|
45
|
+
if (p === rawSymbol) { return target }
|
|
46
|
+
const oldInfo = target[infoSymbol]
|
|
47
|
+
const func = createProxyTarget()
|
|
48
|
+
const info = func[infoSymbol]
|
|
49
|
+
info.push(...oldInfo)
|
|
50
|
+
if (p in promiseTypeObj) func[promiseTagSymbol] = true
|
|
51
|
+
info.push({ method: 'get', arguments: [p as string] })
|
|
35
52
|
return new Proxy(func, handle)
|
|
36
53
|
},
|
|
37
54
|
set(target, p, newValue, _receiver) {
|
|
38
|
-
const oldInfo = target[infoSymbol]
|
|
39
|
-
const info = [...oldInfo, { method: 'set', arguments: [p, newValue] }]
|
|
40
|
-
setValuePromise =
|
|
41
|
-
.then(async (response) => {
|
|
42
|
-
const responseObj = await response.json()
|
|
43
|
-
if (printLog) printInfo(responseObj)
|
|
44
|
-
if (writeLogFile) await writeLogFileToCurrent(responseObj)
|
|
45
|
-
return responseObj?.['data']['result']
|
|
46
|
-
})
|
|
55
|
+
const oldInfo = target[infoSymbol]
|
|
56
|
+
const info: InfoItem[] = [...oldInfo, { method: 'set', arguments: [p, newValue] }]
|
|
57
|
+
setValuePromise = startExecution(info)
|
|
47
58
|
return true
|
|
48
59
|
},
|
|
49
60
|
apply(target, _thisArg, argArray) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return execution({ scriptToken, webhookURL, isAsync, argv: { info } })
|
|
59
|
-
.then(async (response) => {
|
|
60
|
-
const responseObj = await response.json()
|
|
61
|
-
if (printLog) printInfo(responseObj)
|
|
62
|
-
if (writeLogFile) await writeLogFileToCurrent(responseObj)
|
|
63
|
-
return responseObj?.['data']['result']
|
|
64
|
-
})
|
|
65
|
-
.then(...argArray)
|
|
61
|
+
const isCallPromise = target[promiseTagSymbol]
|
|
62
|
+
const info = target[infoSymbol]
|
|
63
|
+
const func = createProxyTarget()
|
|
64
|
+
if (isCallPromise) {
|
|
65
|
+
const last = info[info.length - 1]
|
|
66
|
+
const p = last.arguments[0] as 'then'
|
|
67
|
+
info.pop()
|
|
68
|
+
return startExecution(info)[p](...argArray)
|
|
66
69
|
}
|
|
70
|
+
func[infoSymbol].push(...info, { method: 'apply', arguments: argArray })
|
|
71
|
+
return new Proxy(func, handle)
|
|
67
72
|
},
|
|
68
73
|
}
|
|
69
|
-
return new Proxy(()
|
|
74
|
+
return new Proxy(createProxyTarget(), handle) as unknown as WpsjsGlobalApi
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
type ExecutionConfig = Pick<Config, 'scriptToken' | 'webhookURL' | 'isAsync'> & { argv?: Record<string | number, any> }
|
|
@@ -91,6 +96,18 @@ const execution = ({ scriptToken, webhookURL, isAsync, argv }: ExecutionConfig)
|
|
|
91
96
|
let setValuePromise: any = null
|
|
92
97
|
/* 远程调用的赋值操作返回的promise */
|
|
93
98
|
const setValueOk = async () => setValuePromise
|
|
99
|
+
/**赋值 */
|
|
100
|
+
const setValue = async <T extends Promise<any>>(
|
|
101
|
+
promiseObj: T,
|
|
102
|
+
p: keyof Awaited<T>,
|
|
103
|
+
newValue: Awaited<T>[keyof Awaited<T>],
|
|
104
|
+
) => {
|
|
105
|
+
const obj = promiseObj as Awaited<T>
|
|
106
|
+
const func = obj[rawSymbol] as ProxyTarget
|
|
107
|
+
const info = func[infoSymbol]
|
|
108
|
+
info.push({ method: 'set', arguments: [p as string, newValue] })
|
|
109
|
+
return promiseObj
|
|
110
|
+
}
|
|
94
111
|
|
|
95
112
|
const queryTask = (id: string) => {
|
|
96
113
|
const url = new URL('https://www.kdocs.cn/api/v3/script/task')
|
|
@@ -99,36 +116,44 @@ const queryTask = (id: string) => {
|
|
|
99
116
|
}
|
|
100
117
|
|
|
101
118
|
const printInfo = (remoteCallResponse: RemoteCallWpsjsGlobalReturn) => {
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
console.log(
|
|
105
|
-
const
|
|
106
|
-
console.log('runtime:', time)
|
|
107
|
-
if (error) {
|
|
108
|
-
console.error(error_details.name)
|
|
109
|
-
console.error(error_details.msg)
|
|
110
|
-
console.error(error_details.stack)
|
|
111
|
-
}
|
|
112
|
-
const userInfo = data.logs.filter(x => x.filename !== '<system>')
|
|
119
|
+
const { status, data, } = remoteCallResponse as RemoteCallWpsjsGlobalReturn
|
|
120
|
+
console.log('===result===')
|
|
121
|
+
if (data?.result) { console.log(data?.result) }
|
|
122
|
+
const userInfo = data?.logs.filter(x => x.filename !== '<system>')
|
|
113
123
|
if (userInfo.length !== 0) {
|
|
114
|
-
console.log('
|
|
124
|
+
console.log('===console===')
|
|
115
125
|
for (const item of userInfo) {
|
|
116
126
|
console[item.level](...item.args)
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
|
-
|
|
120
|
-
console.log(
|
|
121
|
-
|
|
129
|
+
const time = data?.logs.at(-1)!.unix_time - data?.logs[1].unix_time
|
|
130
|
+
console.log('runtime:', time)
|
|
131
|
+
console.log('status:', status)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const handleError = (remoteCallResponse: RemoteCallWpsjsGlobalReturn) => {
|
|
135
|
+
const { error, error_details, errno, result, msg, reason } = remoteCallResponse as RemoteCallWpsjsGlobalReturn
|
|
136
|
+
if (error) {
|
|
137
|
+
const normalErr = new Error(error_details.msg, { cause: `${error_details.stack.join('\n')}\nunix_time:${error_details.unix_time}` })
|
|
138
|
+
normalErr.name = `Remote ${error_details.name}`
|
|
139
|
+
throw normalErr
|
|
140
|
+
}
|
|
141
|
+
if ('errno' in remoteCallResponse) {
|
|
142
|
+
const err = new Error(result, { cause: `${msg}\n${reason}` })
|
|
143
|
+
err.name = `Remote Errno ${errno}`
|
|
144
|
+
throw err
|
|
145
|
+
}
|
|
122
146
|
}
|
|
123
147
|
|
|
124
148
|
const writeLogFileToCurrent = (data: object) => {
|
|
125
|
-
return writeFile('./wpsjs.
|
|
149
|
+
return writeFile('./return.wpsjs.json', JSON.stringify((data), undefined, 2))
|
|
126
150
|
}
|
|
127
151
|
|
|
128
152
|
export {
|
|
129
|
-
execution,
|
|
130
153
|
initRemoteCallWpsjsGlobal,
|
|
154
|
+
execution,
|
|
131
155
|
queryTask,
|
|
132
156
|
setValueOk,
|
|
157
|
+
setValue,
|
|
133
158
|
writeLogFileToCurrent,
|
|
134
159
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tadcode-wpsjs",
|
|
3
|
-
"version": "1.1
|
|
4
|
-
"main": "index.js",
|
|
3
|
+
"version": "1.2.1",
|
|
5
4
|
"type": "module",
|
|
6
5
|
"scripts": {
|
|
7
6
|
"hot": "NODE_ENV=development bun --hot ignore/index.ts",
|
|
8
7
|
"dev": "NODE_ENV=development bun --watch index.ts",
|
|
9
|
-
"build
|
|
10
|
-
"build
|
|
8
|
+
"build:main": "NODE_ENV=production bun build index.ts --target node --minify --outfile index.js",
|
|
9
|
+
"build:remotecode": "NODE_ENV=production bun build remoteCode/index.js --target browser --minify --outfile remoteCode/index.min.js"
|
|
11
10
|
},
|
|
12
11
|
"devDependencies": {
|
|
13
12
|
"@types/bun": "latest"
|
|
@@ -17,20 +16,8 @@
|
|
|
17
16
|
],
|
|
18
17
|
"exports": {
|
|
19
18
|
".": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
},
|
|
23
|
-
"./types": {
|
|
24
|
-
"types": "./types/index.d.ts"
|
|
25
|
-
},
|
|
26
|
-
"./types/DB_Application": {
|
|
27
|
-
"types": "./types/DB_Application.d.ts"
|
|
28
|
-
},
|
|
29
|
-
"./types/KSDrive": {
|
|
30
|
-
"types": "./types/KSDrive.d.ts"
|
|
31
|
-
},
|
|
32
|
-
"./types/KSheet_Application": {
|
|
33
|
-
"types": "./types/KSheet_Application.d.ts"
|
|
19
|
+
"types": "./types/index.d.ts",
|
|
20
|
+
"import": "./index.js"
|
|
34
21
|
}
|
|
35
22
|
}
|
|
36
23
|
}
|
package/remoteCode/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/* version 0.2 */
|
|
2
|
-
const { info } = Context.argv
|
|
3
|
-
let peviousTemp = undefined
|
|
4
|
-
let current = globalThis
|
|
5
|
-
for (const item of info) {
|
|
6
|
-
switch (item.method) {
|
|
7
|
-
case 'get': {
|
|
8
|
-
peviousTemp = current
|
|
9
|
-
const [k] = item.arguments
|
|
10
|
-
current = Reflect.get(current, k)
|
|
11
|
-
} break
|
|
12
|
-
case 'set': {
|
|
13
|
-
const [k, v] = item.arguments
|
|
14
|
-
current = Reflect.set(current, k, v)
|
|
15
|
-
} break
|
|
16
|
-
case 'apply': {
|
|
17
|
-
current = Reflect.apply(current, peviousTemp, item.arguments)
|
|
18
|
-
} break
|
|
19
|
-
default:
|
|
20
|
-
throw Error('method must be get or apply')
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return current
|
|
1
|
+
/* version 0.2.1 */
|
|
2
|
+
const { info } = Context.argv
|
|
3
|
+
let peviousTemp = undefined
|
|
4
|
+
let current = globalThis
|
|
5
|
+
for (const item of info) {
|
|
6
|
+
switch (item.method) {
|
|
7
|
+
case 'get': {
|
|
8
|
+
peviousTemp = current
|
|
9
|
+
const [k] = item.arguments
|
|
10
|
+
current = Reflect.get(current, k)
|
|
11
|
+
} break
|
|
12
|
+
case 'set': {
|
|
13
|
+
const [k, v] = item.arguments
|
|
14
|
+
current = Reflect.set(current, k, v)
|
|
15
|
+
} break
|
|
16
|
+
case 'apply': {
|
|
17
|
+
current = Reflect.apply(current, peviousTemp, item.arguments)
|
|
18
|
+
} break
|
|
19
|
+
default:
|
|
20
|
+
throw Error('The method must be get, set, or apply')
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return current
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"logs": [
|
|
4
|
+
{
|
|
5
|
+
"filename": "<system>",
|
|
6
|
+
"timestamp": "04:19:17.543",
|
|
7
|
+
"unix_time": 1772396357543,
|
|
8
|
+
"level": "info",
|
|
9
|
+
"args": [
|
|
10
|
+
"脚本环境(1.0)初始化..."
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"filename": "<system>",
|
|
15
|
+
"timestamp": "04:19:18.519",
|
|
16
|
+
"unix_time": 1772396358519,
|
|
17
|
+
"level": "info",
|
|
18
|
+
"args": [
|
|
19
|
+
"已开始执行"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"filename": "未命名脚本文件.js:9:15",
|
|
24
|
+
"timestamp": "04:19:18.537",
|
|
25
|
+
"unix_time": 1772396358537,
|
|
26
|
+
"level": "info",
|
|
27
|
+
"args": [
|
|
28
|
+
"[\"Application\"]"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"filename": "未命名脚本文件.js:9:15",
|
|
33
|
+
"timestamp": "04:19:18.537",
|
|
34
|
+
"unix_time": 1772396358537,
|
|
35
|
+
"level": "info",
|
|
36
|
+
"args": [
|
|
37
|
+
"[\"ActiveView\"]"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"filename": "未命名脚本文件.js:9:15",
|
|
42
|
+
"timestamp": "04:19:18.539",
|
|
43
|
+
"unix_time": 1772396358539,
|
|
44
|
+
"level": "info",
|
|
45
|
+
"args": [
|
|
46
|
+
"[\"Records\"]"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"filename": "未命名脚本文件.js:9:15",
|
|
51
|
+
"timestamp": "04:19:18.542",
|
|
52
|
+
"unix_time": 1772396358542,
|
|
53
|
+
"level": "info",
|
|
54
|
+
"args": [
|
|
55
|
+
"[\"Select\"]"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"result": null
|
|
60
|
+
},
|
|
61
|
+
"error": "Cannot read properties of undefined (reading 'getRecordViewRow')",
|
|
62
|
+
"error_details": {
|
|
63
|
+
"name": "TypeError",
|
|
64
|
+
"msg": "Cannot read properties of undefined (reading 'getRecordViewRow')",
|
|
65
|
+
"stack": [
|
|
66
|
+
"",
|
|
67
|
+
" at 未命名脚本文件.js:18:31"
|
|
68
|
+
],
|
|
69
|
+
"unix_time": 1772396358544
|
|
70
|
+
},
|
|
71
|
+
"status": "finished"
|
|
72
|
+
}
|
package/types/KSDrive.d.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
}
|
|
1
|
+
declare module 'tadcode-wpsjs:global' {
|
|
2
|
+
import type DBApplication from 'application:datatable'
|
|
3
|
+
interface FileType {
|
|
4
|
+
/**智能文档 */
|
|
5
|
+
AP: 'o'
|
|
6
|
+
/**智能表格 */
|
|
7
|
+
KSheet: 'k'
|
|
8
|
+
/**表格 */
|
|
9
|
+
ET: 's'
|
|
10
|
+
/**多维表 */
|
|
11
|
+
DB: 'd'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 文件类型
|
|
16
|
+
* - 'o': 智能文档
|
|
17
|
+
* - 'k': 智能表格
|
|
18
|
+
* - 's': 表格
|
|
19
|
+
* - 'd': 多维表
|
|
20
|
+
*/
|
|
21
|
+
type FileTypeValue = FileType[keyof FileType]
|
|
22
|
+
|
|
23
|
+
interface CreateOptions {
|
|
24
|
+
/**是 新文件的文件名 */
|
|
25
|
+
name: string
|
|
26
|
+
/**否 新文件的文件目录 */
|
|
27
|
+
dirUrl?: string
|
|
28
|
+
/**否 将目标文件另存为新文件 */
|
|
29
|
+
source?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface FilesInfo {
|
|
33
|
+
files: FileInfo[]
|
|
34
|
+
nextOffset: number
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface FileInfo {
|
|
38
|
+
/** 文件名 */
|
|
39
|
+
fileName: string
|
|
40
|
+
/** 加密后的文件 id */
|
|
41
|
+
fileId: string
|
|
42
|
+
/** 文件创建时间戳 */
|
|
43
|
+
createTime: number
|
|
44
|
+
/** 文件修改时间戳 */
|
|
45
|
+
updateTime: number
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface KSDrive {
|
|
49
|
+
FileType: FileType
|
|
50
|
+
/**
|
|
51
|
+
* 创建文件
|
|
52
|
+
* @param type 新文件的类型
|
|
53
|
+
* @param createOptions 新文件的参数选项
|
|
54
|
+
* @returns 新文件url
|
|
55
|
+
*/
|
|
56
|
+
createFile(type: FileTypeValue, createOptions: CreateOptions): string
|
|
57
|
+
|
|
58
|
+
openFile(url: string): {
|
|
59
|
+
Application: DB_Application
|
|
60
|
+
close()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
listFiles(options?: {
|
|
64
|
+
dirUrl?: string
|
|
65
|
+
offset?: number
|
|
66
|
+
count?: number
|
|
67
|
+
includeExts?: string[]
|
|
68
|
+
}): FilesInfo
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type { KSDrive, FileTypeValue }
|
|
72
|
+
}
|