tadcode-wpsjs 1.4.0 → 1.5.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 CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  项目地址:[https://gitcode.com/caisijian/tadcode-wpsjs](https://gitcode.com/caisijian/tadcode-wpsjs)
6
6
 
7
- 在部署远程代码的情况下,可以远程调用`WpsjsGlobal`,实现对支持`AirScript`的多维表,智能表格等远程操作。如果你对`AirScript`,感兴趣,也能帮助你学习`WpsjsGlobal`。
7
+ 在部署远程代码的情况下,可以远程调用`WpsjsGlobal`,实现对支持`AirScript`的多维表,智能表格等远程操作。如果你对`AirScript`,感兴趣,也能帮助你学习`AirScript`。
8
8
 
9
- In the case of deploying remote code, WpsjsGlobal can be remotely called to achieve remote operations on multidimensional tables, smart tables, and other tables that support AirScript. If you are interested in AirScript, it can also help you learn WpsjsGlobal.
9
+ When deploying remote code, you can remotely invoke `WpsjsGlobal` to perform remote operations on multi-dimensional tables, smart tables, and other supported features with `AirScript`. If you're interested in `AirScript`, it can also assist you in learning it.
10
10
 
11
11
  原理是使用代理收集调用信息,之后让远程代码进行调用并且返回结果。
12
12
  远程代码在`tadcode-wpsjs/remoteCode`目录的`index.js`文件中。
@@ -83,7 +83,7 @@ const wpsjsGlobal = initRemoteCallWpsjsGlobal({ scriptToken, webhookURL, })
83
83
 
84
84
  const range = wpsjsGlobal.Application.ActiveSheet.RecordRange([1, 2], [1, 2]).Font as unknown as Font
85
85
  range.Color = '#ff00ff'
86
- /* 注意:赋值操作依旧远程操作。此函数会拿到最后一次赋值操作的promise */
86
+ /* 注意:赋值操作依旧是远程操作。此函数会拿到最后一次赋值操作的promise */
87
87
  await setValueOk()
88
88
  ```
89
89
 
package/index.ts CHANGED
@@ -94,13 +94,13 @@ const execution = ({ scriptToken, webhookURL, isAsync, argv }: ExecutionConfig)
94
94
  }
95
95
 
96
96
  let setValuePromise: any = null
97
- /* 远程调用的赋值操作返回的promise */
97
+ /** 赋值操作返回的promise */
98
98
  const setValueOk = async () => setValuePromise
99
- /**赋值 */
100
- const setValue = async <T extends Promise<any>>(
99
+ /** 赋值 */
100
+ const setValue = async <T extends Promise<any>, K extends keyof Awaited<T>, V extends Awaited<T>[K]>(
101
101
  promiseObj: T,
102
- p: keyof Awaited<T>,
103
- newValue: Awaited<T>[keyof Awaited<T>],
102
+ p: K,
103
+ newValue: V,
104
104
  ) => {
105
105
  const obj = promiseObj as Awaited<T>
106
106
  const func = obj[rawSymbol] as ProxyTarget
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tadcode-wpsjs",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "hot": "NODE_ENV=development bun --hot ignore/index.ts",
@@ -1,72 +1,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
- }
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: DBApplication
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
+ }
@@ -1,31 +1,31 @@
1
- declare module 'application:datatable' {
2
- // 基础类型定义
3
- type CriteriaOp =
4
- | 'Equals' | 'NotEqu' | 'Greater' | 'GreaterEqu' | 'Less' | 'LessEqu'
5
- | 'GreaterEquAndLessEqu' | 'LessOrGreater' | 'BeginWith' | 'EndWith'
6
- | 'Contains' | 'NotContains' | 'Intersected' | 'Empty' | 'NotEmpty';
7
-
8
- type DynamicType =
9
- | 'today' | 'yesterday' | 'tomorrow' | 'last7Days' | 'last30Days'
10
- | 'thisWeek' | 'lastWeek' | 'nextWeek' | 'thisMonth' | 'lastMonth' | 'nextMonth';
11
-
12
- // Criteria Value 类型
13
- interface CriteriaValue {
14
- type?: string;
15
- value?: any;
16
- dynamicType?: DynamicType;
17
- }
18
-
19
- // Criteria 接口
20
- interface Criteria {
21
- // 属性
22
- Field: number | string;
23
- Op: CriteriaOp;
24
- Values: CriteriaValue[];
25
-
26
- // 注意:文档中显示有 Criteria 构造函数/工厂方法,但这里是接口定义
27
- }
28
-
29
- // 导出 Criteria 类型
30
- export type { Criteria };
31
- }
1
+ declare module 'application:datatable' {
2
+ // 基础类型定义
3
+ type CriteriaOp =
4
+ | 'Equals' | 'NotEqu' | 'Greater' | 'GreaterEqu' | 'Less' | 'LessEqu'
5
+ | 'GreaterEquAndLessEqu' | 'LessOrGreater' | 'BeginWith' | 'EndWith'
6
+ | 'Contains' | 'NotContains' | 'Intersected' | 'Empty' | 'NotEmpty'
7
+
8
+ type DynamicType =
9
+ | 'today' | 'yesterday' | 'tomorrow' | 'last7Days' | 'last30Days'
10
+ | 'thisWeek' | 'lastWeek' | 'nextWeek' | 'thisMonth' | 'lastMonth' | 'nextMonth'
11
+
12
+ // Criteria Value 类型
13
+ interface CriteriaValue {
14
+ type?: string
15
+ value?: any
16
+ dynamicType?: DynamicType
17
+ }
18
+
19
+ // Criteria 接口
20
+ export interface Criteria {
21
+ // 属性
22
+ Field: number | string
23
+ Op: CriteriaOp
24
+ Values: CriteriaValue[]
25
+
26
+ // 注意:文档中显示有 Criteria 构造函数/工厂方法,但这里是接口定义
27
+ }
28
+
29
+ // 导出 Criteria 类型
30
+ export type { }
31
+ }
@@ -1,25 +1,25 @@
1
- declare module 'application:datatable' {
2
- // FieldDescriptor 接口(根据文档引用)
3
- interface FieldDescriptor {
4
- Name: string;
5
- // 其他FieldDescriptor属性
6
- }
7
-
8
- // Field 接口
9
- interface Field {
10
- // 属性
11
- readonly FieldDescriptor: FieldDescriptor;
12
- readonly Id: string;
13
- readonly Name: string;
14
- readonly Type: string;
15
- Visible: boolean;
16
- readonly Width: string;
17
-
18
- // 方法
19
- Copy(Before?: string | number, After?: string | number): Field;
20
- Move(Before?: string | number, After?: string | number): any; // ApiResult
21
- }
22
-
23
- // 导出 Field 类型
24
- export type { Field };
25
- }
1
+ declare module 'application:datatable' {
2
+ // FieldDescriptor 接口(根据文档引用)
3
+ interface FieldDescriptor {
4
+ Name: string
5
+ // 其他FieldDescriptor属性
6
+ }
7
+
8
+ // Field 接口
9
+ export interface Field {
10
+ // 属性
11
+ readonly FieldDescriptor: FieldDescriptor
12
+ readonly Id: string
13
+ readonly Name: string
14
+ readonly Type: string
15
+ Visible: boolean
16
+ readonly Width: string
17
+
18
+ // 方法
19
+ Copy(Before?: string | number, After?: string | number): Field
20
+ Move(Before?: string | number, After?: string | number): any // ApiResult
21
+ }
22
+
23
+ // 导出 Field 类型
24
+ export type { }
25
+ }
@@ -201,12 +201,12 @@ declare module 'application:datatable' {
201
201
  FieldIds: string[]
202
202
  }
203
203
 
204
- interface FieldApi {
204
+ export interface FieldApi {
205
205
  CreateFields(options: Pick<FieldFuncOptions, 'SheetId'> & { Fields: DistributiveOmit<OmitFieldSelectId<Field>, 'id'>[] }): Field[]
206
206
  GetFields(options: Pick<FieldFuncOptions, 'SheetId'>): Field[]
207
207
  UpdateFields(options: Pick<FieldFuncOptions, 'SheetId'> & { Fields: (DeepPartial<Field> & { id: string })[] }): Field[]
208
208
  DeleteFields(options: Pick<FieldFuncOptions, 'SheetId' | 'FieldIds'>): (Pick<FieldBase, 'id'> & { deleted: boolean })[]
209
209
  }
210
210
 
211
- export type { FieldApi }
211
+ export type { }
212
212
  }
@@ -0,0 +1,87 @@
1
+ declare module 'application:datatable' {
2
+ // 基础类型定义
3
+ export type FieldType =
4
+ | 'SingleLineText'
5
+ | 'MultiLineText'
6
+ | 'Date'
7
+ | 'SingleSelect'
8
+ | 'Number'
9
+ | 'Rating'
10
+ | 'ID'
11
+ | 'Phone'
12
+ | 'Email'
13
+ | 'Url'
14
+ | 'Checkbox'
15
+ | 'MultipleSelect'
16
+ | 'Complete'
17
+ | 'CellPicture'
18
+ | 'Contact'
19
+ | 'Attachment'
20
+ | 'Note'
21
+ | 'Link'
22
+ | 'OneWayLink'
23
+ | 'Lookup'
24
+ | 'Address'
25
+ | 'Cascade'
26
+ | 'Automations'
27
+ | 'AutoNumber'
28
+ | 'CreatedBy'
29
+ | 'CreatedTime'
30
+ | 'LastModifiedBy'
31
+ | 'LastModifiedTime'
32
+ | 'Formula'
33
+ | 'Button'
34
+
35
+ interface EventContext {
36
+ Destroy(): void
37
+ }
38
+
39
+ // 字段删除事件数据
40
+ interface FieldDeleteEventData {
41
+ sheetId: number
42
+ fieldId: string
43
+ fieldIds: string[]
44
+ }
45
+
46
+ // 字段描述符接口
47
+ export interface FieldDescriptor {
48
+ // 属性
49
+ Id: string
50
+ Type: FieldType
51
+ Name: string
52
+ Description: string
53
+ IsSyncField: boolean
54
+ DefaultVal: string
55
+ DefaultValType: any // Enum.DbFieldDefaultValueType
56
+ NumberFormat: string
57
+ IsValueUnique: boolean
58
+
59
+ // 各字段类型的特有属性
60
+ Button?: any
61
+ Address?: any
62
+ Cascade?: any
63
+ Contact?: any
64
+ Date?: any
65
+ Watch?: any
66
+ Formula?: any
67
+ Lookup?: any
68
+ Link?: any
69
+ Automation?: any
70
+ Attachment?: any
71
+ Url?: any
72
+ Number?: any
73
+ Select?: any
74
+ Rating?: any
75
+
76
+ // 方法
77
+ Apply(): any // ApiResult
78
+ Delete(RemoveReversedLink?: boolean): boolean
79
+
80
+ // 事件
81
+ OnUpdate(callback: (data: FieldDescriptor) => void): EventContext
82
+ OnDelete(callback: (data: FieldDeleteEventData) => void): EventContext
83
+ }
84
+
85
+ // 导出类型
86
+ export type { }
87
+ }
@@ -0,0 +1,25 @@
1
+ declare module 'application:datatable' {
2
+ import { ViewType, FieldType, FieldDescriptor } from 'application:datatable'
3
+
4
+ interface EventContext {
5
+ Destroy(): void
6
+ }
7
+
8
+ // 字段描述符集合接口
9
+ export interface FieldDescriptors {
10
+ // 属性
11
+ Count: number
12
+
13
+ // 方法
14
+ Item(Index: string | number): FieldDescriptor
15
+ FieldDescriptor(Type: string, Name: string): FieldDescriptor
16
+ AddField(FieldDescriptor: FieldDescriptor, Index?: string | number): any
17
+ Delete(FieldId: string, RemoveReversedLink?: boolean): boolean
18
+
19
+ // 事件
20
+ OnCreate(callback: (data: FieldDescriptor) => void): EventContext
21
+ }
22
+
23
+ // 导出类型
24
+ export type { }
25
+ }
@@ -1,20 +1,14 @@
1
- declare module 'application:datatable' {
2
- // Field 接口(根据文档引用)
3
- interface Field {
4
- readonly Id: string;
5
- Name: string;
6
- // 其他Field属性
7
- }
8
-
9
- // Fields 接口
10
- interface Fields {
11
- // 属性
12
- readonly Count: number;
13
-
14
- // 方法
15
- Item(Index: string | number): Field;
16
- }
17
-
18
- // 导出 Fields 类型
19
- export type { Fields };
20
- }
1
+ declare module 'application:datatable' {
2
+
3
+ // Fields 接口
4
+ export interface Fields {
5
+ // 属性
6
+ readonly Count: number
7
+
8
+ // 方法
9
+ Item(Index: string | number): Field
10
+ }
11
+
12
+ // 导出 Fields 类型
13
+ export type { }
14
+ }
@@ -1,10 +1,10 @@
1
- declare module 'application:datatable' {
2
- // Font 接口
3
- interface Font {
4
- // 属性
5
- Color: string;
6
- }
7
-
8
- // 导出 Font 类型
9
- export type { Font };
10
- }
1
+ declare module 'application:datatable' {
2
+ // Font 接口
3
+ export interface Font {
4
+ // 属性
5
+ Color: string
6
+ }
7
+
8
+ // 导出 Font 类型
9
+ export type { }
10
+ }
@@ -0,0 +1,25 @@
1
+ declare module 'application:datatable' {
2
+ // 甘特图视图模式
3
+ type GanttViewMode = 'Week' | 'Month' | 'Quarter' | 'Year'
4
+
5
+ interface EventContext {
6
+ Destroy(): void
7
+ }
8
+
9
+ // 甘特图视图UI接口
10
+ export interface GanttViewUI {
11
+ // 属性
12
+ GanttGridFold: boolean
13
+ ViewMode: GanttViewMode
14
+
15
+ // 方法
16
+ Today(): boolean
17
+ NextPage(): boolean
18
+ PrevPage(): boolean
19
+ FoldAll(): boolean
20
+ UnFoldAll(): boolean
21
+ }
22
+
23
+ // 导出类型
24
+ export type { }
25
+ }
@@ -1,22 +1,22 @@
1
- declare module 'application:datatable' {
2
- // 基础类型定义
3
- interface Attachment {
4
- // Attachment类型
5
- }
6
-
7
- // Record 接口
8
- interface Record {
9
- // 属性
10
- readonly Id: string;
11
- readonly Text: string;
12
- Value: any; // 可读写的值,根据字段类型不同返回不同类型
13
-
14
- // 方法
15
- Item(Index: number | string): Record;
16
- Delete(): boolean;
17
- Select(): boolean;
18
- }
19
-
20
- // 导出 Record 类型
21
- export type { Record };
22
- }
1
+ declare module 'application:datatable' {
2
+ // 基础类型定义
3
+ interface Attachment {
4
+ // Attachment类型
5
+ }
6
+
7
+ // Record 接口
8
+ export interface Record {
9
+ // 属性
10
+ readonly Id: string
11
+ readonly Text: string
12
+ Value: any // 可读写的值,根据字段类型不同返回不同类型
13
+
14
+ // 方法
15
+ Item(Index: number | string): Record
16
+ Delete(): boolean
17
+ Select(): boolean
18
+ }
19
+
20
+ // 导出 Record 类型
21
+ export type { }
22
+ }
@@ -166,7 +166,7 @@ declare module 'application:datatable' {
166
166
  Filter: RecordsFuncOptionsFilter
167
167
  }
168
168
  /* 行记录 */
169
- interface RecordApi {
169
+ export interface RecordApi {
170
170
  CreateRecords(options: Pick<RecordFuncOptions, 'SheetId'> & { Records: { fields: Record<string, any> }[] }): RecordItem[]
171
171
  GetRecord(options: Pick<RecordFuncOptions, 'SheetId' | 'RecordId'>): RecordItem
172
172
  GetRecords(options: Pick<RecordFuncOptions, 'SheetId'> & Partial<Pick<RecordFuncOptions, 'ViewId' | 'PageSize' | 'Offset' | 'MaxRecords' | 'Fields' | 'Filter'>>): { records: RecordItem[] }
@@ -174,5 +174,5 @@ declare module 'application:datatable' {
174
174
  DeleteRecords(options: Pick<RecordFuncOptions, 'SheetId' | 'RecordIds'>): (Pick<RecordItem, 'id'> & { deleted: boolean })[]
175
175
  }
176
176
 
177
- export type { RecordApi }
177
+ export type { }
178
178
  }