@univerjs-pro/bases 1.0.0-alpha.2 → 1.0.0-alpha.4
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 +8 -5
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/locale/ar-SA.js +1 -1
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/de-DE.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/id-ID.js +1 -1
- package/lib/cjs/locale/it-IT.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/pl-PL.js +1 -1
- package/lib/cjs/locale/pt-BR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-HK.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/es/locale/ar-SA.js +1 -1
- package/lib/es/locale/ca-ES.js +1 -1
- package/lib/es/locale/de-DE.js +1 -1
- package/lib/es/locale/en-US.js +1 -1
- package/lib/es/locale/es-ES.js +1 -1
- package/lib/es/locale/fa-IR.js +1 -1
- package/lib/es/locale/fr-FR.js +1 -1
- package/lib/es/locale/id-ID.js +1 -1
- package/lib/es/locale/it-IT.js +1 -1
- package/lib/es/locale/ja-JP.js +1 -1
- package/lib/es/locale/ko-KR.js +1 -1
- package/lib/es/locale/pl-PL.js +1 -1
- package/lib/es/locale/pt-BR.js +1 -1
- package/lib/es/locale/ru-RU.js +1 -1
- package/lib/es/locale/sk-SK.js +1 -1
- package/lib/es/locale/vi-VN.js +1 -1
- package/lib/es/locale/zh-CN.js +1 -1
- package/lib/es/locale/zh-HK.js +1 -1
- package/lib/es/locale/zh-TW.js +1 -1
- package/lib/facade.js +1 -1
- package/lib/index.js +1 -1
- package/lib/locale/ar-SA.js +1 -1
- package/lib/locale/ca-ES.js +1 -1
- package/lib/locale/de-DE.js +1 -1
- package/lib/locale/en-US.js +1 -1
- package/lib/locale/es-ES.js +1 -1
- package/lib/locale/fa-IR.js +1 -1
- package/lib/locale/fr-FR.js +1 -1
- package/lib/locale/id-ID.js +1 -1
- package/lib/locale/it-IT.js +1 -1
- package/lib/locale/ja-JP.js +1 -1
- package/lib/locale/ko-KR.js +1 -1
- package/lib/locale/pl-PL.js +1 -1
- package/lib/locale/pt-BR.js +1 -1
- package/lib/locale/ru-RU.js +1 -1
- package/lib/locale/sk-SK.js +1 -1
- package/lib/locale/vi-VN.js +1 -1
- package/lib/locale/zh-CN.js +1 -1
- package/lib/locale/zh-HK.js +1 -1
- package/lib/locale/zh-TW.js +1 -1
- package/lib/types/commands/commands/set-base-name.command.d.ts +6 -0
- package/lib/types/commands/commands/set-base-view-filter.command.d.ts +2 -2
- package/lib/types/commands/commands/set-base-view-group.command.d.ts +2 -2
- package/lib/types/commands/commands/set-base-view-sort.command.d.ts +2 -2
- package/lib/types/commands/utils/base-validation.d.ts +6 -0
- package/lib/types/config/config.d.ts +1 -0
- package/lib/types/controllers/base-active-dirty.controller.d.ts +5 -6
- package/lib/types/controllers/base-formula-calculation.controller.d.ts +8 -14
- package/lib/types/embed-host-anchor.d.ts +46 -0
- package/lib/types/facade/f-base.d.ts +126 -577
- package/lib/types/facade/f-enum.d.ts +117 -89
- package/lib/types/facade/f-event.d.ts +240 -132
- package/lib/types/facade/f-field.d.ts +137 -313
- package/lib/types/facade/f-range.d.ts +86 -326
- package/lib/types/facade/f-record.d.ts +93 -216
- package/lib/types/facade/f-table.d.ts +473 -1317
- package/lib/types/facade/f-types.d.ts +1 -0
- package/lib/types/facade/f-univer.d.ts +27 -154
- package/lib/types/facade/f-view.d.ts +207 -484
- package/lib/types/facade/field-key.d.ts +6 -6
- package/lib/types/facade/index.d.ts +10 -20
- package/lib/types/fields/field-core-plugin.d.ts +9 -8
- package/lib/types/index.d.ts +12 -8
- package/lib/types/models/base-cell-data.d.ts +6 -6
- package/lib/types/models/default-table.d.ts +13 -0
- package/lib/types/ot/json1-adapter.d.ts +3 -3
- package/lib/types/ot/json1-invalidation.d.ts +2 -2
- package/lib/types/ot/json1-op-applier.d.ts +2 -2
- package/lib/types/ot/json1-op-factory.d.ts +11 -8
- package/lib/types/plugin.d.ts +0 -1
- package/lib/types/search/base-search.d.ts +4 -3
- package/lib/types/services/base-active-dirty.service.d.ts +2 -2
- package/lib/types/services/base-command.service.d.ts +16 -16
- package/lib/types/services/base-compression.service.d.ts +3 -3
- package/lib/types/services/base-field-registry.service.d.ts +5 -5
- package/lib/types/services/base-formula.service.d.ts +11 -23
- package/lib/types/services/base-view-registry.service.d.ts +3 -3
- package/lib/types/views/view-core-plugin.d.ts +4 -3
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +7 -8
- package/lib/types/controllers/base-remote-formula.controller.d.ts +0 -13
- package/lib/types/facade/f-error.d.ts +0 -30
- package/lib/types/facade/f-permission.d.ts +0 -749
- package/lib/types/facade/transaction.d.ts +0 -19
|
@@ -1,749 +0,0 @@
|
|
|
1
|
-
import type { BaseFieldPermission, BasePermissionSnapshot, BaseRecordPermission, BaseTablePermission, IBasePermissionService } from '@univerjs-pro/bases';
|
|
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
|
-
* @example Browser console
|
|
41
|
-
* ```ts
|
|
42
|
-
* console.log((() => {
|
|
43
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
44
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
45
|
-
* try {
|
|
46
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
47
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
48
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
49
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
50
|
-
* const permission = base.getPermission();
|
|
51
|
-
* permission.setBasePermission({ createTable: true });
|
|
52
|
-
* return permission.canCreateTable();
|
|
53
|
-
* } finally {
|
|
54
|
-
* univerAPI.disposeUnit(unitId);
|
|
55
|
-
* }
|
|
56
|
-
* })());
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
setBasePermission(permission: {
|
|
60
|
-
createTable?: boolean;
|
|
61
|
-
}): void;
|
|
62
|
-
/**
|
|
63
|
-
* Set table-level permissions.
|
|
64
|
-
*
|
|
65
|
-
* Use this for permissions that affect table operations or all records,
|
|
66
|
-
* fields, and views under a table.
|
|
67
|
-
*
|
|
68
|
-
* @param tableId Target table id.
|
|
69
|
-
* @param permission Table permission patch, such as `delete`,
|
|
70
|
-
* `createField`, `createRecord`, or view management flags.
|
|
71
|
-
* @example
|
|
72
|
-
* ```ts
|
|
73
|
-
* permission.setTablePermission('tasks', { createRecord: false });
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* @example Browser console
|
|
77
|
-
* ```ts
|
|
78
|
-
* console.log((() => {
|
|
79
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
80
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
81
|
-
* try {
|
|
82
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
83
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
84
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
85
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
86
|
-
* const permission = base.getPermission();
|
|
87
|
-
* permission.setTablePermission(table.getId(), { createRecord: true });
|
|
88
|
-
* return permission.canCreateRecord(table.getId());
|
|
89
|
-
* } finally {
|
|
90
|
-
* univerAPI.disposeUnit(unitId);
|
|
91
|
-
* }
|
|
92
|
-
* })());
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
setTablePermission(tableId: string, permission: BaseTablePermission): void;
|
|
96
|
-
/**
|
|
97
|
-
* Set field-level permissions.
|
|
98
|
-
*
|
|
99
|
-
* Field permissions are checked by field commands and by cell editing for
|
|
100
|
-
* the target field.
|
|
101
|
-
*
|
|
102
|
-
* @param tableId Target table id.
|
|
103
|
-
* @param fieldId Target field id.
|
|
104
|
-
* @param permission Field permission patch, such as edit/delete flags.
|
|
105
|
-
* @example
|
|
106
|
-
* ```ts
|
|
107
|
-
* permission.setFieldPermission('tasks', 'status', { edit: false });
|
|
108
|
-
* ```
|
|
109
|
-
*
|
|
110
|
-
* @example Browser console
|
|
111
|
-
* ```ts
|
|
112
|
-
* console.log((() => {
|
|
113
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
114
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
115
|
-
* try {
|
|
116
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
117
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
118
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
119
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
120
|
-
* const permission = base.getPermission();
|
|
121
|
-
* permission.setFieldPermission(table.getId(), field.getId(), { edit: true });
|
|
122
|
-
* return permission.canEditField(table.getId(), field.getId());
|
|
123
|
-
* } finally {
|
|
124
|
-
* univerAPI.disposeUnit(unitId);
|
|
125
|
-
* }
|
|
126
|
-
* })());
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
setFieldPermission(tableId: string, fieldId: string, permission: BaseFieldPermission): void;
|
|
130
|
-
/**
|
|
131
|
-
* Set record-level permissions.
|
|
132
|
-
*
|
|
133
|
-
* Record permissions are checked for record-specific operations such as
|
|
134
|
-
* delete and cell edits on that row.
|
|
135
|
-
*
|
|
136
|
-
* @param tableId Target table id.
|
|
137
|
-
* @param recordId Target record id.
|
|
138
|
-
* @param permission Record permission patch, such as delete/edit flags.
|
|
139
|
-
* @example
|
|
140
|
-
* ```ts
|
|
141
|
-
* permission.setRecordPermission('tasks', 'task-1', { delete: false });
|
|
142
|
-
* ```
|
|
143
|
-
*
|
|
144
|
-
* @example Browser console
|
|
145
|
-
* ```ts
|
|
146
|
-
* console.log((() => {
|
|
147
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
148
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
149
|
-
* try {
|
|
150
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
151
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
152
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
153
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
154
|
-
* const permission = base.getPermission();
|
|
155
|
-
* permission.setRecordPermission(table.getId(), record.getId(), { edit: true });
|
|
156
|
-
* return permission.canEditCell(table.getId(), record.getId(), field.getId());
|
|
157
|
-
* } finally {
|
|
158
|
-
* univerAPI.disposeUnit(unitId);
|
|
159
|
-
* }
|
|
160
|
-
* })());
|
|
161
|
-
* ```
|
|
162
|
-
*/
|
|
163
|
-
setRecordPermission(tableId: string, recordId: string, permission: BaseRecordPermission): void;
|
|
164
|
-
/**
|
|
165
|
-
* Clear Base-level permission overrides.
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
* ```ts
|
|
169
|
-
* permission.clearBasePermission();
|
|
170
|
-
* ```
|
|
171
|
-
*
|
|
172
|
-
* @example Browser console
|
|
173
|
-
* ```ts
|
|
174
|
-
* console.log((() => {
|
|
175
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
176
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
177
|
-
* try {
|
|
178
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
179
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
180
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
181
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
182
|
-
* const permission = base.getPermission();
|
|
183
|
-
* permission.setBasePermission({ createTable: false });
|
|
184
|
-
* permission.clearBasePermission();
|
|
185
|
-
* return permission.canCreateTable();
|
|
186
|
-
* } finally {
|
|
187
|
-
* univerAPI.disposeUnit(unitId);
|
|
188
|
-
* }
|
|
189
|
-
* })());
|
|
190
|
-
* ```
|
|
191
|
-
*/
|
|
192
|
-
clearBasePermission(): void;
|
|
193
|
-
/**
|
|
194
|
-
* Clear permission overrides for one table.
|
|
195
|
-
*
|
|
196
|
-
* @param tableId Target table id.
|
|
197
|
-
* @example
|
|
198
|
-
* ```ts
|
|
199
|
-
* permission.clearTablePermission('tasks');
|
|
200
|
-
* ```
|
|
201
|
-
*
|
|
202
|
-
* @example Browser console
|
|
203
|
-
* ```ts
|
|
204
|
-
* console.log((() => {
|
|
205
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
206
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
207
|
-
* try {
|
|
208
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
209
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
210
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
211
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
212
|
-
* const permission = base.getPermission();
|
|
213
|
-
* permission.setTablePermission(table.getId(), { createRecord: false });
|
|
214
|
-
* permission.clearTablePermission(table.getId());
|
|
215
|
-
* return permission.canCreateRecord(table.getId());
|
|
216
|
-
* } finally {
|
|
217
|
-
* univerAPI.disposeUnit(unitId);
|
|
218
|
-
* }
|
|
219
|
-
* })());
|
|
220
|
-
* ```
|
|
221
|
-
*/
|
|
222
|
-
clearTablePermission(tableId: string): void;
|
|
223
|
-
/**
|
|
224
|
-
* Clear permission overrides for one field.
|
|
225
|
-
*
|
|
226
|
-
* @param tableId Target table id.
|
|
227
|
-
* @param fieldId Target field id.
|
|
228
|
-
* @example
|
|
229
|
-
* ```ts
|
|
230
|
-
* permission.clearFieldPermission('tasks', 'status');
|
|
231
|
-
* ```
|
|
232
|
-
*
|
|
233
|
-
* @example Browser console
|
|
234
|
-
* ```ts
|
|
235
|
-
* console.log((() => {
|
|
236
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
237
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
238
|
-
* try {
|
|
239
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
240
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
241
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
242
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
243
|
-
* const permission = base.getPermission();
|
|
244
|
-
* permission.setFieldPermission(table.getId(), field.getId(), { edit: false });
|
|
245
|
-
* permission.clearFieldPermission(table.getId(), field.getId());
|
|
246
|
-
* return permission.canEditField(table.getId(), field.getId());
|
|
247
|
-
* } finally {
|
|
248
|
-
* univerAPI.disposeUnit(unitId);
|
|
249
|
-
* }
|
|
250
|
-
* })());
|
|
251
|
-
* ```
|
|
252
|
-
*/
|
|
253
|
-
clearFieldPermission(tableId: string, fieldId: string): void;
|
|
254
|
-
/**
|
|
255
|
-
* Clear permission overrides for one record.
|
|
256
|
-
*
|
|
257
|
-
* @param tableId Target table id.
|
|
258
|
-
* @param recordId Target record id.
|
|
259
|
-
* @example
|
|
260
|
-
* ```ts
|
|
261
|
-
* permission.clearRecordPermission('tasks', 'task-1');
|
|
262
|
-
* ```
|
|
263
|
-
*
|
|
264
|
-
* @example Browser console
|
|
265
|
-
* ```ts
|
|
266
|
-
* console.log((() => {
|
|
267
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
268
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
269
|
-
* try {
|
|
270
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
271
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
272
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
273
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
274
|
-
* const permission = base.getPermission();
|
|
275
|
-
* permission.setRecordPermission(table.getId(), record.getId(), { edit: false });
|
|
276
|
-
* permission.clearRecordPermission(table.getId(), record.getId());
|
|
277
|
-
* return permission.canEditCell(table.getId(), record.getId(), field.getId());
|
|
278
|
-
* } finally {
|
|
279
|
-
* univerAPI.disposeUnit(unitId);
|
|
280
|
-
* }
|
|
281
|
-
* })());
|
|
282
|
-
* ```
|
|
283
|
-
*/
|
|
284
|
-
clearRecordPermission(tableId: string, recordId: string): void;
|
|
285
|
-
/**
|
|
286
|
-
* Check whether the Base can create tables.
|
|
287
|
-
* @returns `true` when table creation is allowed.
|
|
288
|
-
* @example
|
|
289
|
-
* ```ts
|
|
290
|
-
* if (permission.canCreateTable()) base.createTable({ name: 'Tasks' });
|
|
291
|
-
* ```
|
|
292
|
-
*
|
|
293
|
-
* @example Browser console
|
|
294
|
-
* ```ts
|
|
295
|
-
* console.log((() => {
|
|
296
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
297
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
298
|
-
* try {
|
|
299
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
300
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
301
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
302
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
303
|
-
* return base.getPermission().canCreateTable();
|
|
304
|
-
* } finally {
|
|
305
|
-
* univerAPI.disposeUnit(unitId);
|
|
306
|
-
* }
|
|
307
|
-
* })());
|
|
308
|
-
* ```
|
|
309
|
-
*/
|
|
310
|
-
canCreateTable(): boolean;
|
|
311
|
-
/**
|
|
312
|
-
* Check whether a table can be deleted.
|
|
313
|
-
* @param tableId Target table id.
|
|
314
|
-
* @returns `true` when table deletion is allowed.
|
|
315
|
-
* @example
|
|
316
|
-
* ```ts
|
|
317
|
-
* console.log(permission.canDeleteTable('tasks'));
|
|
318
|
-
* ```
|
|
319
|
-
*
|
|
320
|
-
* @example Browser console
|
|
321
|
-
* ```ts
|
|
322
|
-
* console.log((() => {
|
|
323
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
324
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
325
|
-
* try {
|
|
326
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
327
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
328
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
329
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
330
|
-
* return base.getPermission().canDeleteTable(table.getId());
|
|
331
|
-
* } finally {
|
|
332
|
-
* univerAPI.disposeUnit(unitId);
|
|
333
|
-
* }
|
|
334
|
-
* })());
|
|
335
|
-
* ```
|
|
336
|
-
*/
|
|
337
|
-
canDeleteTable(tableId: string): boolean;
|
|
338
|
-
/**
|
|
339
|
-
* Check whether fields can be created in a table.
|
|
340
|
-
* @param tableId Target table id.
|
|
341
|
-
* @returns `true` when field creation is allowed.
|
|
342
|
-
* @example
|
|
343
|
-
* ```ts
|
|
344
|
-
* console.log(permission.canCreateField('tasks'));
|
|
345
|
-
* ```
|
|
346
|
-
*
|
|
347
|
-
* @example Browser console
|
|
348
|
-
* ```ts
|
|
349
|
-
* console.log((() => {
|
|
350
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
351
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
352
|
-
* try {
|
|
353
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
354
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
355
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
356
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
357
|
-
* return base.getPermission().canCreateField(table.getId());
|
|
358
|
-
* } finally {
|
|
359
|
-
* univerAPI.disposeUnit(unitId);
|
|
360
|
-
* }
|
|
361
|
-
* })());
|
|
362
|
-
* ```
|
|
363
|
-
*/
|
|
364
|
-
canCreateField(tableId: string): boolean;
|
|
365
|
-
/**
|
|
366
|
-
* Check whether a field can be edited.
|
|
367
|
-
* @param tableId Target table id.
|
|
368
|
-
* @param fieldId Target field id.
|
|
369
|
-
* @returns `true` when field metadata edits are allowed.
|
|
370
|
-
* @example
|
|
371
|
-
* ```ts
|
|
372
|
-
* console.log(permission.canEditField('tasks', 'status'));
|
|
373
|
-
* ```
|
|
374
|
-
*
|
|
375
|
-
* @example Browser console
|
|
376
|
-
* ```ts
|
|
377
|
-
* console.log((() => {
|
|
378
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
379
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
380
|
-
* try {
|
|
381
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
382
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
383
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
384
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
385
|
-
* return base.getPermission().canEditField(table.getId(), field.getId());
|
|
386
|
-
* } finally {
|
|
387
|
-
* univerAPI.disposeUnit(unitId);
|
|
388
|
-
* }
|
|
389
|
-
* })());
|
|
390
|
-
* ```
|
|
391
|
-
*/
|
|
392
|
-
canEditField(tableId: string, fieldId: string): boolean;
|
|
393
|
-
/**
|
|
394
|
-
* Check whether a field can be deleted.
|
|
395
|
-
* @param tableId Target table id.
|
|
396
|
-
* @param fieldId Target field id.
|
|
397
|
-
* @returns `true` when field deletion is allowed.
|
|
398
|
-
* @example
|
|
399
|
-
* ```ts
|
|
400
|
-
* console.log(permission.canDeleteField('tasks', 'status'));
|
|
401
|
-
* ```
|
|
402
|
-
*
|
|
403
|
-
* @example Browser console
|
|
404
|
-
* ```ts
|
|
405
|
-
* console.log((() => {
|
|
406
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
407
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
408
|
-
* try {
|
|
409
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
410
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
411
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
412
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
413
|
-
* return base.getPermission().canDeleteField(table.getId(), field.getId());
|
|
414
|
-
* } finally {
|
|
415
|
-
* univerAPI.disposeUnit(unitId);
|
|
416
|
-
* }
|
|
417
|
-
* })());
|
|
418
|
-
* ```
|
|
419
|
-
*/
|
|
420
|
-
canDeleteField(tableId: string, fieldId: string): boolean;
|
|
421
|
-
/**
|
|
422
|
-
* Check whether records can be created in a table.
|
|
423
|
-
* @param tableId Target table id.
|
|
424
|
-
* @returns `true` when record creation is allowed.
|
|
425
|
-
* @example
|
|
426
|
-
* ```ts
|
|
427
|
-
* console.log(permission.canCreateRecord('tasks'));
|
|
428
|
-
* ```
|
|
429
|
-
*
|
|
430
|
-
* @example Browser console
|
|
431
|
-
* ```ts
|
|
432
|
-
* console.log((() => {
|
|
433
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
434
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
435
|
-
* try {
|
|
436
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
437
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
438
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
439
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
440
|
-
* return base.getPermission().canCreateRecord(table.getId());
|
|
441
|
-
* } finally {
|
|
442
|
-
* univerAPI.disposeUnit(unitId);
|
|
443
|
-
* }
|
|
444
|
-
* })());
|
|
445
|
-
* ```
|
|
446
|
-
*/
|
|
447
|
-
canCreateRecord(tableId: string): boolean;
|
|
448
|
-
/**
|
|
449
|
-
* Check whether a record can be deleted.
|
|
450
|
-
* @param tableId Target table id.
|
|
451
|
-
* @param recordId Target record id.
|
|
452
|
-
* @returns `true` when record deletion is allowed.
|
|
453
|
-
* @example
|
|
454
|
-
* ```ts
|
|
455
|
-
* console.log(permission.canDeleteRecord('tasks', 'task-1'));
|
|
456
|
-
* ```
|
|
457
|
-
*
|
|
458
|
-
* @example Browser console
|
|
459
|
-
* ```ts
|
|
460
|
-
* console.log((() => {
|
|
461
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
462
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
463
|
-
* try {
|
|
464
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
465
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
466
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
467
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
468
|
-
* return base.getPermission().canDeleteRecord(table.getId(), record.getId());
|
|
469
|
-
* } finally {
|
|
470
|
-
* univerAPI.disposeUnit(unitId);
|
|
471
|
-
* }
|
|
472
|
-
* })());
|
|
473
|
-
* ```
|
|
474
|
-
*/
|
|
475
|
-
canDeleteRecord(tableId: string, recordId: string): boolean;
|
|
476
|
-
/**
|
|
477
|
-
* Check whether one cell can be edited.
|
|
478
|
-
*
|
|
479
|
-
* The effective result combines table, field, record, and readonly-style
|
|
480
|
-
* restrictions in the permission service.
|
|
481
|
-
*
|
|
482
|
-
* @param tableId Target table id.
|
|
483
|
-
* @param recordId Target record id.
|
|
484
|
-
* @param fieldId Target field id.
|
|
485
|
-
* @returns `true` when the cell edit is allowed.
|
|
486
|
-
* @example
|
|
487
|
-
* ```ts
|
|
488
|
-
* if (permission.canEditCell('tasks', 'task-1', 'status')) {
|
|
489
|
-
* table.setCellValue('task-1', 'status', 'done');
|
|
490
|
-
* }
|
|
491
|
-
* ```
|
|
492
|
-
*
|
|
493
|
-
* @example Browser console
|
|
494
|
-
* ```ts
|
|
495
|
-
* console.log((() => {
|
|
496
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
497
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
498
|
-
* try {
|
|
499
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
500
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
501
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
502
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
503
|
-
* return base.getPermission().canEditCell(table.getId(), record.getId(), field.getId());
|
|
504
|
-
* } finally {
|
|
505
|
-
* univerAPI.disposeUnit(unitId);
|
|
506
|
-
* }
|
|
507
|
-
* })());
|
|
508
|
-
* ```
|
|
509
|
-
*/
|
|
510
|
-
canEditCell(tableId: string, recordId: string, fieldId: string): boolean;
|
|
511
|
-
/**
|
|
512
|
-
* Check whether one view can be managed.
|
|
513
|
-
* @param tableId Target table id.
|
|
514
|
-
* @param viewId Target view id.
|
|
515
|
-
* @returns `true` when view configuration, ordering, or deletion is allowed.
|
|
516
|
-
* @example
|
|
517
|
-
* ```ts
|
|
518
|
-
* console.log(permission.canManageView('tasks', 'grid-main'));
|
|
519
|
-
* ```
|
|
520
|
-
*
|
|
521
|
-
* @example Browser console
|
|
522
|
-
* ```ts
|
|
523
|
-
* console.log((() => {
|
|
524
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
525
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
526
|
-
* try {
|
|
527
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
528
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
529
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
530
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
531
|
-
* return base.getPermission().canManageView(table.getId(), view.getId());
|
|
532
|
-
* } finally {
|
|
533
|
-
* univerAPI.disposeUnit(unitId);
|
|
534
|
-
* }
|
|
535
|
-
* })());
|
|
536
|
-
* ```
|
|
537
|
-
*/
|
|
538
|
-
canManageView(tableId: string, viewId: string): boolean;
|
|
539
|
-
/**
|
|
540
|
-
* Get the current permission snapshot.
|
|
541
|
-
*
|
|
542
|
-
* Use this at the persistence boundary if Base-local permission overrides
|
|
543
|
-
* are stored with the server-side Base model.
|
|
544
|
-
*
|
|
545
|
-
* @returns Base permission snapshot.
|
|
546
|
-
* @example
|
|
547
|
-
* ```ts
|
|
548
|
-
* await savePermissionSnapshot(base.getId(), permission.getSnapshot());
|
|
549
|
-
* ```
|
|
550
|
-
*
|
|
551
|
-
* @example Browser console
|
|
552
|
-
* ```ts
|
|
553
|
-
* console.log((() => {
|
|
554
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
555
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
556
|
-
* try {
|
|
557
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
558
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
559
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
560
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
561
|
-
* return base.getPermission().getSnapshot();
|
|
562
|
-
* } finally {
|
|
563
|
-
* univerAPI.disposeUnit(unitId);
|
|
564
|
-
* }
|
|
565
|
-
* })());
|
|
566
|
-
* ```
|
|
567
|
-
*/
|
|
568
|
-
getSnapshot(): BasePermissionSnapshot;
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* Table-scoped permission facade returned by `table.getPermission()`.
|
|
572
|
-
*
|
|
573
|
-
* It is a convenience wrapper around `FBasePermission` for callers that already
|
|
574
|
-
* operate inside one table and do not want to pass `tableId` repeatedly.
|
|
575
|
-
*/
|
|
576
|
-
export declare class FTablePermission {
|
|
577
|
-
private readonly _tableId;
|
|
578
|
-
private readonly _permissionService;
|
|
579
|
-
constructor(_tableId: string, _permissionService: IBasePermissionService);
|
|
580
|
-
/**
|
|
581
|
-
* Set permission overrides for this table.
|
|
582
|
-
* @param permission Table permission patch.
|
|
583
|
-
* @example
|
|
584
|
-
* ```ts
|
|
585
|
-
* table.getPermission().setPermission({ createRecord: false });
|
|
586
|
-
* ```
|
|
587
|
-
*
|
|
588
|
-
* @example Browser console
|
|
589
|
-
* ```ts
|
|
590
|
-
* console.log((() => {
|
|
591
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
592
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
593
|
-
* try {
|
|
594
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
595
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
596
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
597
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
598
|
-
* const permission = table.getPermission();
|
|
599
|
-
* permission.setPermission({ createRecord: true });
|
|
600
|
-
* return permission.canCreateRecord();
|
|
601
|
-
* } finally {
|
|
602
|
-
* univerAPI.disposeUnit(unitId);
|
|
603
|
-
* }
|
|
604
|
-
* })());
|
|
605
|
-
* ```
|
|
606
|
-
*/
|
|
607
|
-
setPermission(permission: BaseTablePermission): void;
|
|
608
|
-
/**
|
|
609
|
-
* Clear permission overrides for this table.
|
|
610
|
-
* @example
|
|
611
|
-
* ```ts
|
|
612
|
-
* table.getPermission().clearPermission();
|
|
613
|
-
* ```
|
|
614
|
-
*
|
|
615
|
-
* @example Browser console
|
|
616
|
-
* ```ts
|
|
617
|
-
* console.log((() => {
|
|
618
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
619
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
620
|
-
* try {
|
|
621
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
622
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
623
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
624
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
625
|
-
* const permission = table.getPermission();
|
|
626
|
-
* permission.setPermission({ createRecord: false });
|
|
627
|
-
* permission.clearPermission();
|
|
628
|
-
* return permission.canCreateRecord();
|
|
629
|
-
* } finally {
|
|
630
|
-
* univerAPI.disposeUnit(unitId);
|
|
631
|
-
* }
|
|
632
|
-
* })());
|
|
633
|
-
* ```
|
|
634
|
-
*/
|
|
635
|
-
clearPermission(): void;
|
|
636
|
-
/**
|
|
637
|
-
* Check whether this table can be deleted.
|
|
638
|
-
* @returns `true` when table deletion is allowed.
|
|
639
|
-
*
|
|
640
|
-
* @example Browser console
|
|
641
|
-
* ```ts
|
|
642
|
-
* console.log((() => {
|
|
643
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
644
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
645
|
-
* try {
|
|
646
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
647
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
648
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
649
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
650
|
-
* return table.getPermission().canDeleteTable();
|
|
651
|
-
* } finally {
|
|
652
|
-
* univerAPI.disposeUnit(unitId);
|
|
653
|
-
* }
|
|
654
|
-
* })());
|
|
655
|
-
* ```
|
|
656
|
-
*/
|
|
657
|
-
canDeleteTable(): boolean;
|
|
658
|
-
/**
|
|
659
|
-
* Check whether fields can be created in this table.
|
|
660
|
-
* @returns `true` when field creation is allowed.
|
|
661
|
-
*
|
|
662
|
-
* @example Browser console
|
|
663
|
-
* ```ts
|
|
664
|
-
* console.log((() => {
|
|
665
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
666
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
667
|
-
* try {
|
|
668
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
669
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
670
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
671
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
672
|
-
* return table.getPermission().canCreateField();
|
|
673
|
-
* } finally {
|
|
674
|
-
* univerAPI.disposeUnit(unitId);
|
|
675
|
-
* }
|
|
676
|
-
* })());
|
|
677
|
-
* ```
|
|
678
|
-
*/
|
|
679
|
-
canCreateField(): boolean;
|
|
680
|
-
/**
|
|
681
|
-
* Check whether records can be created in this table.
|
|
682
|
-
* @returns `true` when record creation is allowed.
|
|
683
|
-
*
|
|
684
|
-
* @example Browser console
|
|
685
|
-
* ```ts
|
|
686
|
-
* console.log((() => {
|
|
687
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
688
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
689
|
-
* try {
|
|
690
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
691
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
692
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
693
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
694
|
-
* return table.getPermission().canCreateRecord();
|
|
695
|
-
* } finally {
|
|
696
|
-
* univerAPI.disposeUnit(unitId);
|
|
697
|
-
* }
|
|
698
|
-
* })());
|
|
699
|
-
* ```
|
|
700
|
-
*/
|
|
701
|
-
canCreateRecord(): boolean;
|
|
702
|
-
/**
|
|
703
|
-
* Check whether a view in this table can be managed.
|
|
704
|
-
* @param viewId Target view id.
|
|
705
|
-
* @returns `true` when view management is allowed.
|
|
706
|
-
*
|
|
707
|
-
* @example Browser console
|
|
708
|
-
* ```ts
|
|
709
|
-
* console.log((() => {
|
|
710
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
711
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
712
|
-
* try {
|
|
713
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
714
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
715
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
716
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
717
|
-
* return table.getPermission().canManageView(view.getId());
|
|
718
|
-
* } finally {
|
|
719
|
-
* univerAPI.disposeUnit(unitId);
|
|
720
|
-
* }
|
|
721
|
-
* })());
|
|
722
|
-
* ```
|
|
723
|
-
*/
|
|
724
|
-
canManageView(viewId: string): boolean;
|
|
725
|
-
/**
|
|
726
|
-
* Check whether one cell in this table can be edited.
|
|
727
|
-
* @param recordId Target record id.
|
|
728
|
-
* @param fieldId Target field id.
|
|
729
|
-
* @returns `true` when the cell edit is allowed.
|
|
730
|
-
*
|
|
731
|
-
* @example Browser console
|
|
732
|
-
* ```ts
|
|
733
|
-
* console.log((() => {
|
|
734
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
735
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
736
|
-
* try {
|
|
737
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
738
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
739
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
740
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
741
|
-
* return table.getPermission().canEditCell(record.getId(), field.getId());
|
|
742
|
-
* } finally {
|
|
743
|
-
* univerAPI.disposeUnit(unitId);
|
|
744
|
-
* }
|
|
745
|
-
* })());
|
|
746
|
-
* ```
|
|
747
|
-
*/
|
|
748
|
-
canEditCell(recordId: string, fieldId: string): boolean;
|
|
749
|
-
}
|