tadcode-wpsjs 0.1.2 → 0.3.0
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 +58 -15
- package/index.js +1 -2
- package/index.ts +105 -80
- package/package.json +15 -15
- package/remoteCode/index.js +17 -13
- 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
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { FieldTypeKeys, } from './DB_Application_Field'
|
|
2
|
+
import type { ViewType } from './DB_Application_View'
|
|
3
|
+
|
|
4
|
+
interface Sheet {
|
|
5
|
+
'description': string,
|
|
6
|
+
'fields': {
|
|
7
|
+
'arraySupport': boolean,
|
|
8
|
+
'autoFillSourceField': string,
|
|
9
|
+
'customConfig': string,
|
|
10
|
+
'defaultValueType': 'Normal',
|
|
11
|
+
'description': string,
|
|
12
|
+
'id': string,
|
|
13
|
+
'name': string,
|
|
14
|
+
'numberFormat': string,
|
|
15
|
+
'syncField': boolean,
|
|
16
|
+
'type': FieldTypeKeys,
|
|
17
|
+
'uniqueValue': boolean
|
|
18
|
+
'loadLegalHoliday': number,
|
|
19
|
+
'items': {
|
|
20
|
+
'color': number,
|
|
21
|
+
'id': string,
|
|
22
|
+
'value': string
|
|
23
|
+
}[],
|
|
24
|
+
'allowAddItemWhenInputting': true,
|
|
25
|
+
'autoAddItem': boolean,
|
|
26
|
+
}[],
|
|
27
|
+
'icon': string,
|
|
28
|
+
'id': number,
|
|
29
|
+
'name': number,
|
|
30
|
+
'primaryFieldId': number,
|
|
31
|
+
'recordsCount': number,
|
|
32
|
+
'sheetType': 'xlEtDataBaseSheet',
|
|
33
|
+
'subType': 'Normal',
|
|
34
|
+
'syncFieldSourceId': string,
|
|
35
|
+
'syncFieldSourceNameId': string,
|
|
36
|
+
'syncType': 'None',
|
|
37
|
+
'views': {
|
|
38
|
+
'id': string,
|
|
39
|
+
'name': string,
|
|
40
|
+
'notice': string,
|
|
41
|
+
'recordsCount': number,
|
|
42
|
+
'type': ViewType
|
|
43
|
+
}[]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface SheetFuncOptions {
|
|
47
|
+
SheetId: number
|
|
48
|
+
Name: string
|
|
49
|
+
Views: {
|
|
50
|
+
name: string
|
|
51
|
+
type: ViewType
|
|
52
|
+
}[]
|
|
53
|
+
Fields: { name: string, type: FieldTypeKeys }[]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type { Sheet, SheetFuncOptions }
|
|
57
|
+
|
|
58
|
+
export default interface DBSheet {
|
|
59
|
+
CreateSheet(options: Omit<SheetFuncOptions, 'SheetId'>): Sheet
|
|
60
|
+
GetSheets(): Sheet[]
|
|
61
|
+
UpdateSheet(options: Pick<SheetFuncOptions, 'SheetId' | 'Name'>): boolean
|
|
62
|
+
DeleteSheet(options: Pick<SheetFuncOptions, 'SheetId'>): Pick<Sheet, 'id'>
|
|
63
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type ViewType = 'Grid' | 'Kanban' | 'Gallery' | 'Form' | 'Gantt'
|
|
2
|
+
|
|
3
|
+
interface View {
|
|
4
|
+
"id": string
|
|
5
|
+
"name": string
|
|
6
|
+
"recordsCount": number
|
|
7
|
+
"type": ViewType
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ViewFuncOptions {
|
|
11
|
+
SheetId: number
|
|
12
|
+
ViewId: string
|
|
13
|
+
Name: string
|
|
14
|
+
ViewType: ViewType
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { View, ViewType, ViewFuncOptions }
|
|
18
|
+
|
|
19
|
+
export default interface DBView {
|
|
20
|
+
CreateView(options: Pick<ViewFuncOptions, 'SheetId' | 'Name' | 'ViewType'>): View
|
|
21
|
+
GetViews(options: Pick<ViewFuncOptions, 'SheetId'>): View[]
|
|
22
|
+
UpdateView(options: Pick<ViewFuncOptions, 'SheetId' | 'Name' | 'ViewId'>): View
|
|
23
|
+
DeleteView(options: Pick<ViewFuncOptions, 'SheetId' | 'ViewId'>): Pick<View, 'id'>
|
|
24
|
+
}
|
package/types/KSDrive.d.ts
CHANGED
|
@@ -1,53 +1,60 @@
|
|
|
1
1
|
import type DB_Application from './DB_Application'
|
|
2
2
|
import type KSheet_Application from './KSheet_Application'
|
|
3
|
-
export default interface KSDrive {
|
|
4
|
-
FileType: {
|
|
5
|
-
/**智能文档 */
|
|
6
|
-
AP: string
|
|
7
|
-
/**智能表格 */
|
|
8
|
-
KSheet: string
|
|
9
|
-
/**表格 */
|
|
10
|
-
ET: string
|
|
11
|
-
/**多维表 */
|
|
12
|
-
DB: string
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* 创建文件
|
|
16
|
-
* @param type 新文件的类型
|
|
17
|
-
* @param createOptions 新文件的参数选项
|
|
18
3
|
|
|
19
|
-
*/
|
|
20
|
-
createFile(type: string, createOptions: createOptions)
|
|
21
|
-
openFile(url: string): {
|
|
22
|
-
Application: KSheet_Application & DB_Application
|
|
23
|
-
close()
|
|
24
|
-
}
|
|
25
|
-
listFiles(options?: {
|
|
26
|
-
dirUrl: string
|
|
27
|
-
offset: number
|
|
28
|
-
count: number
|
|
29
|
-
includeExts: string[]
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
4
|
interface CreateOptions {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
5
|
+
/**是 新文件的文件名 */
|
|
6
|
+
name: string
|
|
7
|
+
/**否 新文件的文件目录 */
|
|
8
|
+
dirUrl: string
|
|
9
|
+
/**否 将目标文件另存为新文件 */
|
|
10
|
+
source: string
|
|
39
11
|
}
|
|
12
|
+
|
|
40
13
|
interface FilesInfo {
|
|
41
|
-
|
|
42
|
-
|
|
14
|
+
files: FileInfo[]
|
|
15
|
+
nextOffset: number
|
|
43
16
|
}
|
|
17
|
+
|
|
44
18
|
interface FileInfo {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
19
|
+
/** 文件名 */
|
|
20
|
+
fileName: string
|
|
21
|
+
/** 加密后的文件 id */
|
|
22
|
+
fileId: string
|
|
23
|
+
/** 文件创建时间戳 */
|
|
24
|
+
createTime: number
|
|
25
|
+
/** 文件修改时间戳 */
|
|
26
|
+
updateTime: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default interface KSDrive {
|
|
30
|
+
FileType: {
|
|
31
|
+
/**智能文档 */
|
|
32
|
+
AP: 'o'
|
|
33
|
+
/**智能表格 */
|
|
34
|
+
KSheet: 'k'
|
|
35
|
+
/**表格 */
|
|
36
|
+
ET: 's'
|
|
37
|
+
/**多维表 */
|
|
38
|
+
DB: 'd'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 创建文件
|
|
43
|
+
* @param type 新文件的类型
|
|
44
|
+
* @param createOptions 新文件的参数选项
|
|
45
|
+
* @returns {string} 新文件url
|
|
46
|
+
*/
|
|
47
|
+
createFile(type: string, createOptions: createOptions): string
|
|
48
|
+
|
|
49
|
+
openFile(url: string): {
|
|
50
|
+
Application: KSheet_Application & DB_Application
|
|
51
|
+
close()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
listFiles(options?: {
|
|
55
|
+
dirUrl: string
|
|
56
|
+
offset: number
|
|
57
|
+
count: number
|
|
58
|
+
includeExts: string[]
|
|
59
|
+
})
|
|
53
60
|
}
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Range(index: string): {
|
|
6
|
-
Value: any
|
|
7
|
-
}
|
|
1
|
+
interface Range {
|
|
2
|
+
Value2: any
|
|
3
|
+
Formula: any
|
|
4
|
+
Resize(RowSize: number, ColumnSize?: number): Range
|
|
8
5
|
}
|
|
6
|
+
|
|
9
7
|
interface Sheet {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
UsedRange: Range
|
|
9
|
+
/**
|
|
10
|
+
* 获取一个单元格或单元格区域,返回一个 Range 对象
|
|
11
|
+
* @paramaddress — 地址,可以是单元格地址或者选区范围范围地址
|
|
12
|
+
* @returns — 工作表里的一个单元格或单元格区域
|
|
13
|
+
* @example — 参考示例
|
|
14
|
+
* const sheet = Application.ActiveSheet
|
|
15
|
+
* // 打印当前活动工作表D2单元格的内容
|
|
16
|
+
* console.log(sheet.Range('D2').Text) // D2
|
|
17
|
+
* // 修改当前活动工作表D2单元格的内容
|
|
18
|
+
* sheet.Range('D2').Value = 'this is D2'
|
|
19
|
+
*/
|
|
20
|
+
Range(address: string): Range
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
|
|
23
|
+
export default interface KSheet_Application {
|
|
24
|
+
ActiveSheet: Sheet
|
|
25
|
+
Sheets: {
|
|
26
|
+
Item(index: number | string): Sheet
|
|
27
|
+
}
|
|
28
|
+
Range(index: string): Range
|
|
25
29
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -2,85 +2,46 @@ import type { WithExecution } from './type-tools'
|
|
|
2
2
|
import type DB_Application from './DB_Application'
|
|
3
3
|
import type KSheet_Application from './KSheet_Application'
|
|
4
4
|
import type KSDrive from './KSDrive'
|
|
5
|
+
|
|
5
6
|
interface WpsjsGlobal {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Application: KSheet_Application & DB_Application
|
|
7
|
+
KSDrive: KSDrive
|
|
8
|
+
Application: KSheet_Application & DB_Application
|
|
9
9
|
}
|
|
10
|
+
|
|
10
11
|
type WithExecutionWpsjsGlobal = WithExecution<WpsjsGlobal>
|
|
12
|
+
|
|
11
13
|
interface InfoItem {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
method: keyof typeof Reflect
|
|
15
|
+
arguments: string[]
|
|
14
16
|
}
|
|
17
|
+
|
|
15
18
|
interface RemoteCallWpsjsGlobalReturn {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"filename": "xxxx.js:row:column",
|
|
38
|
-
"timestamp": string,
|
|
39
|
-
"unix_time": number,
|
|
40
|
-
"level": "error",
|
|
41
|
-
"args": []
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"filename": "xxxx.js:row:column",
|
|
45
|
-
"timestamp": string,
|
|
46
|
-
"unix_time": number,
|
|
47
|
-
"level": "warn",
|
|
48
|
-
"args": []
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"filename": "xxxx.js:row:column",
|
|
52
|
-
"timestamp": string,
|
|
53
|
-
"unix_time": number,
|
|
54
|
-
"level": "info",
|
|
55
|
-
"args": []
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"filename": "<system>",
|
|
59
|
-
"timestamp": string,
|
|
60
|
-
"unix_time": number,
|
|
61
|
-
"level": "info",
|
|
62
|
-
"args": [
|
|
63
|
-
"执行完毕"
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
"result": unknown,
|
|
68
|
-
"task_id": string,
|
|
69
|
-
},
|
|
70
|
-
"error": string,
|
|
71
|
-
"error_details": {
|
|
72
|
-
"name": string,
|
|
73
|
-
"msg": string,
|
|
74
|
-
"stack": string[],
|
|
75
|
-
"unix_time": number,
|
|
76
|
-
},
|
|
77
|
-
"status": "finished",
|
|
78
|
-
"task_id": "GN/KU3B3BG84MdCjraN5mukx0Rt5Sp1eJ9k2qClmcaOkkF3PUVNDOYPY7Kz4aQMXSvXn9N08QabldRKjPfzii87fuGYydIuK2la2HMfcxmGK1Pf4WcPEflb5xOOkQQEo8fmEbzcobhurYg==",
|
|
79
|
-
"task_type": "open_air_script",
|
|
19
|
+
"data": {
|
|
20
|
+
"logs": {
|
|
21
|
+
"filename": string
|
|
22
|
+
"timestamp": string
|
|
23
|
+
"unix_time": number
|
|
24
|
+
"level": 'info' | 'error' | 'warn'
|
|
25
|
+
"args": string[]
|
|
26
|
+
}[]
|
|
27
|
+
"result": unknown
|
|
28
|
+
"task_id": string
|
|
29
|
+
}
|
|
30
|
+
"error": string
|
|
31
|
+
"error_details": {
|
|
32
|
+
"name": string
|
|
33
|
+
"msg": string
|
|
34
|
+
"stack": string[]
|
|
35
|
+
"unix_time": number
|
|
36
|
+
}
|
|
37
|
+
"status": "finished"
|
|
38
|
+
"task_id": string
|
|
39
|
+
"task_type": string
|
|
80
40
|
}
|
|
41
|
+
|
|
81
42
|
export {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
43
|
+
WpsjsGlobal,
|
|
44
|
+
WithExecutionWpsjsGlobal,
|
|
45
|
+
InfoItem,
|
|
46
|
+
RemoteCallWpsjsGlobalReturn,
|
|
86
47
|
}
|
package/types/type-tools.ts
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
/**根据给的对象,添加execution方法 */
|
|
2
2
|
type WithExecution<T> = T extends (...args: infer A) => infer R
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
? ((...args: A) => WithExecution<R>) & { execution: () => Promise<R> }
|
|
4
|
+
: T extends object
|
|
5
|
+
? { [K in keyof T]: WithExecution<T[K]> } & { execution: () => Promise<T> }
|
|
6
|
+
: T & { execution: () => Promise<T> }
|
|
7
|
+
|
|
7
8
|
/**部分可选 */
|
|
8
9
|
type MakePropertyOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
/**选取修改类型 */
|
|
10
12
|
type PickModify<T, K extends keyof T, M> = {
|
|
11
|
-
|
|
13
|
+
[P in K]: M
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 深度可选工具类型
|
|
18
|
+
*/
|
|
19
|
+
type DeepPartial<T> = T extends object
|
|
20
|
+
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
21
|
+
: T
|
|
22
|
+
|
|
23
|
+
/**去掉联合类型对象中的id */
|
|
24
|
+
type DistributiveOmit<T, K extends PropertyKey> =
|
|
25
|
+
T extends any ? Omit<T, K> : never
|
|
26
|
+
|
|
27
|
+
export type {
|
|
28
|
+
WithExecution,
|
|
29
|
+
MakePropertyOptional,
|
|
30
|
+
PickModify,
|
|
31
|
+
DeepPartial,
|
|
32
|
+
DistributiveOmit,
|
|
12
33
|
}
|
|
13
|
-
export type { WithExecution, MakePropertyOptional, PickModify }
|
package/.editorconfig
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# EditorConfig is awesome: https://editorconfig.org
|
|
2
|
-
|
|
3
|
-
# top-most EditorConfig file
|
|
4
|
-
root = true
|
|
5
|
-
|
|
6
|
-
[*]
|
|
7
|
-
end_of_line = lf
|
|
8
|
-
insert_final_newline = true
|
|
9
|
-
charset = utf-8
|
|
10
|
-
indent_style = tab
|
|
11
|
-
tab_width = 2
|
|
12
|
-
trim_trailing_whitespace = true
|
|
13
|
-
|
|
14
|
-
[*.md]
|
|
15
|
-
indent_style = tab
|
|
16
|
-
trim_trailing_whitespace = false
|
package/.vscode/launch.json
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.2.0",
|
|
3
|
-
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
/* 需要插件Bun for Visual Studio Code id:oven.bun-vscode */
|
|
6
|
-
"type": "bun",
|
|
7
|
-
"request": "launch",
|
|
8
|
-
"name": "Debug Bun",
|
|
9
|
-
// The path to a JavaScript or TypeScript file to run.
|
|
10
|
-
"program": "${file}",
|
|
11
|
-
// The arguments to pass to the program, if any.
|
|
12
|
-
"args": [],
|
|
13
|
-
// The working directory of the program.
|
|
14
|
-
"cwd": "${workspaceFolder}",
|
|
15
|
-
// The environment variables to pass to the program.
|
|
16
|
-
"env": {},
|
|
17
|
-
// If the environment variables should not be inherited from the parent process.
|
|
18
|
-
"strictEnv": false,
|
|
19
|
-
// If the program should be run in watch mode.
|
|
20
|
-
// This is equivalent to passing `--watch` to the `bun` executable.
|
|
21
|
-
// You can also set this to "hot" to enable hot reloading using `--hot`.
|
|
22
|
-
"watchMode": true,
|
|
23
|
-
// If the debugger should stop on the first line of the program.
|
|
24
|
-
"stopOnEntry": false,
|
|
25
|
-
// If the debugger should be disabled. (for example, breakpoints will not be hit)
|
|
26
|
-
"noDebug": false,
|
|
27
|
-
// The path to the `bun` executable, defaults to your `PATH` environment variable.
|
|
28
|
-
"runtime": "bun",
|
|
29
|
-
// The arguments to pass to the `bun` executable, if any.
|
|
30
|
-
// Unlike `args`, these are passed to the executable itself, not the program.
|
|
31
|
-
"runtimeArgs": [
|
|
32
|
-
// "--hot"
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"type": "bun",
|
|
37
|
-
"request": "attach",
|
|
38
|
-
"name": "Attach to Bun",
|
|
39
|
-
// The URL of the WebSocket inspector to attach to.
|
|
40
|
-
// This value can be retrieved by using `bun --inspect`.
|
|
41
|
-
"url": "ws://localhost:6499/",
|
|
42
|
-
},
|
|
43
|
-
]
|
|
44
|
-
}
|
package/.vscode/settings.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files.autoSave": "off",
|
|
3
|
-
// The path to the `bun` executable.
|
|
4
|
-
// "bun.runtime": "/path/to/bun",
|
|
5
|
-
// If support for Bun should be added to the default "JavaScript Debug Terminal".
|
|
6
|
-
"bun.debugTerminal.enabled": true,
|
|
7
|
-
// If the debugger should stop on the first line of the program.
|
|
8
|
-
"bun.debugTerminal.stopOnEntry": false,
|
|
9
|
-
// Glob pattern to find test files. Defaults to the value shown below.
|
|
10
|
-
"bun.test.filePattern": "**/*{.test.,.spec.,_test_,_spec_}{js,ts,tsx,jsx,mts,cts}",
|
|
11
|
-
"search.exclude": {
|
|
12
|
-
"**/node_modules": true,
|
|
13
|
-
"**/bower_components": true,
|
|
14
|
-
"**/*.code-search": true
|
|
15
|
-
},
|
|
16
|
-
"files.exclude": {
|
|
17
|
-
"**/node_modules": true,
|
|
18
|
-
"**/.git": true,
|
|
19
|
-
"**/.svn": true,
|
|
20
|
-
"**/.hg": true,
|
|
21
|
-
"**/CVS": true,
|
|
22
|
-
"**/.DS_Store": true,
|
|
23
|
-
"**/Thumbs.db": true,
|
|
24
|
-
"bun.lock": true,
|
|
25
|
-
}
|
|
26
|
-
}
|