@univerjs-pro/bases 1.0.0-alpha.1 → 1.0.0-alpha.3

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 (127) hide show
  1. package/README.md +8 -5
  2. package/lib/cjs/facade.js +1 -1
  3. package/lib/cjs/index.js +1 -1
  4. package/lib/cjs/locale/ar-SA.js +1 -1
  5. package/lib/cjs/locale/ca-ES.js +1 -1
  6. package/lib/cjs/locale/de-DE.js +1 -1
  7. package/lib/cjs/locale/en-US.js +1 -1
  8. package/lib/cjs/locale/es-ES.js +1 -1
  9. package/lib/cjs/locale/fa-IR.js +1 -1
  10. package/lib/cjs/locale/fr-FR.js +1 -1
  11. package/lib/cjs/locale/id-ID.js +1 -1
  12. package/lib/cjs/locale/it-IT.js +1 -1
  13. package/lib/cjs/locale/ja-JP.js +1 -1
  14. package/lib/cjs/locale/ko-KR.js +1 -1
  15. package/lib/cjs/locale/pl-PL.js +1 -1
  16. package/lib/cjs/locale/pt-BR.js +1 -1
  17. package/lib/cjs/locale/ru-RU.js +1 -1
  18. package/lib/cjs/locale/sk-SK.js +1 -1
  19. package/lib/cjs/locale/vi-VN.js +1 -1
  20. package/lib/cjs/locale/zh-CN.js +1 -1
  21. package/lib/cjs/locale/zh-HK.js +1 -1
  22. package/lib/cjs/locale/zh-TW.js +1 -1
  23. package/lib/es/facade.js +1 -1
  24. package/lib/es/index.js +1 -1
  25. package/lib/es/locale/ar-SA.js +1 -1
  26. package/lib/es/locale/ca-ES.js +1 -1
  27. package/lib/es/locale/de-DE.js +1 -1
  28. package/lib/es/locale/en-US.js +1 -1
  29. package/lib/es/locale/es-ES.js +1 -1
  30. package/lib/es/locale/fa-IR.js +1 -1
  31. package/lib/es/locale/fr-FR.js +1 -1
  32. package/lib/es/locale/id-ID.js +1 -1
  33. package/lib/es/locale/it-IT.js +1 -1
  34. package/lib/es/locale/ja-JP.js +1 -1
  35. package/lib/es/locale/ko-KR.js +1 -1
  36. package/lib/es/locale/pl-PL.js +1 -1
  37. package/lib/es/locale/pt-BR.js +1 -1
  38. package/lib/es/locale/ru-RU.js +1 -1
  39. package/lib/es/locale/sk-SK.js +1 -1
  40. package/lib/es/locale/vi-VN.js +1 -1
  41. package/lib/es/locale/zh-CN.js +1 -1
  42. package/lib/es/locale/zh-HK.js +1 -1
  43. package/lib/es/locale/zh-TW.js +1 -1
  44. package/lib/facade.js +1 -1
  45. package/lib/index.js +1 -1
  46. package/lib/locale/ar-SA.js +1 -1
  47. package/lib/locale/ca-ES.js +1 -1
  48. package/lib/locale/de-DE.js +1 -1
  49. package/lib/locale/en-US.js +1 -1
  50. package/lib/locale/es-ES.js +1 -1
  51. package/lib/locale/fa-IR.js +1 -1
  52. package/lib/locale/fr-FR.js +1 -1
  53. package/lib/locale/id-ID.js +1 -1
  54. package/lib/locale/it-IT.js +1 -1
  55. package/lib/locale/ja-JP.js +1 -1
  56. package/lib/locale/ko-KR.js +1 -1
  57. package/lib/locale/pl-PL.js +1 -1
  58. package/lib/locale/pt-BR.js +1 -1
  59. package/lib/locale/ru-RU.js +1 -1
  60. package/lib/locale/sk-SK.js +1 -1
  61. package/lib/locale/vi-VN.js +1 -1
  62. package/lib/locale/zh-CN.js +1 -1
  63. package/lib/locale/zh-HK.js +1 -1
  64. package/lib/locale/zh-TW.js +1 -1
  65. package/lib/types/commands/commands/set-base-view-filter.command.d.ts +2 -2
  66. package/lib/types/commands/commands/set-base-view-group.command.d.ts +2 -2
  67. package/lib/types/commands/commands/set-base-view-sort.command.d.ts +2 -2
  68. package/lib/types/commands/utils/base-validation.d.ts +6 -0
  69. package/lib/types/config/config.d.ts +11 -0
  70. package/lib/types/controllers/base-active-dirty.controller.d.ts +5 -6
  71. package/lib/types/controllers/base-formula-calculation.controller.d.ts +8 -14
  72. package/lib/types/embed-host-anchor.d.ts +46 -0
  73. package/lib/types/facade/f-base.d.ts +126 -577
  74. package/lib/types/facade/f-enum.d.ts +117 -89
  75. package/lib/types/facade/f-event.d.ts +255 -132
  76. package/lib/types/facade/f-field.d.ts +137 -313
  77. package/lib/types/facade/f-range.d.ts +86 -326
  78. package/lib/types/facade/f-record.d.ts +93 -216
  79. package/lib/types/facade/f-table.d.ts +473 -1317
  80. package/lib/types/facade/f-types.d.ts +1 -0
  81. package/lib/types/facade/f-univer.d.ts +27 -154
  82. package/lib/types/facade/f-view.d.ts +207 -484
  83. package/lib/types/facade/field-key.d.ts +6 -6
  84. package/lib/types/facade/index.d.ts +11 -14
  85. package/lib/types/fields/field-core-plugin.d.ts +9 -8
  86. package/lib/types/index.d.ts +17 -47
  87. package/lib/types/models/base-cell-data.d.ts +6 -6
  88. package/lib/types/models/default-table.d.ts +13 -0
  89. package/lib/types/ot/json1-adapter.d.ts +3 -3
  90. package/lib/types/ot/json1-invalidation.d.ts +2 -2
  91. package/lib/types/ot/json1-op-applier.d.ts +2 -2
  92. package/lib/types/ot/json1-op-factory.d.ts +9 -8
  93. package/lib/types/plugin.d.ts +6 -4
  94. package/lib/types/search/base-search.d.ts +4 -3
  95. package/lib/types/services/base-active-dirty.service.d.ts +2 -2
  96. package/lib/types/services/base-command.service.d.ts +16 -16
  97. package/lib/types/services/base-compression.service.d.ts +3 -3
  98. package/lib/types/services/base-field-registry.service.d.ts +5 -5
  99. package/lib/types/services/base-formula.service.d.ts +11 -20
  100. package/lib/types/services/base-view-registry.service.d.ts +3 -3
  101. package/lib/types/views/view-core-plugin.d.ts +4 -3
  102. package/lib/umd/facade.js +1 -1
  103. package/lib/umd/index.js +1 -1
  104. package/lib/umd/locale/ar-SA.js +1 -1
  105. package/lib/umd/locale/ca-ES.js +1 -1
  106. package/lib/umd/locale/de-DE.js +1 -1
  107. package/lib/umd/locale/en-US.js +1 -1
  108. package/lib/umd/locale/es-ES.js +1 -1
  109. package/lib/umd/locale/fa-IR.js +1 -1
  110. package/lib/umd/locale/fr-FR.js +1 -1
  111. package/lib/umd/locale/id-ID.js +1 -1
  112. package/lib/umd/locale/it-IT.js +1 -1
  113. package/lib/umd/locale/ja-JP.js +1 -1
  114. package/lib/umd/locale/ko-KR.js +1 -1
  115. package/lib/umd/locale/pl-PL.js +1 -1
  116. package/lib/umd/locale/pt-BR.js +1 -1
  117. package/lib/umd/locale/ru-RU.js +1 -1
  118. package/lib/umd/locale/sk-SK.js +1 -1
  119. package/lib/umd/locale/vi-VN.js +1 -1
  120. package/lib/umd/locale/zh-CN.js +1 -1
  121. package/lib/umd/locale/zh-HK.js +1 -1
  122. package/lib/umd/locale/zh-TW.js +1 -1
  123. package/package.json +7 -8
  124. package/lib/types/controllers/base-remote-formula.controller.d.ts +0 -13
  125. package/lib/types/facade/f-error.d.ts +0 -30
  126. package/lib/types/facade/f-permission.d.ts +0 -749
  127. package/lib/types/facade/transaction.d.ts +0 -19
@@ -1,5 +1,7 @@
1
- import type { BaseCellValue, BaseDataModel, ICommandService, IRecordSnapshot } from '@univerjs/core';
2
- import type { IBaseFieldKeyOptions } from './field-key';
1
+ import type { BaseCellValue, FieldId, Injector, IRecordSnapshot } from '@univerjs/core';
2
+ import type { FBase } from './f-base';
3
+ import type { FBaseTable } from './f-table';
4
+ import { BaseFieldKeyEnum } from './field-key';
3
5
  /**
4
6
  * Facade API object bound to a Base record.
5
7
  *
@@ -9,147 +11,72 @@ import type { IBaseFieldKeyOptions } from './field-key';
9
11
  *
10
12
  * @example Read, update, and duplicate a record
11
13
  * ```ts
12
- * const record = table.getRecord('task-1');
14
+ * const fBase = univerAPI.getActiveBase();
15
+ * const fBaseTable = fBase.getTableById('table-1');
16
+ *
17
+ * const record = fBaseTable.getRecordById('task-1');
13
18
  * if (record) {
14
19
  * record.setValue('status', 'done');
15
20
  * record.setValues({ progress: 100 });
16
21
  * const copy = record.duplicate({
17
- * id: 'task-1-copy',
18
22
  * values: { ...record.getValues(), status: 'todo' },
19
23
  * });
20
24
  * console.log(copy.getId());
21
25
  * }
22
26
  * ```
23
27
  */
24
- export declare class FRecord {
28
+ export declare class FBaseTableRecord {
25
29
  private readonly _base;
26
- private readonly _tableId;
30
+ private readonly _table;
27
31
  private readonly _recordId;
28
- private readonly _commandService;
29
- constructor(_base: BaseDataModel, _tableId: string, _recordId: string, _commandService: ICommandService);
32
+ private readonly _inject;
33
+ constructor(_base: FBase, _table: FBaseTable, _recordId: string, _inject: Injector);
30
34
  /**
31
35
  * Get the record id.
32
- * @returns The record id.
36
+ * @returns {string} The record id.
33
37
  * @example
34
38
  * ```ts
35
- * console.log(record.getId());
36
- * ```
37
- *
38
- * @example Browser console
39
- * ```ts
40
- * console.log((() => {
41
- * const unitId = `facade_example_${Date.now()}`;
42
- * const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
43
- * try {
44
- * const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
45
- * const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
46
- * const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
47
- * return record.getId();
48
- * } finally {
49
- * univerAPI.disposeUnit(unitId);
50
- * }
51
- * })());
39
+ * const fBase = univerAPI.getActiveBase();
40
+ * const fBaseTable = fBase.getTableById('table-1');
41
+ * const records = fBaseTable.getRecords();
42
+ * console.log(records[0]?.getId());
52
43
  * ```
53
44
  */
54
45
  getId(): string;
55
46
  /**
56
47
  * Get the record snapshot.
57
- * @returns The record snapshot.
48
+ * @returns {IRecordSnapshot} The record snapshot.
58
49
  * @example
59
50
  * ```ts
60
- * const rawRecord = record.getRecord();
61
- * ```
62
- *
63
- * @example Browser console
64
- * ```ts
65
- * console.log((() => {
66
- * const unitId = `facade_example_${Date.now()}`;
67
- * const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
68
- * try {
69
- * const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
70
- * const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
71
- * const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
72
- * return record.getRecord();
73
- * } finally {
74
- * univerAPI.disposeUnit(unitId);
75
- * }
76
- * })());
51
+ * const fBase = univerAPI.getActiveBase();
52
+ * const fBaseTable = fBase.getTableById('table-1');
53
+ * const records = fBaseTable.getRecords();
54
+ * console.log(records[0]?.getRecord());
77
55
  * ```
78
56
  */
79
57
  getRecord(): IRecordSnapshot;
80
- /**
81
- * Get the record snapshot.
82
- * @returns The record snapshot.
83
- * @example
84
- * ```ts
85
- * const snapshot = record.getSnapshot();
86
- * ```
87
- *
88
- * @example Browser console
89
- * ```ts
90
- * console.log((() => {
91
- * const unitId = `facade_example_${Date.now()}`;
92
- * const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
93
- * try {
94
- * const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
95
- * const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
96
- * const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
97
- * return record.getSnapshot();
98
- * } finally {
99
- * univerAPI.disposeUnit(unitId);
100
- * }
101
- * })());
102
- * ```
103
- */
104
- getSnapshot(): IRecordSnapshot;
105
58
  /**
106
59
  * Get a field value from this record.
107
- * @param fieldId The field id.
108
- * @returns The field value, or null when empty.
60
+ * @param {FieldId} fieldId The field id.
61
+ * @returns {BaseCellValue} The cell value, or `null` if the field is empty.
109
62
  * @example
110
63
  * ```ts
111
- * const title = record.getValue('title');
112
- * ```
113
- *
114
- * @example Browser console
115
- * ```ts
116
- * console.log((() => {
117
- * const unitId = `facade_example_${Date.now()}`;
118
- * const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
119
- * try {
120
- * const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
121
- * const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
122
- * const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
123
- * return record.getValue(field.getId());
124
- * } finally {
125
- * univerAPI.disposeUnit(unitId);
126
- * }
127
- * })());
64
+ * const fBase = univerAPI.getActiveBase();
65
+ * const fBaseTable = fBase.getTableById('table-1');
66
+ * const record = fBaseTable.getRecords()[0];
67
+ * console.log(record.getValue('status'));
128
68
  * ```
129
69
  */
130
- getValue(fieldId: string): BaseCellValue;
70
+ getValue(fieldId: FieldId): BaseCellValue;
131
71
  /**
132
72
  * Get all values from this record.
133
73
  * @returns A field-id keyed value map.
134
74
  * @example
135
75
  * ```ts
136
- * const values = record.getValues();
137
- * ```
138
- *
139
- * @example Browser console
140
- * ```ts
141
- * console.log((() => {
142
- * const unitId = `facade_example_${Date.now()}`;
143
- * const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
144
- * try {
145
- * const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
146
- * const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
147
- * const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
148
- * return record.getValues();
149
- * } finally {
150
- * univerAPI.disposeUnit(unitId);
151
- * }
152
- * })());
76
+ * const fBase = univerAPI.getActiveBase();
77
+ * const fBaseTable = fBase.getTableById('table-1');
78
+ * const record = fBaseTable.getRecords()[0];
79
+ * console.log(record.getValues());
153
80
  * ```
154
81
  */
155
82
  getValues(): IRecordSnapshot['values'];
@@ -159,146 +86,96 @@ export declare class FRecord {
159
86
  * @param value The new cell value. Pass `null` to clear the cell.
160
87
  * @example
161
88
  * ```ts
162
- * record.setValue('status', 'done');
163
- * ```
164
- *
165
- * @example Browser console
166
- * ```ts
167
- * console.log((() => {
168
- * const unitId = `facade_example_${Date.now()}`;
169
- * const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
170
- * try {
171
- * const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
172
- * const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
173
- * const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
174
- * record.setValue(field.getId(), 'done');
175
- * return record.getValue(field.getId());
176
- * } finally {
177
- * univerAPI.disposeUnit(unitId);
178
- * }
179
- * })());
89
+ * const fBase = univerAPI.getActiveBase();
90
+ * const fBaseTable = fBase.getTableById('table-1');
91
+ * const record = fBaseTable.getRecordById('task-1');
92
+ * const success = record.setValue('status', 'done');
93
+ * console.log(success);
180
94
  * ```
181
95
  */
182
- setValue(fieldId: string, value: BaseCellValue): void;
96
+ setValue(fieldId: FieldId, value: BaseCellValue): boolean;
183
97
  /**
184
98
  * Set multiple field values in this record.
185
- * @param values Field-id keyed values to write. Only the provided fields are
99
+ * @param {Record<string, BaseCellValue>} values Field-id keyed values to write. Only the provided fields are
186
100
  * patched; omitted fields keep their existing values.
101
+ * @param {BaseFieldKeyEnum} fieldKey How to interpret the keys in `values`. Defaults to `BaseFieldKeyEnum.Id`.
102
+ * @returns {boolean} `true` if the command succeeded, `false` otherwise.
103
+ *
187
104
  * @example
188
105
  * ```ts
189
- * record.setValues({ title: 'Ship beta', status: 'done' });
106
+ * const fBase = univerAPI.getActiveBase();
107
+ * const fBaseTable = fBase.getTableById('table-1');
108
+ * const record = fBaseTable.getRecordById('task-1');
109
+ * const success = record.setValues(
110
+ * {
111
+ * status: 'done',
112
+ * progress: 100
113
+ * }
114
+ * );
115
+ * console.log(success);
190
116
  * ```
191
117
  *
192
- * @example Browser console
118
+ * @example
193
119
  * ```ts
194
- * console.log((() => {
195
- * const unitId = `facade_example_${Date.now()}`;
196
- * const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
197
- * try {
198
- * const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
199
- * const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
200
- * const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
201
- * record.setValues({ Title: 'Updated', Status: 'done' }, { fieldKey: univerAPI.Enum.BaseFieldKeyEnum.Name });
202
- * return record.getValues();
203
- * } finally {
204
- * univerAPI.disposeUnit(unitId);
205
- * }
206
- * })());
120
+ * const fBase = univerAPI.getActiveBase();
121
+ * const fBaseTable = fBase.getTableById('table-1');
122
+ * const record = fBaseTable.getRecordById('task-1');
123
+ * const success = record.setValues(
124
+ * {
125
+ * Status: 'done',
126
+ * Progress: 100
127
+ * },
128
+ * univerAPI.Enum.BaseFieldKeyEnum.Name
129
+ * );
130
+ * console.log(success);
207
131
  * ```
208
132
  */
209
- setValues(values: Record<string, BaseCellValue>, options?: IBaseFieldKeyOptions): void;
133
+ setValues(values: Record<string, BaseCellValue>, fieldKey?: BaseFieldKeyEnum): boolean;
210
134
  /**
211
135
  * Delete this record.
136
+ * @returns {boolean} `true` if the command succeeded, `false` otherwise.
212
137
  * @example
213
138
  * ```ts
214
- * record.delete();
215
- * ```
216
- *
217
- * @example Browser console
218
- * ```ts
219
- * console.log((() => {
220
- * const unitId = `facade_example_${Date.now()}`;
221
- * const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
222
- * try {
223
- * const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
224
- * const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
225
- * const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
226
- * const recordId = record.getId();
227
- * record.delete();
228
- * return table.getRecord(recordId);
229
- * } finally {
230
- * univerAPI.disposeUnit(unitId);
231
- * }
232
- * })());
139
+ * const fBase = univerAPI.getActiveBase();
140
+ * const fBaseTable = fBase.getTableById('table-1');
141
+ * const record = fBaseTable.getRecordById('task-1');
142
+ * const success = record.delete();
143
+ * console.log(success);
233
144
  * ```
234
145
  */
235
- delete(): void;
146
+ delete(): boolean;
236
147
  /**
237
148
  * Duplicate this record.
238
- *
239
- * The duplicated record starts with this record's values, then applies
240
- * `input.values` as field-id keyed overrides.
241
- *
242
- * @param input Optional record id, values, and order key overrides.
243
- * @param input.id Optional id for the duplicated record.
244
- * @param input.values Optional field-id keyed values for the duplicated record.
245
- * @param input.orderKey Optional order key for the duplicated record.
246
- * @returns The duplicated record facade.
149
+ * @param {Partial<Omit<IRecordSnapshot, 'id'>>} [record] Optional record snapshot to override the source record.
150
+ * @returns {FBaseTableRecord} The new record.
247
151
  * @example
248
152
  * ```ts
249
- * const copy = record.duplicate({
250
- * id: 'record-copy',
251
- * values: { title: 'Copy' },
252
- * });
253
- * ```
254
- *
255
- * @example Browser console
256
- * ```ts
257
- * console.log((() => {
258
- * const unitId = `facade_example_${Date.now()}`;
259
- * const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
260
- * try {
261
- * const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
262
- * const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
263
- * const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
264
- * const copy = record.duplicate({ id: `${unitId}_copy`, values: { [field.getId()]: 'done' } });
265
- * return { original: record.getId(), copy: copy.getId() };
266
- * } finally {
267
- * univerAPI.disposeUnit(unitId);
268
- * }
269
- * })());
153
+ * const fBase = univerAPI.getActiveBase();
154
+ * const fBaseTable = fBase.getTableById('table-1');
155
+ * const record = fBaseTable.getRecordById('task-1');
156
+ * const copy = record.duplicate();
157
+ * console.log(copy);
270
158
  * ```
271
159
  */
272
- duplicate(input?: {
273
- id?: string;
274
- values?: Record<string, BaseCellValue>;
275
- orderKey?: string;
276
- }): FRecord;
160
+ duplicate(record?: Partial<Omit<IRecordSnapshot, 'id'>>): FBaseTableRecord;
277
161
  /**
278
162
  * Set this record's order key.
279
- * @param orderKey The new order key.
163
+ * @param {string} orderKey The new order key.
164
+ * @returns {boolean} `true` if the command succeeded, `false` otherwise.
280
165
  * @example
281
166
  * ```ts
282
- * record.setOrderKey('a1');
283
- * ```
167
+ * const fBase = univerAPI.getActiveBase();
168
+ * const fBaseTable = fBase.getTableById('table-1');
169
+ * const records = fBaseTable.getRecords();
170
+ * const lastRecord = records[records.length - 1];
284
171
  *
285
- * @example Browser console
286
- * ```ts
287
- * console.log((() => {
288
- * const unitId = `facade_example_${Date.now()}`;
289
- * const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
290
- * try {
291
- * const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
292
- * const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
293
- * const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
294
- * record.setOrderKey('z');
295
- * return record.getRecord().orderKey;
296
- * } finally {
297
- * univerAPI.disposeUnit(unitId);
298
- * }
299
- * })());
172
+ * // "0000" sorts before the timestamp-like order keys used by newly
173
+ * // created records, so the last record moves to the top immediately.
174
+ * // Clear the view's field sort first to see the underlying record order.
175
+ * const success = lastRecord?.setOrderKey('0000') ?? false;
176
+ * console.log(success ? 'Record moved to the top' : 'Failed to move record');
300
177
  * ```
301
178
  */
302
- setOrderKey(orderKey: string): void;
179
+ setOrderKey(orderKey: string): boolean;
303
180
  private _getRecord;
304
181
  }