tadcode-wpsjs 0.1.3 → 0.3.2
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 +29 -5
- package/index.js +1 -2
- package/index.ts +110 -87
- package/package.json +27 -15
- package/remoteCode/index.js +17 -12
- package/tsconfig.json +25 -25
- package/types/DB_Application.d.ts +17 -220
- package/types/DB_Application_Field.d.ts +212 -0
- package/types/DB_Application_Record.d.ts +178 -0
- package/types/DB_Application_Selection.ts +22 -0
- package/types/DB_Application_Sheet.d.ts +63 -0
- package/types/DB_Application_View.d.ts +24 -0
- package/types/KSDrive.d.ts +51 -44
- package/types/KSheet_Application.d.ts +25 -21
- package/types/index.d.ts +34 -73
- package/types/type-tools.ts +28 -8
- package/.editorconfig +0 -16
- package/.vscode/launch.json +0 -44
- package/.vscode/settings.json +0 -26
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# tadcode-wpsjs
|
|
2
2
|
|
|
3
|
-
基于wps官方文档
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
## 基于wps官方文档
|
|
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)
|
|
6
8
|
|
|
7
9
|
## 联系我
|
|
8
10
|
|
|
@@ -14,7 +16,7 @@
|
|
|
14
16
|
|
|
15
17
|
## 应用
|
|
16
18
|
|
|
17
|
-
用于学习
|
|
19
|
+
用于学习wpsjs-api,远程调用wpsjs-api。
|
|
18
20
|
|
|
19
21
|
使用wpsjs-api。支持异步任务。
|
|
20
22
|
|
|
@@ -53,6 +55,28 @@ const data = await wpsjsGlobal.Application.Sheet.GetSheets().execution()
|
|
|
53
55
|
console.log(data)
|
|
54
56
|
```
|
|
55
57
|
|
|
58
|
+
### 对于智能表格执行赋值操作
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { initRemoteCallWpsjsGlobal } from 'tadcode-wpsjs'
|
|
62
|
+
/* 脚本令牌 具体获取方式参考上面 */
|
|
63
|
+
const scriptToken = 'xxxx'
|
|
64
|
+
/* webhook url地址 具体获取方式参考上面 */
|
|
65
|
+
const webhookURL = 'xxxx'
|
|
66
|
+
const wpsjsGlobal = initRemoteCallWpsjsGlobal({ scriptToken, webhookURL, })
|
|
67
|
+
const values = [
|
|
68
|
+
['name', 'price'],
|
|
69
|
+
['米', 2.5],
|
|
70
|
+
]
|
|
71
|
+
function setValue(data: any[][], rangeReference = 'a1') {
|
|
72
|
+
const rowCount = data.length
|
|
73
|
+
const columnCount = data[0].length
|
|
74
|
+
wpsjsGlobal.Application.ActiveSheet.Range(rangeReference).Resize(rowCount, columnCount).Value2 = data
|
|
75
|
+
return wpsjsGlobal.execution() as unknown as boolean
|
|
76
|
+
}
|
|
77
|
+
setValue(values)
|
|
78
|
+
```
|
|
79
|
+
|
|
56
80
|
### 执行脚本并且返回(不用部署remoteCode代码)
|
|
57
81
|
|
|
58
82
|
```ts
|
|
@@ -68,4 +92,4 @@ console.log(data)
|
|
|
68
92
|
|
|
69
93
|
## 支持
|
|
70
94
|
|
|
71
|
-
|
|
95
|
+
如果对你有用请在[gitcode](https://gitcode.com/caisijian/tadcode-wpsjs)给个`star`
|
package/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import{writeFile as $}from"fs/promises";import Y from"path";var O=(B)=>{let{scriptToken:E,webhookURL:M,isAsync:H=!1,printLog:N=!1,writeLogFile:J=!1}=B,z=[];return new Proxy(()=>{},{get:(K,S,V)=>{return z.push({method:"get",arguments:[S]}),V},apply:(K,S,V)=>{if(z.at(-1)?.arguments[0]==="execution")return z.pop(),q({scriptToken:E,webhookURL:M,isAsync:H,argv:{info:z}}).then(async(Z)=>{let X=await Z.json();if(z=[],N)G(X);if(J)W(X);return X.data.result});return z.push({method:"apply",arguments:V}),S}})},q=({scriptToken:B,webhookURL:E,isAsync:M,argv:H})=>{let N=JSON.stringify({Context:{argv:H}}),J=Y.parse(E);J.base=M?"task":"sync_task";let z=Y.format(J);return fetch(z,{method:"post",headers:{"Content-Type":"application/json","AirScript-Token":B},body:N})},U=(B)=>{let E=new URL("https://www.kdocs.cn/api/v3/script/task");return E.searchParams.append("task_id",B),fetch(E)},G=(B)=>{let E=B,{status:M,data:H,error:N,error_details:J}=E;console.log("status:",M);let z=H.logs.at(-1).unix_time-H.logs[1].unix_time;if(console.log("runtime:",z),N)console.error(J.name),console.error(J.msg),console.error(J.stack);let Q=H.logs.filter((K)=>K.filename!=="<system>");if(Q.length!==0){console.log("log:");for(let K of Q)console[K.level](...K.args)}return console.log("result:"),console.log(H.result),E},W=(B)=>{$("./wpsjs.log.json",JSON.stringify(B,void 0,4))};export{W as writeLogFileToCurrent,U as queryTask,O as initRemoteCallWpsjsGlobal,q as execution};
|
|
1
|
+
import{writeFile as G}from"fs/promises";import $ from"path";var O=(B)=>{let{scriptToken:E,webhookURL:M,isAsync:H=!1,printLog:N=!1,writeLogFile:J=!1}=B,z=[];return new Proxy(()=>{},{get:(K,Q,S)=>{return z.push({method:"get",arguments:[Q]}),S},set:(K,Q,S,Z)=>{return z.push({method:"set",arguments:[Q,S]}),Z},apply:(K,Q,S)=>{if(z.at(-1)?.arguments[0]==="execution")return z.pop(),W({scriptToken:E,webhookURL:M,isAsync:H,argv:{info:z}}).then(async(q)=>{let Y=await q.json();if(z=[],N)D(Y);if(J)await P(Y);return Y.data.result});return z.push({method:"apply",arguments:S}),Q}})},W=({scriptToken:B,webhookURL:E,isAsync:M,argv:H})=>{let N=JSON.stringify({Context:{argv:H}}),J=$.parse(E);J.base=M?"task":"sync_task";let z=$.format(J);return fetch(z,{method:"post",headers:{"Content-Type":"application/json","AirScript-Token":B},body:N})},U=(B)=>{let E=new URL("https://www.kdocs.cn/api/v3/script/task");return E.searchParams.append("task_id",B),fetch(E)},D=(B)=>{let E=B,{status:M,data:H,error:N,error_details:J}=E;console.log("status:",M);let z=H.logs.at(-1).unix_time-H.logs[1].unix_time;if(console.log("runtime:",z),N)console.error(J.name),console.error(J.msg),console.error(J.stack);let X=H.logs.filter((K)=>K.filename!=="<system>");if(X.length!==0){console.log("log:");for(let K of X)console[K.level](...K.args)}return console.log("result:"),console.log(H.result),E},P=(B)=>{return G("./wpsjs.log.json",JSON.stringify(B,void 0,2))};export{P as writeLogFileToCurrent,U as queryTask,O as initRemoteCallWpsjsGlobal,W as execution};
|
package/index.ts
CHANGED
|
@@ -1,87 +1,110 @@
|
|
|
1
|
-
import type { InfoItem, RemoteCallWpsjsGlobalReturn, WithExecutionWpsjsGlobal } from './types'
|
|
2
|
-
import { writeFile } from 'fs/promises'
|
|
3
|
-
import path from 'path'
|
|
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
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
1
|
+
import type { InfoItem, RemoteCallWpsjsGlobalReturn, WithExecutionWpsjsGlobal } from './types'
|
|
2
|
+
import { writeFile } from 'fs/promises'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
interface Config {
|
|
6
|
+
/**脚本令牌 */
|
|
7
|
+
scriptToken: string
|
|
8
|
+
/**脚本链接 */
|
|
9
|
+
webhookURL: string
|
|
10
|
+
/**异步任务 */
|
|
11
|
+
isAsync?: boolean
|
|
12
|
+
/**在控制台打印日志 */
|
|
13
|
+
printLog?: boolean
|
|
14
|
+
/**在当前路径下写入日志文件 */
|
|
15
|
+
writeLogFile?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const initRemoteCallWpsjsGlobal = (config: Config) => {
|
|
19
|
+
const { scriptToken, webhookURL, isAsync = false, printLog = false, writeLogFile = false, } = config
|
|
20
|
+
let info: InfoItem[] = []
|
|
21
|
+
const handle: ProxyHandler<() => void> = {
|
|
22
|
+
get: (_target, p: string, receiver) => {
|
|
23
|
+
info.push({ method: 'get', arguments: [p] })
|
|
24
|
+
return receiver
|
|
25
|
+
},
|
|
26
|
+
set: (_target, p: string, newValue, receiver) => {
|
|
27
|
+
info.push({ method: 'set', arguments: [p, newValue] })
|
|
28
|
+
return receiver
|
|
29
|
+
},
|
|
30
|
+
apply: (_target, thisArg, argArray) => {
|
|
31
|
+
const lastInfo = info.at(-1)
|
|
32
|
+
if (lastInfo?.arguments[0] === 'execution') {
|
|
33
|
+
info.pop() /* 删除 execution的调用信息 */
|
|
34
|
+
return execution({ scriptToken, webhookURL, isAsync, argv: { info } })
|
|
35
|
+
.then(async (response) => {
|
|
36
|
+
const responseObj = await response.json()
|
|
37
|
+
info = [] /* 执行结束,清空调用 */
|
|
38
|
+
if (printLog) printInfo(responseObj)
|
|
39
|
+
|
|
40
|
+
if (writeLogFile) await writeLogFileToCurrent(responseObj)
|
|
41
|
+
return responseObj['data']['result']
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
info.push({ method: 'apply', arguments: argArray })
|
|
45
|
+
return thisArg
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
return new Proxy(() => { }, handle) as unknown as WithExecutionWpsjsGlobal
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type ExecutionConfig = Pick<Config, 'scriptToken' | 'webhookURL' | 'isAsync'> & { argv?: Record<string | number, any> }
|
|
52
|
+
|
|
53
|
+
const execution = ({ scriptToken, webhookURL, isAsync, argv }: ExecutionConfig) => {
|
|
54
|
+
/* 获取请求信息 */
|
|
55
|
+
const data = JSON.stringify({ Context: { argv, } })
|
|
56
|
+
/* 根据是否同步返回不同的url */
|
|
57
|
+
const parsedPath = path.parse(webhookURL)
|
|
58
|
+
parsedPath.base = isAsync ? 'task' : 'sync_task'
|
|
59
|
+
const url = path.format(parsedPath)
|
|
60
|
+
return fetch(url, {
|
|
61
|
+
method: 'post',
|
|
62
|
+
headers: {
|
|
63
|
+
'Content-Type': 'application/json',
|
|
64
|
+
'AirScript-Token': scriptToken
|
|
65
|
+
},
|
|
66
|
+
body: data
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const queryTask = (id: string) => {
|
|
71
|
+
const url = new URL('https://www.kdocs.cn/api/v3/script/task')
|
|
72
|
+
url.searchParams.append('task_id', id)
|
|
73
|
+
return fetch(url)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const printInfo = (remoteCallResponse: RemoteCallWpsjsGlobalReturn) => {
|
|
77
|
+
const responseData = remoteCallResponse as RemoteCallWpsjsGlobalReturn
|
|
78
|
+
const { status, data, error, error_details } = responseData
|
|
79
|
+
console.log('status:', status)
|
|
80
|
+
const time = data.logs.at(-1)!.unix_time - data.logs[1].unix_time
|
|
81
|
+
console.log('runtime:', time)
|
|
82
|
+
if (error) {
|
|
83
|
+
console.error(error_details.name)
|
|
84
|
+
console.error(error_details.msg)
|
|
85
|
+
console.error(error_details.stack)
|
|
86
|
+
}
|
|
87
|
+
const userInfo = data.logs.filter(x => x.filename !== '<system>')
|
|
88
|
+
if (userInfo.length !== 0) {
|
|
89
|
+
console.log('log:')
|
|
90
|
+
for (const item of userInfo) {
|
|
91
|
+
console[item.level](...item.args)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
console.log('result:')
|
|
95
|
+
console.log(data.result)
|
|
96
|
+
return responseData
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const writeLogFileToCurrent = (data: object) => {
|
|
100
|
+
return writeFile('./wpsjs.log.json', JSON.stringify((data), undefined, 2))
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export type * from './types'
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
execution,
|
|
107
|
+
initRemoteCallWpsjsGlobal,
|
|
108
|
+
queryTask,
|
|
109
|
+
writeLogFileToCurrent,
|
|
110
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
"name": "tadcode-wpsjs",
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"hot": "NODE_ENV=development bun --hot ignore/index.ts",
|
|
8
|
+
"dev": "NODE_ENV=development bun --watch index.ts",
|
|
9
|
+
"build": "NODE_ENV=production bun build index.ts --target node --minify --outfile index.js"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/bun": "latest"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"tadcode-wpsjs"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./index.js",
|
|
20
|
+
"types": "./index.ts"
|
|
21
|
+
},
|
|
22
|
+
"./types": {
|
|
23
|
+
"types": "./types/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./types/DB_Application": {
|
|
26
|
+
"types": "./types/DB_Application.d.ts"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
17
29
|
}
|
package/remoteCode/index.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
/* version 0.
|
|
1
|
+
/* version 0.2 */
|
|
2
2
|
const { info } = Context.argv
|
|
3
3
|
let peviousTemp = undefined
|
|
4
4
|
let current = globalThis
|
|
5
5
|
for (const item of info) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
}
|
|
17
22
|
}
|
|
18
23
|
return current
|
package/tsconfig.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Enable latest features
|
|
4
|
+
"lib": [
|
|
5
|
+
"ESNext",
|
|
6
|
+
"DOM"
|
|
7
|
+
],
|
|
8
|
+
"target": "ESNext",
|
|
9
|
+
"module": "ESNext",
|
|
10
|
+
"moduleDetection": "force",
|
|
11
|
+
"jsx": "react-jsx",
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
// Bundler mode
|
|
14
|
+
"moduleResolution": "bundler",
|
|
15
|
+
"allowImportingTsExtensions": true,
|
|
16
|
+
"verbatimModuleSyntax": true,
|
|
17
|
+
"noEmit": true,
|
|
18
|
+
// Best practices
|
|
19
|
+
"strict": true,
|
|
20
|
+
"skipLibCheck": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
// Some stricter flags (disabled by default)
|
|
23
|
+
"noUnusedLocals": false,
|
|
24
|
+
"noUnusedParameters": false,
|
|
25
|
+
"noPropertyAccessFromIndexSignature": false
|
|
26
|
+
}
|
|
27
27
|
}
|
|
@@ -1,225 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
View: DBView
|
|
7
|
-
}
|
|
8
|
-
/* 表 */
|
|
9
|
-
interface DBSheet {
|
|
10
|
-
GetSheets(): SheetInfo[]
|
|
11
|
-
CreateSheet(options: Pick<SheetOptions, 'SheetId'>)
|
|
12
|
-
DeleteSheet(options: Pick<SheetOptions, 'SheetId'>)
|
|
13
|
-
UpdateSheet(options: Omit<SheetOptions, 'SheetId'> & Partial<SheetOptions>)
|
|
14
|
-
}
|
|
15
|
-
interface SheetOptions {
|
|
16
|
-
SheetId: number
|
|
17
|
-
Name: string
|
|
18
|
-
Views: {
|
|
19
|
-
name: string
|
|
20
|
-
/**
|
|
21
|
-
* 表格视图 看板视图 画册视图 表单视图 甘特视图
|
|
22
|
-
*/
|
|
23
|
-
type: ViewType
|
|
24
|
-
}[]
|
|
25
|
-
Fields: { name: string, type: FieldType }[]
|
|
26
|
-
}
|
|
27
|
-
interface SheetInfo {
|
|
28
|
-
'description': string,
|
|
29
|
-
'fields': {
|
|
30
|
-
'arraySupport': boolean,
|
|
31
|
-
'autoFillSourceField': string,
|
|
32
|
-
'customConfig': string,
|
|
33
|
-
'defaultValueType': 'Normal',
|
|
34
|
-
'description': string,
|
|
35
|
-
'id': string,
|
|
36
|
-
'name': string,
|
|
37
|
-
'numberFormat': string,
|
|
38
|
-
'syncField': boolean,
|
|
39
|
-
'type': FieldType,
|
|
40
|
-
'uniqueValue': boolean
|
|
41
|
-
'loadLegalHoliday': number,
|
|
42
|
-
'items': {
|
|
43
|
-
'color': number,
|
|
44
|
-
'id': string,
|
|
45
|
-
'value': string
|
|
46
|
-
}[],
|
|
47
|
-
'allowAddItemWhenInputting': true,
|
|
48
|
-
'autoAddItem': boolean,
|
|
49
|
-
}[],
|
|
50
|
-
'icon': string,
|
|
51
|
-
'id': number,
|
|
52
|
-
'name': number,
|
|
53
|
-
'primaryFieldId': number,
|
|
54
|
-
'recordsCount': number,
|
|
55
|
-
'sheetType': 'xlEtDataBaseSheet',
|
|
56
|
-
'subType': 'Normal',
|
|
57
|
-
'syncFieldSourceId': string,
|
|
58
|
-
'syncFieldSourceNameId': string,
|
|
59
|
-
'syncType': 'None',
|
|
60
|
-
'views': {
|
|
61
|
-
'id': string,
|
|
62
|
-
'name': string,
|
|
63
|
-
'notice': string,
|
|
64
|
-
'recordsCount': number,
|
|
65
|
-
'type': ViewType
|
|
66
|
-
}[]
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
type FieldType = 'MultiLineText' | 'Date' | 'Time' | 'Number' | 'Currency' | 'Percentage' | 'ID' | 'Phone' | 'Email' | 'Url' | 'Checkbox' | 'SingleSelect' | 'MultipleSelect' | 'Rating' | 'Complete' | 'Contact' | 'Attachment' | 'Link' | 'Note' | 'AutoNumber' | 'CreatedBy' | 'CreatedTime' | 'Formula' | 'Lookup'
|
|
70
|
-
type ViewType = 'Grid' | 'Kanban' | 'Gallery' | 'Form' | 'Gantt'
|
|
71
|
-
|
|
72
|
-
interface Entry {
|
|
73
|
-
id: string,
|
|
74
|
-
fields: Record<string, boolean | number | string | string[]>
|
|
75
|
-
}
|
|
76
|
-
interface Options {
|
|
77
|
-
SheetId: number
|
|
78
|
-
RecordId: string
|
|
79
|
-
RecordIds: string[]
|
|
80
|
-
Records: Entry[]
|
|
81
|
-
/**
|
|
82
|
-
* 填写后将从被指定的视图获取该用户所见到的记录;若不填写,则从工作表获取记录
|
|
83
|
-
*/
|
|
84
|
-
ViewId: string
|
|
85
|
-
/**
|
|
86
|
-
* 存在分页时,指定本次查询的起始记录(含)。若不填写或填写为空字符串,则从第一条记录开始获取
|
|
87
|
-
*
|
|
88
|
-
* 当前最大值:1000
|
|
89
|
-
*/
|
|
90
|
-
PageSize: number
|
|
91
|
-
/**分页查询时,将返回一个offset值,指向下一页的第一条记录,供后续查询。查询到最后一页或第maxRecords条记录时,返回数据将不再包含offset值 */
|
|
92
|
-
Offset: number
|
|
93
|
-
/**指定要获取的“前maxRecords条记录”,若不填写,则默认返回全部记录 */
|
|
94
|
-
MaxRecords: number
|
|
95
|
-
/**具体字段类型说明详见 [附件2](https://kdocs.cn/l/ctzsgDlAGF0l?linkname=QSt7dOHYA0) */
|
|
96
|
-
Fields: any[]
|
|
97
|
-
/**详细说明见 [附件4](https://www.kdocs.cn/l/ctzsgDlAGF0l?linkname=wsTfzS9o34) */
|
|
98
|
-
Filter: {
|
|
99
|
-
/**选填。表示各筛选条件之间的逻辑关系。只能是'AND'或'OR'。缺省值为'AND' */
|
|
100
|
-
mode?: 'AND' | 'OR',
|
|
101
|
-
/**filter结构体内必填。包含筛选条件的数组。每个字段上只能有一个筛选条件 */
|
|
102
|
-
criteria: {
|
|
103
|
-
/**必填。根据 preferId 与否,需要填入字段名或字段id */
|
|
104
|
-
field: string
|
|
105
|
-
/**"Equals": 等于
|
|
106
|
-
|
|
107
|
-
"NotEqu": 不等于
|
|
108
|
-
|
|
109
|
-
"Greater": 大于
|
|
110
|
-
|
|
111
|
-
"GreaterEqu": 大等于
|
|
112
|
-
|
|
113
|
-
"Less": 小于
|
|
114
|
-
|
|
115
|
-
"LessEqu": 小等于
|
|
1
|
+
import type DBSheet from './DB_Application_Sheet'
|
|
2
|
+
import type DBView from './DB_Application_View'
|
|
3
|
+
import type DBField from './DB_Application_Field'
|
|
4
|
+
import type DBRecord from './DB_Application_Record'
|
|
5
|
+
import type DBSelection from './DB_Application_Selection'
|
|
116
6
|
|
|
117
|
-
|
|
7
|
+
export type * from './DB_Application_Sheet'
|
|
8
|
+
export type * from './DB_Application_View'
|
|
9
|
+
export type * from './DB_Application_Field'
|
|
10
|
+
export type * from './DB_Application_Record'
|
|
11
|
+
export type * from './DB_Application_Selection'
|
|
118
12
|
|
|
119
|
-
|
|
13
|
+
export type { DBSheet, DBView, DBField, DBRecord, DBSelection }
|
|
120
14
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
"NotContains": 不包含
|
|
128
|
-
|
|
129
|
-
"Intersected": 指定值
|
|
130
|
-
|
|
131
|
-
"Empty": 为空
|
|
132
|
-
|
|
133
|
-
"NotEmpty": 不为空
|
|
134
|
-
*/
|
|
135
|
-
op: 'Equals' | 'NotEqu' | 'Greater' | 'GreaterEqu' | 'Less' | 'LessEqu' | 'GreaterEquAndLessEqu' | 'LessOrGreater' | 'BeginWith' | 'EndWith' | 'Contains' | 'NotContains' | 'Intersected' | 'Empty' | 'NotEmpty'
|
|
136
|
-
/**
|
|
137
|
-
* 必填。表示筛选规则中的值。数组形式。值为字符串时表示文本匹配。
|
|
138
|
-
* 这里的 values,必须是一个数组,传 ["多维表"],相当于传 [{ type: 'Text', value: '多维表' }],即不传默认帮你补充 Text 类型。
|
|
139
|
-
* 复选框的值,values: ['0'] 代表否,value: ['1'] 代表是。
|
|
140
|
-
*
|
|
141
|
-
* values[]数组内的元素为字符串时,表示文本匹配。各筛选规则独立地限制了values数组内最多允许填写的元素数,当values内元素数超过阈值时,该筛选规则将失效。
|
|
142
|
-
*
|
|
143
|
-
* a. “为空、不为空”不允许填写元素;
|
|
144
|
-
*
|
|
145
|
-
* b. “介于”允许最多填写2个元素;
|
|
146
|
-
*
|
|
147
|
-
* c. “指定值”允许填写65535个元素;
|
|
148
|
-
*
|
|
149
|
-
* d. 其他规则允许最多填写1个元素
|
|
150
|
-
*/
|
|
151
|
-
values: string[] | {
|
|
152
|
-
type: 'Text'
|
|
153
|
-
value: string
|
|
154
|
-
}[] |
|
|
155
|
-
{
|
|
156
|
-
type: 'DynamicSimple'
|
|
157
|
-
/**
|
|
158
|
-
* 当"op"为"greater"或"less"时,"dynamicType"只能是昨天、今天或明天。
|
|
159
|
-
*
|
|
160
|
-
* "today": 今天
|
|
161
|
-
*
|
|
162
|
-
* "yesterday": 昨天
|
|
163
|
-
*
|
|
164
|
-
* "tomorrow": 明天
|
|
165
|
-
*
|
|
166
|
-
* "last7Days": 最近7天
|
|
167
|
-
*
|
|
168
|
-
* "last30Days": 最近30天
|
|
169
|
-
*
|
|
170
|
-
* "thisWeek": 本周
|
|
171
|
-
*
|
|
172
|
-
* "lastWeek": 上周
|
|
173
|
-
*
|
|
174
|
-
* "nextWeek":下周
|
|
175
|
-
*
|
|
176
|
-
* "thisMonth": 本月
|
|
177
|
-
*
|
|
178
|
-
* "lastMonth": 上月
|
|
179
|
-
*
|
|
180
|
-
* "nextMonth": 次月
|
|
181
|
-
*/
|
|
182
|
-
dynamicType: "today" | "yesterday" | "tomorrow" | "last7Days" | "last30Days" | "thisWeek" | "lastWeek" | "nextWeek" | "thisMonth" | "lastMonth" | "nextMonth"
|
|
183
|
-
}[]
|
|
184
|
-
}[]
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/* 行记录 */
|
|
188
|
-
interface DBRecord {
|
|
189
|
-
GetRecord(options: Pick<Options, 'SheetId' | 'RecordId'>)
|
|
190
|
-
GetRecords(options: Pick<Options, 'SheetId'> & Partial<Pick<Options, 'ViewId' | 'PageSize' | 'Offset' | 'MaxRecords' | 'Fields' | 'Filter'>>): { records: Entry[] }
|
|
191
|
-
CreateRecords(options: Pick<Options, 'SheetId'> & PickModify<Options, 'Records', MakePropertyOptional<Entry, 'id'>[]>): Entry[]
|
|
192
|
-
UpdateRecords(options: Pick<Options, 'SheetId' | 'Records'>)
|
|
193
|
-
DeleteRecords(options: Pick<Options, 'SheetId' | 'RecordIds'>)
|
|
194
|
-
}
|
|
195
|
-
/* 字段 */
|
|
196
|
-
interface DBField {
|
|
197
|
-
GetFields(options: Pick<FieldOptions, 'SheetId'>)
|
|
198
|
-
CreateFields(options: Pick<FieldOptions, 'SheetId' | 'Fields'>)
|
|
199
|
-
DeleteFields(options: Pick<FieldOptions, 'SheetId' | 'FieldIds'>)
|
|
200
|
-
UpdateFields(options: Pick<FieldOptions, 'SheetId' | 'Fields'> & {})
|
|
201
|
-
}
|
|
202
|
-
interface FieldOptions {
|
|
203
|
-
SheetId: number
|
|
204
|
-
Fields: Partial<Field>[]
|
|
205
|
-
FieldIds: string[]
|
|
206
|
-
}
|
|
207
|
-
interface Field {
|
|
208
|
-
id: string,
|
|
209
|
-
name: string,
|
|
210
|
-
type: FieldType
|
|
15
|
+
export default interface DB_Application {
|
|
16
|
+
Sheet: DBSheet
|
|
17
|
+
View: DBView
|
|
18
|
+
Field: DBField
|
|
19
|
+
Record: DBRecord
|
|
20
|
+
Selection: DBSelection
|
|
211
21
|
}
|
|
212
22
|
|
|
213
|
-
/* 视图 */
|
|
214
|
-
interface DBView {
|
|
215
|
-
GetViews(options: Pick<ViewOptions, 'SheetId'>)
|
|
216
|
-
CreateView(options: Pick<ViewOptions, 'SheetId' | 'Name' | 'ViewType'>)
|
|
217
|
-
DeleteView(options: Pick<ViewOptions, 'SheetId' | 'ViewId'>)
|
|
218
|
-
UpdateView(options: Pick<ViewOptions, 'SheetId' | 'Name' | 'ViewId'>)
|
|
219
|
-
}
|
|
220
|
-
interface ViewOptions {
|
|
221
|
-
SheetId: number
|
|
222
|
-
ViewId: string
|
|
223
|
-
Name: string
|
|
224
|
-
ViewType: ViewType
|
|
225
|
-
}
|