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
|
@@ -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
|
-
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type { DistributiveOmit, DeepPartial } from './type-tools'
|
|
2
|
+
import type { Operator, } from './DB_Application_Record'
|
|
3
|
+
|
|
4
|
+
interface FieldBase {
|
|
5
|
+
id: string
|
|
6
|
+
name: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type DatePart =
|
|
10
|
+
| 'MM/dd'
|
|
11
|
+
| 'yyyy/MM/dd'
|
|
12
|
+
| 'yyyy-MM-dd'
|
|
13
|
+
| 'yyyy\"年\"M\"月\"d\"日\"'
|
|
14
|
+
| 'yyyy\"年\"m\"月\"'
|
|
15
|
+
|
|
16
|
+
type DateFormat =
|
|
17
|
+
| `${DatePart};@`
|
|
18
|
+
| `${DatePart} aaaa;@`
|
|
19
|
+
| `${DatePart} aaaa hh:mm;@`
|
|
20
|
+
|
|
21
|
+
type TimePart =
|
|
22
|
+
| 'h:mm'
|
|
23
|
+
| 'h:mm:ss'
|
|
24
|
+
|
|
25
|
+
type TimeFormat =
|
|
26
|
+
| `[$-409]${TimePart};@`
|
|
27
|
+
| `[$-409]${TimePart} AM/PM;@`
|
|
28
|
+
|
|
29
|
+
type ZeroFormat =
|
|
30
|
+
| `${number}_ `
|
|
31
|
+
| `#,##${number}_ `
|
|
32
|
+
|
|
33
|
+
type CurrencyFormat =
|
|
34
|
+
| `¥#,##0;¥-#,##0`
|
|
35
|
+
| `¥#,##0.0;¥-#,##0.0`
|
|
36
|
+
| `¥#,##0.00;¥-#,##0.00`
|
|
37
|
+
| `$#,##0;$-#,##0`
|
|
38
|
+
| `$#,##0.0;$-#,##0.0`
|
|
39
|
+
| `$#,##0.00;$-#,##0.00`
|
|
40
|
+
| `\"€\"#,##0;\"€\"-#,##0`
|
|
41
|
+
| `\"€\"#,##0.0;\"€\"-#,##0.0`
|
|
42
|
+
| `\"€\"#,##0.00;\"€\"-#,##0.00`
|
|
43
|
+
|
|
44
|
+
type RatingRange = 0 | 1 | 2 | 3 | 4 | 5
|
|
45
|
+
|
|
46
|
+
type CompleteRange = `0.${number}`
|
|
47
|
+
|
|
48
|
+
type SelectItem = { id: string, value: string }
|
|
49
|
+
|
|
50
|
+
type OmitFieldSelectId<T> = T extends { type: 'SingleSelect' | 'MultipleSelect', items: [SelectItem, ...SelectItem[]] } ? Omit<T, 'items'> & { items: [Omit<SelectItem, 'id'>, ...Omit<SelectItem, 'id'>[]] } : T
|
|
51
|
+
|
|
52
|
+
interface FieldTypeFormat {
|
|
53
|
+
MultiLineText: {
|
|
54
|
+
uniqueValue?: boolean
|
|
55
|
+
defaultValue?: string
|
|
56
|
+
}
|
|
57
|
+
Date: {
|
|
58
|
+
uniqueValue?: boolean
|
|
59
|
+
defaultValue?: string
|
|
60
|
+
numberFormat?: DateFormat
|
|
61
|
+
defaultValueType?: 'Normal' | 'RecordCreateTime'
|
|
62
|
+
}
|
|
63
|
+
Time: {
|
|
64
|
+
uniqueValue?: boolean
|
|
65
|
+
defaultValue?: string
|
|
66
|
+
numberFormat?: TimeFormat
|
|
67
|
+
}
|
|
68
|
+
Number: {
|
|
69
|
+
uniqueValue?: boolean
|
|
70
|
+
defaultValue?: string
|
|
71
|
+
numberFormat?: ZeroFormat
|
|
72
|
+
}
|
|
73
|
+
Currency: {
|
|
74
|
+
uniqueValue?: boolean
|
|
75
|
+
defaultValue?: string
|
|
76
|
+
numberFormat?: CurrencyFormat
|
|
77
|
+
}
|
|
78
|
+
Percentage: {
|
|
79
|
+
uniqueValue?: boolean
|
|
80
|
+
defaultValue?: string
|
|
81
|
+
numberFormat?: `${number}%`
|
|
82
|
+
}
|
|
83
|
+
ID: {
|
|
84
|
+
uniqueValue?: boolean
|
|
85
|
+
defaultValue?: string
|
|
86
|
+
numberFormat?: string
|
|
87
|
+
}
|
|
88
|
+
Phone: {
|
|
89
|
+
uniqueValue?: boolean
|
|
90
|
+
defaultValue?: string
|
|
91
|
+
numberFormat?: string
|
|
92
|
+
}
|
|
93
|
+
Email: {
|
|
94
|
+
uniqueValue?: boolean
|
|
95
|
+
defaultValue?: string
|
|
96
|
+
numberFormat?: string
|
|
97
|
+
}
|
|
98
|
+
Url: {
|
|
99
|
+
uniqueValue?: boolean
|
|
100
|
+
defaultValue?: string
|
|
101
|
+
numberFormat?: string
|
|
102
|
+
displayText?: string
|
|
103
|
+
}
|
|
104
|
+
Checkbox: {
|
|
105
|
+
uniqueValue?: boolean
|
|
106
|
+
defaultValue?: '1'
|
|
107
|
+
numberFormat?: string
|
|
108
|
+
}
|
|
109
|
+
SingleSelect: {
|
|
110
|
+
uniqueValue?: boolean
|
|
111
|
+
defaultValue?: string
|
|
112
|
+
numberFormat?: string
|
|
113
|
+
autoAddItem?: boolean
|
|
114
|
+
items: [SelectItem, ...SelectItem[]]
|
|
115
|
+
}
|
|
116
|
+
MultipleSelect: {
|
|
117
|
+
uniqueValue?: boolean
|
|
118
|
+
defaultValue?: string
|
|
119
|
+
numberFormat?: string
|
|
120
|
+
autoAddItem?: boolean
|
|
121
|
+
items: [SelectItem, ...SelectItem[]]
|
|
122
|
+
}
|
|
123
|
+
Rating: {
|
|
124
|
+
uniqueValue?: boolean
|
|
125
|
+
defaultValue?: string
|
|
126
|
+
numberFormat?: string
|
|
127
|
+
max: RatingRange
|
|
128
|
+
}
|
|
129
|
+
Complete: {
|
|
130
|
+
uniqueValue?: boolean
|
|
131
|
+
defaultValue?: `0.${number}`
|
|
132
|
+
numberFormat?: `${number}%`
|
|
133
|
+
}
|
|
134
|
+
Contact: {
|
|
135
|
+
uniqueValue?: boolean
|
|
136
|
+
defaultValue?: {
|
|
137
|
+
avatar: string
|
|
138
|
+
companyId: string
|
|
139
|
+
nickName: string
|
|
140
|
+
}[]
|
|
141
|
+
defaultValueType?: 'Normal' | 'RecordCreator'
|
|
142
|
+
numberFormat?: string
|
|
143
|
+
multipleContacts: boolean
|
|
144
|
+
noticeNewContact: boolean
|
|
145
|
+
}
|
|
146
|
+
Attachment: {
|
|
147
|
+
uniqueValue?: boolean
|
|
148
|
+
onlyUploadByCamera?: boolean
|
|
149
|
+
displayStyle?: 'Pic' | 'List'
|
|
150
|
+
}
|
|
151
|
+
/* 可关联的记录范围不支持设置 */
|
|
152
|
+
Link: {
|
|
153
|
+
uniqueValue?: boolean
|
|
154
|
+
linkSheet: number
|
|
155
|
+
multipleLinks: boolean
|
|
156
|
+
}
|
|
157
|
+
Note: {}
|
|
158
|
+
AutoNumber: {
|
|
159
|
+
uniqueValue?: boolean
|
|
160
|
+
numberFormat?: '000000' | '00000000',
|
|
161
|
+
}
|
|
162
|
+
CreatedBy: {
|
|
163
|
+
uniqueValue?: boolean
|
|
164
|
+
}
|
|
165
|
+
CreatedTime: {
|
|
166
|
+
uniqueValue?: boolean
|
|
167
|
+
}
|
|
168
|
+
Formula: {}
|
|
169
|
+
Lookup: {
|
|
170
|
+
lookupSheetId?: 5,
|
|
171
|
+
lookupField?: string,
|
|
172
|
+
lookupFunction?: 'Origin',
|
|
173
|
+
filter?: {
|
|
174
|
+
groups: [
|
|
175
|
+
{
|
|
176
|
+
conds: {
|
|
177
|
+
linkSheetFieldId: string
|
|
178
|
+
/**注意字段类型,文本 数字 日期 所用操作符会不一样 */
|
|
179
|
+
condOpType: Operator
|
|
180
|
+
curSheetCondType: 'Field' | 'Literal'
|
|
181
|
+
curSheetCondContents: string[]
|
|
182
|
+
}[]
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
type FieldTypeKeys = keyof FieldTypeFormat
|
|
190
|
+
|
|
191
|
+
type ResultField<T> = { type: T } & FieldTypeFormat[T] & FieldBase
|
|
192
|
+
|
|
193
|
+
// 使用映射类型生成联合类型
|
|
194
|
+
type Field = {
|
|
195
|
+
[K in FieldTypeKeys]: ResultField<K>
|
|
196
|
+
}[FieldTypeKeys]
|
|
197
|
+
|
|
198
|
+
interface FieldFuncOptions {
|
|
199
|
+
SheetId: number
|
|
200
|
+
Fields: Field[]
|
|
201
|
+
FieldIds: string[]
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export type { RatingRange, CompleteRange, FieldTypeKeys, Field, FieldFuncOptions }
|
|
205
|
+
|
|
206
|
+
/* 字段 */
|
|
207
|
+
export default interface DBField {
|
|
208
|
+
CreateFields(options: Pick<FieldFuncOptions, 'SheetId'> & { Fields: DistributiveOmit<OmitFieldSelectId<Field>, 'id'>[] }): Field[]
|
|
209
|
+
GetFields(options: Pick<FieldFuncOptions, 'SheetId'>): Field[]
|
|
210
|
+
UpdateFields(options: Pick<FieldFuncOptions, 'SheetId'> & { Fields: (DeepPartial<Field> & { id: string })[] }): Field[]
|
|
211
|
+
DeleteFields(options: Pick<FieldFuncOptions, 'SheetId' | 'FieldIds'>): (Pick<FieldBase, 'id'> & { deleted: boolean })[]
|
|
212
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { RatingRange, CompleteRange } from './DB_Application_Field'
|
|
2
|
+
import type { MakePropertyOptional, PickModify } from './type-tools'
|
|
3
|
+
|
|
4
|
+
/* 复杂字段 超链接 联系人 附件 关联 */
|
|
5
|
+
interface RecordValueFormat {
|
|
6
|
+
MultiLineText: string
|
|
7
|
+
Date: `${number}/${number}` | `${number}/${number}/${number}`
|
|
8
|
+
Time: `${number}:${number}` | `${number}:${number}:${number}`
|
|
9
|
+
Number: number
|
|
10
|
+
Currency: number
|
|
11
|
+
Percentage: number
|
|
12
|
+
ID: string
|
|
13
|
+
Phone: string
|
|
14
|
+
Email: string
|
|
15
|
+
Url: string | { address: string, displayText: string }
|
|
16
|
+
Checkbox: boolean
|
|
17
|
+
SingleSelect: string
|
|
18
|
+
MultipleSelect: string[]
|
|
19
|
+
Rating: RatingRange
|
|
20
|
+
Complete: number
|
|
21
|
+
Contact: {
|
|
22
|
+
id: string,
|
|
23
|
+
nickName?: string,
|
|
24
|
+
avatar?: string
|
|
25
|
+
}[]
|
|
26
|
+
Attachment: {
|
|
27
|
+
uploadId: string,
|
|
28
|
+
fileName: string,
|
|
29
|
+
source: 'upload_ks3' | 'cloud',
|
|
30
|
+
type: string,
|
|
31
|
+
linkUrl?: string
|
|
32
|
+
size: number,
|
|
33
|
+
imgSize: string,
|
|
34
|
+
}[]
|
|
35
|
+
Link: string[] | { recordIds: string[] }
|
|
36
|
+
Note: never
|
|
37
|
+
AutoNumber: never
|
|
38
|
+
CreatedBy: never
|
|
39
|
+
CreatedTime: never
|
|
40
|
+
Formula: never
|
|
41
|
+
Lookup: never
|
|
42
|
+
SingleSelect: never
|
|
43
|
+
MultipleSelect: never
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface RecordItem {
|
|
47
|
+
id: string,
|
|
48
|
+
fields: Record<string, RecordValueFormat[keyof RecordValueFormat]> & Partial<RecordValueFormat>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type Operator = 'Equals' | 'NotEqu' | 'Greater' | 'GreaterEqu' | 'Less' | 'LessEqu' | 'GreaterEquAndLessEqu' | 'LessOrGreater' | 'BeginWith' | 'EndWith' | 'Contains' | 'NotContains' | 'Intersected' | 'Empty' | 'NotEmpty'
|
|
52
|
+
|
|
53
|
+
type DynamicDateRange = 'today' | 'yesterday' | 'tomorrow' | 'last7Days' | 'last30Days' | 'thisWeek' | 'lastWeek' | 'nextWeek' | 'thisMonth' | 'lastMonth' | 'nextMonth'
|
|
54
|
+
|
|
55
|
+
interface RecordsFuncOptionsFilter {
|
|
56
|
+
/**选填。表示各筛选条件之间的逻辑关系。只能是'AND'或'OR'。缺省值为'AND' */
|
|
57
|
+
mode?: 'AND' | 'OR',
|
|
58
|
+
/**filter结构体内必填。包含筛选条件的数组。每个字段上只能有一个筛选条件 */
|
|
59
|
+
criteria: {
|
|
60
|
+
/**必填。根据 preferId 与否,需要填入字段名或字段id */
|
|
61
|
+
field: string
|
|
62
|
+
/**"Equals": 等于
|
|
63
|
+
|
|
64
|
+
"NotEqu": 不等于
|
|
65
|
+
|
|
66
|
+
"Greater": 大于
|
|
67
|
+
|
|
68
|
+
"GreaterEqu": 大等于
|
|
69
|
+
|
|
70
|
+
"Less": 小于
|
|
71
|
+
|
|
72
|
+
"LessEqu": 小等于
|
|
73
|
+
|
|
74
|
+
"GreaterEquAndLessEqu": 介于(取等)
|
|
75
|
+
|
|
76
|
+
"LessOrGreater": 介于(不取等)
|
|
77
|
+
|
|
78
|
+
"BeginWith": 开头是
|
|
79
|
+
|
|
80
|
+
"EndWith": 结尾是
|
|
81
|
+
|
|
82
|
+
"Contains": 包含
|
|
83
|
+
|
|
84
|
+
"NotContains": 不包含
|
|
85
|
+
|
|
86
|
+
"Intersected": 指定值
|
|
87
|
+
|
|
88
|
+
"Empty": 为空
|
|
89
|
+
|
|
90
|
+
"NotEmpty": 不为空
|
|
91
|
+
*/
|
|
92
|
+
op: Operator
|
|
93
|
+
/**
|
|
94
|
+
* 必填。表示筛选规则中的值。数组形式。值为字符串时表示文本匹配。
|
|
95
|
+
* 这里的 values,必须是一个数组,传 ["多维表"],相当于传 [{ type: 'Text', value: '多维表' }],即不传默认帮你补充 Text 类型。
|
|
96
|
+
* 复选框的值,values: ['0'] 代表否,value: ['1'] 代表是。
|
|
97
|
+
*
|
|
98
|
+
* values[]数组内的元素为字符串时,表示文本匹配。各筛选规则独立地限制了values数组内最多允许填写的元素数,当values内元素数超过阈值时,该筛选规则将失效。
|
|
99
|
+
*
|
|
100
|
+
* a. “为空、不为空”不允许填写元素;
|
|
101
|
+
*
|
|
102
|
+
* b. “介于”允许最多填写2个元素;
|
|
103
|
+
*
|
|
104
|
+
* c. “指定值”允许填写65535个元素;
|
|
105
|
+
*
|
|
106
|
+
* d. 其他规则允许最多填写1个元素
|
|
107
|
+
*/
|
|
108
|
+
values: string[] | {
|
|
109
|
+
type: 'Text'
|
|
110
|
+
value: string
|
|
111
|
+
}[] |
|
|
112
|
+
{
|
|
113
|
+
type: 'DynamicSimple'
|
|
114
|
+
/**
|
|
115
|
+
* 当"op"为"greater"或"less"时,"dynamicType"只能是昨天、今天或明天。
|
|
116
|
+
*
|
|
117
|
+
* "today": 今天
|
|
118
|
+
*
|
|
119
|
+
* "yesterday": 昨天
|
|
120
|
+
*
|
|
121
|
+
* "tomorrow": 明天
|
|
122
|
+
*
|
|
123
|
+
* "last7Days": 最近7天
|
|
124
|
+
*
|
|
125
|
+
* "last30Days": 最近30天
|
|
126
|
+
*
|
|
127
|
+
* "thisWeek": 本周
|
|
128
|
+
*
|
|
129
|
+
* "lastWeek": 上周
|
|
130
|
+
*
|
|
131
|
+
* "nextWeek":下周
|
|
132
|
+
*
|
|
133
|
+
* "thisMonth": 本月
|
|
134
|
+
*
|
|
135
|
+
* "lastMonth": 上月
|
|
136
|
+
*
|
|
137
|
+
* "nextMonth": 次月
|
|
138
|
+
*/
|
|
139
|
+
dynamicType: DynamicDateRange
|
|
140
|
+
}[]
|
|
141
|
+
}[]
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
interface RecordFuncOptions {
|
|
145
|
+
SheetId: number
|
|
146
|
+
RecordId: string
|
|
147
|
+
RecordIds: string[]
|
|
148
|
+
Records: RecordItem[]
|
|
149
|
+
/**
|
|
150
|
+
* 填写后将从被指定的视图获取该用户所见到的记录;若不填写,则从工作表获取记录
|
|
151
|
+
*/
|
|
152
|
+
ViewId: string
|
|
153
|
+
/**
|
|
154
|
+
* 存在分页时,指定本次查询的起始记录(含)。若不填写或填写为空字符串,则从第一条记录开始获取
|
|
155
|
+
*
|
|
156
|
+
* 当前最大值:1000
|
|
157
|
+
*/
|
|
158
|
+
PageSize: number
|
|
159
|
+
/**分页查询时,将返回一个offset值,指向下一页的第一条记录,供后续查询。查询到最后一页或第maxRecords条记录时,返回数据将不再包含offset值 */
|
|
160
|
+
Offset: number
|
|
161
|
+
/**指定要获取的“前maxRecords条记录”,若不填写,则默认返回全部记录 */
|
|
162
|
+
MaxRecords: number
|
|
163
|
+
/**具体字段类型说明详见 [附件2](https://kdocs.cn/l/ctzsgDlAGF0l?linkname=QSt7dOHYA0) */
|
|
164
|
+
Fields: string[]
|
|
165
|
+
/**详细说明见 [附件4](https://www.kdocs.cn/l/ctzsgDlAGF0l?linkname=wsTfzS9o34) */
|
|
166
|
+
Filter: RecordsFuncOptionsFilter
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type { Operator, DynamicDateRange, RecordItem, RecordFuncOptions }
|
|
170
|
+
|
|
171
|
+
/* 行记录 */
|
|
172
|
+
export default interface DBRecord {
|
|
173
|
+
CreateRecords(options: Pick<RecordFuncOptions, 'SheetId'> & { Records: Omit<RecordItem, 'id'>[] }): RecordItem[]
|
|
174
|
+
GetRecord(options: Pick<RecordFuncOptions, 'SheetId' | 'RecordId'>): RecordItem
|
|
175
|
+
GetRecords(options: Pick<RecordFuncOptions, 'SheetId'> & Partial<Pick<RecordFuncOptions, 'ViewId' | 'PageSize' | 'Offset' | 'MaxRecords' | 'Fields' | 'Filter'>>): { records: RecordItem[] }
|
|
176
|
+
UpdateRecords(options: Pick<RecordFuncOptions, 'SheetId' | 'Records'>): RecordItem[]
|
|
177
|
+
DeleteRecords(options: Pick<RecordFuncOptions, 'SheetId' | 'RecordIds'>): (Pick<RecordItem, 'id'> & { deleted: boolean })[]
|
|
178
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RecordItem } from './DB_Application_Record'
|
|
2
|
+
|
|
3
|
+
interface ActiveView {
|
|
4
|
+
"sheetId": number
|
|
5
|
+
"viewId": string
|
|
6
|
+
"name": string
|
|
7
|
+
"type": string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ActiveSheet {
|
|
11
|
+
"sheetId": number
|
|
12
|
+
"name": string
|
|
13
|
+
"description": string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type { ActiveView, ActiveSheet }
|
|
17
|
+
|
|
18
|
+
export default interface DBSelection {
|
|
19
|
+
GetActiveView(): ActiveView
|
|
20
|
+
GetSelectionRecords(): RecordItem[]
|
|
21
|
+
GetActiveSheet(): ActiveSheet
|
|
22
|
+
}
|