@univerjs-pro/bases 0.25.0-insiders.20260608-e4336f7

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.
Files changed (157) hide show
  1. package/README.md +42 -0
  2. package/lib/cjs/facade.js +1 -0
  3. package/lib/cjs/index.js +1 -0
  4. package/lib/cjs/locale/ar-SA.js +1 -0
  5. package/lib/cjs/locale/ca-ES.js +1 -0
  6. package/lib/cjs/locale/de-DE.js +1 -0
  7. package/lib/cjs/locale/en-US.js +1 -0
  8. package/lib/cjs/locale/es-ES.js +1 -0
  9. package/lib/cjs/locale/fa-IR.js +1 -0
  10. package/lib/cjs/locale/fr-FR.js +1 -0
  11. package/lib/cjs/locale/id-ID.js +1 -0
  12. package/lib/cjs/locale/it-IT.js +1 -0
  13. package/lib/cjs/locale/ja-JP.js +1 -0
  14. package/lib/cjs/locale/ko-KR.js +1 -0
  15. package/lib/cjs/locale/pl-PL.js +1 -0
  16. package/lib/cjs/locale/pt-BR.js +1 -0
  17. package/lib/cjs/locale/ru-RU.js +1 -0
  18. package/lib/cjs/locale/sk-SK.js +1 -0
  19. package/lib/cjs/locale/vi-VN.js +1 -0
  20. package/lib/cjs/locale/zh-CN.js +1 -0
  21. package/lib/cjs/locale/zh-HK.js +1 -0
  22. package/lib/cjs/locale/zh-TW.js +1 -0
  23. package/lib/es/facade.js +1 -0
  24. package/lib/es/index.js +1 -0
  25. package/lib/es/locale/ar-SA.js +1 -0
  26. package/lib/es/locale/ca-ES.js +1 -0
  27. package/lib/es/locale/de-DE.js +1 -0
  28. package/lib/es/locale/en-US.js +1 -0
  29. package/lib/es/locale/es-ES.js +1 -0
  30. package/lib/es/locale/fa-IR.js +1 -0
  31. package/lib/es/locale/fr-FR.js +1 -0
  32. package/lib/es/locale/id-ID.js +1 -0
  33. package/lib/es/locale/it-IT.js +1 -0
  34. package/lib/es/locale/ja-JP.js +1 -0
  35. package/lib/es/locale/ko-KR.js +1 -0
  36. package/lib/es/locale/pl-PL.js +1 -0
  37. package/lib/es/locale/pt-BR.js +1 -0
  38. package/lib/es/locale/ru-RU.js +1 -0
  39. package/lib/es/locale/sk-SK.js +1 -0
  40. package/lib/es/locale/vi-VN.js +1 -0
  41. package/lib/es/locale/zh-CN.js +1 -0
  42. package/lib/es/locale/zh-HK.js +1 -0
  43. package/lib/es/locale/zh-TW.js +1 -0
  44. package/lib/facade.js +1 -0
  45. package/lib/index.js +1 -0
  46. package/lib/locale/ar-SA.js +1 -0
  47. package/lib/locale/ca-ES.js +1 -0
  48. package/lib/locale/de-DE.js +1 -0
  49. package/lib/locale/en-US.js +1 -0
  50. package/lib/locale/es-ES.js +1 -0
  51. package/lib/locale/fa-IR.js +1 -0
  52. package/lib/locale/fr-FR.js +1 -0
  53. package/lib/locale/id-ID.js +1 -0
  54. package/lib/locale/it-IT.js +1 -0
  55. package/lib/locale/ja-JP.js +1 -0
  56. package/lib/locale/ko-KR.js +1 -0
  57. package/lib/locale/pl-PL.js +1 -0
  58. package/lib/locale/pt-BR.js +1 -0
  59. package/lib/locale/ru-RU.js +1 -0
  60. package/lib/locale/sk-SK.js +1 -0
  61. package/lib/locale/vi-VN.js +1 -0
  62. package/lib/locale/zh-CN.js +1 -0
  63. package/lib/locale/zh-HK.js +1 -0
  64. package/lib/locale/zh-TW.js +1 -0
  65. package/lib/types/commands/cell.command.d.ts +32 -0
  66. package/lib/types/commands/field.command.d.ts +53 -0
  67. package/lib/types/commands/record.command.d.ts +39 -0
  68. package/lib/types/commands/table.command.d.ts +18 -0
  69. package/lib/types/commands/undo-redo.d.ts +2 -0
  70. package/lib/types/commands/view.command.d.ts +107 -0
  71. package/lib/types/controllers/base-active-dirty.controller.d.ts +16 -0
  72. package/lib/types/controllers/base-formula-calculation.controller.d.ts +23 -0
  73. package/lib/types/controllers/base-formula-optional-identifier.d.ts +1 -0
  74. package/lib/types/controllers/base-remote-formula.controller.d.ts +13 -0
  75. package/lib/types/facade/f-base.d.ts +362 -0
  76. package/lib/types/facade/f-event.d.ts +61 -0
  77. package/lib/types/facade/f-field.d.ts +191 -0
  78. package/lib/types/facade/f-permission.d.ts +299 -0
  79. package/lib/types/facade/f-range.d.ts +179 -0
  80. package/lib/types/facade/f-record.d.ts +137 -0
  81. package/lib/types/facade/f-table.d.ts +769 -0
  82. package/lib/types/facade/f-univer.d.ts +148 -0
  83. package/lib/types/facade/f-view.d.ts +275 -0
  84. package/lib/types/facade/index.d.ts +10 -0
  85. package/lib/types/fields/date-format.d.ts +6 -0
  86. package/lib/types/fields/field-core-plugin.d.ts +21 -0
  87. package/lib/types/fields/number-format.d.ts +15 -0
  88. package/lib/types/index.d.ts +48 -0
  89. package/lib/types/locale/ar-SA.d.ts +3 -0
  90. package/lib/types/locale/ca-ES.d.ts +3 -0
  91. package/lib/types/locale/de-DE.d.ts +3 -0
  92. package/lib/types/locale/en-US.d.ts +59 -0
  93. package/lib/types/locale/es-ES.d.ts +3 -0
  94. package/lib/types/locale/fa-IR.d.ts +3 -0
  95. package/lib/types/locale/fr-FR.d.ts +3 -0
  96. package/lib/types/locale/id-ID.d.ts +3 -0
  97. package/lib/types/locale/it-IT.d.ts +3 -0
  98. package/lib/types/locale/ja-JP.d.ts +3 -0
  99. package/lib/types/locale/ko-KR.d.ts +3 -0
  100. package/lib/types/locale/pl-PL.d.ts +3 -0
  101. package/lib/types/locale/pt-BR.d.ts +3 -0
  102. package/lib/types/locale/ru-RU.d.ts +3 -0
  103. package/lib/types/locale/sk-SK.d.ts +3 -0
  104. package/lib/types/locale/vi-VN.d.ts +3 -0
  105. package/lib/types/locale/zh-CN.d.ts +3 -0
  106. package/lib/types/locale/zh-HK.d.ts +3 -0
  107. package/lib/types/locale/zh-TW.d.ts +3 -0
  108. package/lib/types/models/base-cell-data.d.ts +14 -0
  109. package/lib/types/models/base-snapshot.d.ts +1 -0
  110. package/lib/types/models/default-table.d.ts +12 -0
  111. package/lib/types/models/field-snapshot.d.ts +1 -0
  112. package/lib/types/models/record-snapshot.d.ts +1 -0
  113. package/lib/types/models/table-snapshot.d.ts +1 -0
  114. package/lib/types/models/value.d.ts +1 -0
  115. package/lib/types/models/view-snapshot.d.ts +1 -0
  116. package/lib/types/mutations/json1.mutation.d.ts +7 -0
  117. package/lib/types/mutations/utils.d.ts +2 -0
  118. package/lib/types/ot/json1-adapter.d.ts +103 -0
  119. package/lib/types/ot/json1-invalidation.d.ts +2 -0
  120. package/lib/types/ot/json1-op-applier.d.ts +6 -0
  121. package/lib/types/ot/json1-op-factory.d.ts +64 -0
  122. package/lib/types/ot/json1-path.d.ts +13 -0
  123. package/lib/types/plugin.d.ts +35 -0
  124. package/lib/types/search/base-search.d.ts +24 -0
  125. package/lib/types/services/base-active-dirty.service.d.ts +24 -0
  126. package/lib/types/services/base-command.service.d.ts +122 -0
  127. package/lib/types/services/base-compression.service.d.ts +46 -0
  128. package/lib/types/services/base-field-registry.service.d.ts +17 -0
  129. package/lib/types/services/base-formula.service.d.ts +71 -0
  130. package/lib/types/services/base-performance.service.d.ts +5 -0
  131. package/lib/types/services/base-permission.service.d.ts +76 -0
  132. package/lib/types/services/base-projection.service.d.ts +97 -0
  133. package/lib/types/services/base-resource.service.d.ts +15 -0
  134. package/lib/types/services/base-view-registry.service.d.ts +15 -0
  135. package/lib/types/views/view-core-plugin.d.ts +21 -0
  136. package/lib/umd/facade.js +1 -0
  137. package/lib/umd/index.js +1 -0
  138. package/lib/umd/locale/ar-SA.js +1 -0
  139. package/lib/umd/locale/ca-ES.js +1 -0
  140. package/lib/umd/locale/de-DE.js +1 -0
  141. package/lib/umd/locale/en-US.js +1 -0
  142. package/lib/umd/locale/es-ES.js +1 -0
  143. package/lib/umd/locale/fa-IR.js +1 -0
  144. package/lib/umd/locale/fr-FR.js +1 -0
  145. package/lib/umd/locale/id-ID.js +1 -0
  146. package/lib/umd/locale/it-IT.js +1 -0
  147. package/lib/umd/locale/ja-JP.js +1 -0
  148. package/lib/umd/locale/ko-KR.js +1 -0
  149. package/lib/umd/locale/pl-PL.js +1 -0
  150. package/lib/umd/locale/pt-BR.js +1 -0
  151. package/lib/umd/locale/ru-RU.js +1 -0
  152. package/lib/umd/locale/sk-SK.js +1 -0
  153. package/lib/umd/locale/vi-VN.js +1 -0
  154. package/lib/umd/locale/zh-CN.js +1 -0
  155. package/lib/umd/locale/zh-HK.js +1 -0
  156. package/lib/umd/locale/zh-TW.js +1 -0
  157. package/package.json +86 -0
@@ -0,0 +1,299 @@
1
+ import type { IBaseFieldPermission, IBasePermissionService, IBasePermissionSnapshot, IBaseRecordPermission, IBaseTablePermission } from '../services/base-permission.service';
2
+ /**
3
+ * Facade API for Base permission points.
4
+ *
5
+ * It exposes Base-local permission controls that are consumed by Base commands.
6
+ * Server-backed auth can hydrate the same points without changing facade callers.
7
+ *
8
+ * @example Configure permissions from server auth data
9
+ * ```ts
10
+ * const permission = base.getPermission();
11
+ * permission.setBasePermission({ createTable: false });
12
+ * permission.setTablePermission('tasks', { createRecord: false });
13
+ * permission.setFieldPermission('tasks', 'status', { edit: false });
14
+ * permission.setRecordPermission('tasks', 'task-1', { delete: false });
15
+ *
16
+ * console.log(permission.canCreateTable());
17
+ * console.log(permission.canEditCell('tasks', 'task-1', 'status'));
18
+ * console.log(permission.getSnapshot());
19
+ * ```
20
+ */
21
+ export declare class FBasePermission {
22
+ private readonly _baseId;
23
+ private readonly _permissionService;
24
+ constructor(_baseId: string, _permissionService: IBasePermissionService);
25
+ /**
26
+ * Set Base-level permissions.
27
+ *
28
+ * Base-level permissions apply to the whole Base unit. They are the right
29
+ * place for permissions that do not belong to a specific table, field,
30
+ * record, or view.
31
+ *
32
+ * @param permission Permission patch. `createTable` controls whether new
33
+ * tables can be created in this Base.
34
+ * @param permission.createTable Optional flag for creating tables.
35
+ * @example
36
+ * ```ts
37
+ * base.getPermission().setBasePermission({ createTable: false });
38
+ * ```
39
+ */
40
+ setBasePermission(permission: {
41
+ createTable?: boolean;
42
+ }): void;
43
+ /**
44
+ * Set table-level permissions.
45
+ *
46
+ * Use this for permissions that affect table operations or all records,
47
+ * fields, and views under a table.
48
+ *
49
+ * @param tableId Target table id.
50
+ * @param permission Table permission patch, such as `delete`,
51
+ * `createField`, `createRecord`, or view management flags.
52
+ * @example
53
+ * ```ts
54
+ * permission.setTablePermission('tasks', { createRecord: false });
55
+ * ```
56
+ */
57
+ setTablePermission(tableId: string, permission: IBaseTablePermission): void;
58
+ /**
59
+ * Set field-level permissions.
60
+ *
61
+ * Field permissions are checked by field commands and by cell editing for
62
+ * the target field.
63
+ *
64
+ * @param tableId Target table id.
65
+ * @param fieldId Target field id.
66
+ * @param permission Field permission patch, such as edit/delete flags.
67
+ * @example
68
+ * ```ts
69
+ * permission.setFieldPermission('tasks', 'status', { edit: false });
70
+ * ```
71
+ */
72
+ setFieldPermission(tableId: string, fieldId: string, permission: IBaseFieldPermission): void;
73
+ /**
74
+ * Set record-level permissions.
75
+ *
76
+ * Record permissions are checked for record-specific operations such as
77
+ * delete and cell edits on that row.
78
+ *
79
+ * @param tableId Target table id.
80
+ * @param recordId Target record id.
81
+ * @param permission Record permission patch, such as delete/edit flags.
82
+ * @example
83
+ * ```ts
84
+ * permission.setRecordPermission('tasks', 'task-1', { delete: false });
85
+ * ```
86
+ */
87
+ setRecordPermission(tableId: string, recordId: string, permission: IBaseRecordPermission): void;
88
+ /**
89
+ * Clear Base-level permission overrides.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * permission.clearBasePermission();
94
+ * ```
95
+ */
96
+ clearBasePermission(): void;
97
+ /**
98
+ * Clear permission overrides for one table.
99
+ *
100
+ * @param tableId Target table id.
101
+ * @example
102
+ * ```ts
103
+ * permission.clearTablePermission('tasks');
104
+ * ```
105
+ */
106
+ clearTablePermission(tableId: string): void;
107
+ /**
108
+ * Clear permission overrides for one field.
109
+ *
110
+ * @param tableId Target table id.
111
+ * @param fieldId Target field id.
112
+ * @example
113
+ * ```ts
114
+ * permission.clearFieldPermission('tasks', 'status');
115
+ * ```
116
+ */
117
+ clearFieldPermission(tableId: string, fieldId: string): void;
118
+ /**
119
+ * Clear permission overrides for one record.
120
+ *
121
+ * @param tableId Target table id.
122
+ * @param recordId Target record id.
123
+ * @example
124
+ * ```ts
125
+ * permission.clearRecordPermission('tasks', 'task-1');
126
+ * ```
127
+ */
128
+ clearRecordPermission(tableId: string, recordId: string): void;
129
+ /**
130
+ * Check whether the Base can create tables.
131
+ * @returns `true` when table creation is allowed.
132
+ * @example
133
+ * ```ts
134
+ * if (permission.canCreateTable()) await base.createTable({ name: 'Tasks' });
135
+ * ```
136
+ */
137
+ canCreateTable(): boolean;
138
+ /**
139
+ * Check whether a table can be deleted.
140
+ * @param tableId Target table id.
141
+ * @returns `true` when table deletion is allowed.
142
+ * @example
143
+ * ```ts
144
+ * console.log(permission.canDeleteTable('tasks'));
145
+ * ```
146
+ */
147
+ canDeleteTable(tableId: string): boolean;
148
+ /**
149
+ * Check whether fields can be created in a table.
150
+ * @param tableId Target table id.
151
+ * @returns `true` when field creation is allowed.
152
+ * @example
153
+ * ```ts
154
+ * console.log(permission.canCreateField('tasks'));
155
+ * ```
156
+ */
157
+ canCreateField(tableId: string): boolean;
158
+ /**
159
+ * Check whether a field can be edited.
160
+ * @param tableId Target table id.
161
+ * @param fieldId Target field id.
162
+ * @returns `true` when field metadata edits are allowed.
163
+ * @example
164
+ * ```ts
165
+ * console.log(permission.canEditField('tasks', 'status'));
166
+ * ```
167
+ */
168
+ canEditField(tableId: string, fieldId: string): boolean;
169
+ /**
170
+ * Check whether a field can be deleted.
171
+ * @param tableId Target table id.
172
+ * @param fieldId Target field id.
173
+ * @returns `true` when field deletion is allowed.
174
+ * @example
175
+ * ```ts
176
+ * console.log(permission.canDeleteField('tasks', 'status'));
177
+ * ```
178
+ */
179
+ canDeleteField(tableId: string, fieldId: string): boolean;
180
+ /**
181
+ * Check whether records can be created in a table.
182
+ * @param tableId Target table id.
183
+ * @returns `true` when record creation is allowed.
184
+ * @example
185
+ * ```ts
186
+ * console.log(permission.canCreateRecord('tasks'));
187
+ * ```
188
+ */
189
+ canCreateRecord(tableId: string): boolean;
190
+ /**
191
+ * Check whether a record can be deleted.
192
+ * @param tableId Target table id.
193
+ * @param recordId Target record id.
194
+ * @returns `true` when record deletion is allowed.
195
+ * @example
196
+ * ```ts
197
+ * console.log(permission.canDeleteRecord('tasks', 'task-1'));
198
+ * ```
199
+ */
200
+ canDeleteRecord(tableId: string, recordId: string): boolean;
201
+ /**
202
+ * Check whether one cell can be edited.
203
+ *
204
+ * The effective result combines table, field, record, and readonly-style
205
+ * restrictions in the permission service.
206
+ *
207
+ * @param tableId Target table id.
208
+ * @param recordId Target record id.
209
+ * @param fieldId Target field id.
210
+ * @returns `true` when the cell edit is allowed.
211
+ * @example
212
+ * ```ts
213
+ * if (permission.canEditCell('tasks', 'task-1', 'status')) {
214
+ * await table.setCellValue('task-1', 'status', 'done');
215
+ * }
216
+ * ```
217
+ */
218
+ canEditCell(tableId: string, recordId: string, fieldId: string): boolean;
219
+ /**
220
+ * Check whether one view can be managed.
221
+ * @param tableId Target table id.
222
+ * @param viewId Target view id.
223
+ * @returns `true` when view configuration, ordering, or deletion is allowed.
224
+ * @example
225
+ * ```ts
226
+ * console.log(permission.canManageView('tasks', 'grid-main'));
227
+ * ```
228
+ */
229
+ canManageView(tableId: string, viewId: string): boolean;
230
+ /**
231
+ * Get the current permission snapshot.
232
+ *
233
+ * Use this at the persistence boundary if Base-local permission overrides
234
+ * are stored with the server-side Base model.
235
+ *
236
+ * @returns Base permission snapshot.
237
+ * @example
238
+ * ```ts
239
+ * await savePermissionSnapshot(base.getId(), permission.getSnapshot());
240
+ * ```
241
+ */
242
+ getSnapshot(): IBasePermissionSnapshot;
243
+ }
244
+ /**
245
+ * Table-scoped permission facade returned by `table.getPermission()`.
246
+ *
247
+ * It is a convenience wrapper around `FBasePermission` for callers that already
248
+ * operate inside one table and do not want to pass `tableId` repeatedly.
249
+ */
250
+ export declare class FTablePermission {
251
+ private readonly _tableId;
252
+ private readonly _permissionService;
253
+ constructor(_tableId: string, _permissionService: IBasePermissionService);
254
+ /**
255
+ * Set permission overrides for this table.
256
+ * @param permission Table permission patch.
257
+ * @example
258
+ * ```ts
259
+ * table.getPermission().setPermission({ createRecord: false });
260
+ * ```
261
+ */
262
+ setPermission(permission: IBaseTablePermission): void;
263
+ /**
264
+ * Clear permission overrides for this table.
265
+ * @example
266
+ * ```ts
267
+ * table.getPermission().clearPermission();
268
+ * ```
269
+ */
270
+ clearPermission(): void;
271
+ /**
272
+ * Check whether this table can be deleted.
273
+ * @returns `true` when table deletion is allowed.
274
+ */
275
+ canDeleteTable(): boolean;
276
+ /**
277
+ * Check whether fields can be created in this table.
278
+ * @returns `true` when field creation is allowed.
279
+ */
280
+ canCreateField(): boolean;
281
+ /**
282
+ * Check whether records can be created in this table.
283
+ * @returns `true` when record creation is allowed.
284
+ */
285
+ canCreateRecord(): boolean;
286
+ /**
287
+ * Check whether a view in this table can be managed.
288
+ * @param viewId Target view id.
289
+ * @returns `true` when view management is allowed.
290
+ */
291
+ canManageView(viewId: string): boolean;
292
+ /**
293
+ * Check whether one cell in this table can be edited.
294
+ * @param recordId Target record id.
295
+ * @param fieldId Target field id.
296
+ * @returns `true` when the cell edit is allowed.
297
+ */
298
+ canEditCell(recordId: string, fieldId: string): boolean;
299
+ }
@@ -0,0 +1,179 @@
1
+ import type { BaseCellValue, BaseDataModel, IBaseCellData, ICommandService, IRange } from '@univerjs/core';
2
+ export type BaseRangeValues = BaseCellValue[][];
3
+ /**
4
+ * Facade API object bound to a rectangular Base table range.
5
+ *
6
+ * A Base range is addressed by row and column indexes over records and fields,
7
+ * similar to a spreadsheet range over worksheet cells.
8
+ *
9
+ * Row indexes resolve through the table's current `recordOrder`; column indexes
10
+ * resolve through `fieldOrder`. Writes are converted to Base cell updates under
11
+ * the hood, so the persisted snapshot still stores values by record id and
12
+ * field id.
13
+ *
14
+ * @example Read and write a rectangular block
15
+ * ```ts
16
+ * const range = table.getRange(0, 0, 2, 2);
17
+ * console.log(range.getValues());
18
+ * await range.setValues([
19
+ * ['Task A', 'todo'],
20
+ * ['Task B', 'done'],
21
+ * ]);
22
+ * const statusColumn = range.offset(0, 1, range.getNumRows(), 1);
23
+ * await statusColumn.clear();
24
+ * ```
25
+ */
26
+ export declare class FBaseRange {
27
+ private readonly _base;
28
+ private readonly _tableId;
29
+ private readonly _range;
30
+ private readonly _commandService;
31
+ constructor(_base: BaseDataModel, _tableId: string, _range: IRange, _commandService: ICommandService);
32
+ /**
33
+ * Get the Base unit id.
34
+ * @returns The Base unit id.
35
+ * @example
36
+ * ```ts
37
+ * console.log(range.getUnitId());
38
+ * ```
39
+ */
40
+ getUnitId(): string;
41
+ /**
42
+ * Get the Base id.
43
+ * @returns The Base id.
44
+ * @example
45
+ * ```ts
46
+ * console.log(range.getBaseId());
47
+ * ```
48
+ */
49
+ getBaseId(): string;
50
+ /**
51
+ * Get the table id.
52
+ * @returns The table id.
53
+ * @example
54
+ * ```ts
55
+ * console.log(range.getTableId());
56
+ * ```
57
+ */
58
+ getTableId(): string;
59
+ /**
60
+ * Get the raw range position.
61
+ * @returns The range position.
62
+ * @example
63
+ * ```ts
64
+ * const position = range.getRange();
65
+ * ```
66
+ */
67
+ getRange(): IRange;
68
+ /**
69
+ * Get the first row index of this range.
70
+ * @returns The zero-based row index.
71
+ * @example
72
+ * ```ts
73
+ * console.log(range.getRow());
74
+ * ```
75
+ */
76
+ getRow(): number;
77
+ /**
78
+ * Get the first column index of this range.
79
+ * @returns The zero-based column index.
80
+ * @example
81
+ * ```ts
82
+ * console.log(range.getColumn());
83
+ * ```
84
+ */
85
+ getColumn(): number;
86
+ /**
87
+ * Get the number of rows in this range.
88
+ * @returns The row count.
89
+ * @example
90
+ * ```ts
91
+ * console.log(range.getNumRows());
92
+ * ```
93
+ */
94
+ getNumRows(): number;
95
+ /**
96
+ * Get the number of columns in this range.
97
+ * @returns The column count.
98
+ * @example
99
+ * ```ts
100
+ * console.log(range.getNumColumns());
101
+ * ```
102
+ */
103
+ getNumColumns(): number;
104
+ /**
105
+ * Get all values in this range.
106
+ *
107
+ * The outer array is rows and the inner array is columns. Empty cells are
108
+ * returned as `null`.
109
+ *
110
+ * @returns A two-dimensional array matching the range size.
111
+ * @example
112
+ * ```ts
113
+ * const values = table.getRange(0, 0, 2, 3).getValues();
114
+ * ```
115
+ */
116
+ getValues(): BaseRangeValues;
117
+ /**
118
+ * Get the first value in this range.
119
+ * @returns The top-left value.
120
+ * @example
121
+ * ```ts
122
+ * const value = table.getRange(0, 0).getValue();
123
+ * ```
124
+ */
125
+ getValue(): BaseCellValue;
126
+ /**
127
+ * Set the top-left value in this range.
128
+ * @param value The value to write. It may be a raw Base cell value, a full
129
+ * `IBaseCellData` object, or `null` to clear the cell.
130
+ * @example
131
+ * ```ts
132
+ * await table.getRange(0, 0).setValue('Task title');
133
+ * ```
134
+ */
135
+ setValue(value: BaseCellValue | IBaseCellData | null): Promise<void>;
136
+ /**
137
+ * Set all values in this range.
138
+ *
139
+ * The provided matrix must match `getNumRows()` by `getNumColumns()`.
140
+ * Passing the wrong shape throws before any command is executed.
141
+ *
142
+ * @param values A two-dimensional array matching the range size. Each cell
143
+ * may be a raw Base cell value, an `IBaseCellData` object, or `null`.
144
+ * @example
145
+ * ```ts
146
+ * await table.getRange(0, 1, 2, 2).setValues([
147
+ * ['todo', 10],
148
+ * ['done', 20],
149
+ * ]);
150
+ * ```
151
+ */
152
+ setValues(values: Array<Array<BaseCellValue | IBaseCellData | null>>): Promise<void>;
153
+ /**
154
+ * Clear all values in this range.
155
+ * @example
156
+ * ```ts
157
+ * await table.getRange(0, 0, 10, 3).clear();
158
+ * ```
159
+ */
160
+ clear(): Promise<void>;
161
+ /**
162
+ * Create a new range offset from this range.
163
+ *
164
+ * Offsets are validated against the table's current row and column bounds.
165
+ *
166
+ * @param rowOffset Number of rows to move. Positive values move down.
167
+ * @param columnOffset Number of columns to move. Positive values move right.
168
+ * @param numRows Number of rows in the returned range. Defaults to the current row count.
169
+ * @param numColumns Number of columns in the returned range. Defaults to the current column count.
170
+ * @returns The offset range facade.
171
+ * @example
172
+ * ```ts
173
+ * const nextColumn = range.offset(0, 1);
174
+ * ```
175
+ */
176
+ offset(rowOffset: number, columnOffset: number, numRows?: number, numColumns?: number): FBaseRange;
177
+ private _getTable;
178
+ private _assertInBounds;
179
+ }
@@ -0,0 +1,137 @@
1
+ import type { BaseCellValue, BaseDataModel, ICommandService, IRecordSnapshot } from '@univerjs/core';
2
+ /**
3
+ * Facade API object bound to a Base record.
4
+ *
5
+ * A Base record is equivalent to a row in a table.
6
+ * Record values are keyed by field id. Use field ids from `FField` or
7
+ * `table.getPrimaryFieldId()` instead of display names when reading or writing.
8
+ *
9
+ * @example Read, update, and duplicate a record
10
+ * ```ts
11
+ * const record = table.getRecord('task-1');
12
+ * if (record) {
13
+ * await record.setValue('status', 'done');
14
+ * await record.setValues({ progress: 100 });
15
+ * const copy = await record.duplicate({
16
+ * id: 'task-1-copy',
17
+ * values: { ...record.getValues(), status: 'todo' },
18
+ * });
19
+ * console.log(copy.getId());
20
+ * }
21
+ * ```
22
+ */
23
+ export declare class FRecord {
24
+ private readonly _base;
25
+ private readonly _tableId;
26
+ private readonly _recordId;
27
+ private readonly _commandService;
28
+ constructor(_base: BaseDataModel, _tableId: string, _recordId: string, _commandService: ICommandService);
29
+ /**
30
+ * Get the record id.
31
+ * @returns The record id.
32
+ * @example
33
+ * ```ts
34
+ * console.log(record.getId());
35
+ * ```
36
+ */
37
+ getId(): string;
38
+ /**
39
+ * Get the record snapshot.
40
+ * @returns The record snapshot.
41
+ * @example
42
+ * ```ts
43
+ * const rawRecord = record.getRecord();
44
+ * ```
45
+ */
46
+ getRecord(): IRecordSnapshot;
47
+ /**
48
+ * Get the record snapshot.
49
+ * @returns The record snapshot.
50
+ * @example
51
+ * ```ts
52
+ * const snapshot = record.getSnapshot();
53
+ * ```
54
+ */
55
+ getSnapshot(): IRecordSnapshot;
56
+ /**
57
+ * Get a field value from this record.
58
+ * @param fieldId The field id.
59
+ * @returns The field value, or null when empty.
60
+ * @example
61
+ * ```ts
62
+ * const title = record.getValue('title');
63
+ * ```
64
+ */
65
+ getValue(fieldId: string): BaseCellValue;
66
+ /**
67
+ * Get all values from this record.
68
+ * @returns A field-id keyed value map.
69
+ * @example
70
+ * ```ts
71
+ * const values = record.getValues();
72
+ * ```
73
+ */
74
+ getValues(): IRecordSnapshot['values'];
75
+ /**
76
+ * Set one field value in this record.
77
+ * @param fieldId The field id to write.
78
+ * @param value The new cell value. Pass `null` to clear the cell.
79
+ * @example
80
+ * ```ts
81
+ * await record.setValue('status', 'done');
82
+ * ```
83
+ */
84
+ setValue(fieldId: string, value: BaseCellValue): Promise<void>;
85
+ /**
86
+ * Set multiple field values in this record.
87
+ * @param values Field-id keyed values to write. Only the provided fields are
88
+ * patched; omitted fields keep their existing values.
89
+ * @example
90
+ * ```ts
91
+ * await record.setValues({ title: 'Ship beta', status: 'done' });
92
+ * ```
93
+ */
94
+ setValues(values: Record<string, BaseCellValue>): Promise<void>;
95
+ /**
96
+ * Delete this record.
97
+ * @example
98
+ * ```ts
99
+ * await record.delete();
100
+ * ```
101
+ */
102
+ delete(): Promise<void>;
103
+ /**
104
+ * Duplicate this record.
105
+ *
106
+ * The duplicated record starts with this record's values, then applies
107
+ * `input.values` as field-id keyed overrides.
108
+ *
109
+ * @param input Optional record id, values, and order key overrides.
110
+ * @param input.id Optional id for the duplicated record.
111
+ * @param input.values Optional field-id keyed values for the duplicated record.
112
+ * @param input.orderKey Optional order key for the duplicated record.
113
+ * @returns The duplicated record facade.
114
+ * @example
115
+ * ```ts
116
+ * const copy = await record.duplicate({
117
+ * id: 'record-copy',
118
+ * values: { title: 'Copy' },
119
+ * });
120
+ * ```
121
+ */
122
+ duplicate(input?: {
123
+ id?: string;
124
+ values?: Record<string, BaseCellValue>;
125
+ orderKey?: string;
126
+ }): Promise<FRecord>;
127
+ /**
128
+ * Set this record's order key.
129
+ * @param orderKey The new order key.
130
+ * @example
131
+ * ```ts
132
+ * await record.setOrderKey('a1');
133
+ * ```
134
+ */
135
+ setOrderKey(orderKey: string): Promise<void>;
136
+ private _getRecord;
137
+ }