@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type FBaseEmbedUnitFacadeMapAugmentation = never;
|
|
@@ -1,190 +1,63 @@
|
|
|
1
|
-
import type { IBaseSnapshot, ICreateUnitOptions
|
|
1
|
+
import type { IBaseSnapshot, ICreateUnitOptions } from '@univerjs/core';
|
|
2
2
|
import { FUniver } from '@univerjs/core/facade';
|
|
3
3
|
import { FBase } from './f-base';
|
|
4
4
|
export interface IFUniverBaseMixin {
|
|
5
|
-
createBase(snapshot: Partial<IBaseSnapshot>, options?: ICreateUnitOptions): FBase;
|
|
6
|
-
getActiveBase(): FBase | null;
|
|
7
|
-
getBase(baseId: string): FBase | null;
|
|
8
|
-
getBases(): FBase[];
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Facade API mixin for creating and retrieving Univer Base units.
|
|
12
|
-
*
|
|
13
|
-
* Import `@univerjs-pro/bases/facade` once before creating the facade API so the
|
|
14
|
-
* Base methods are mixed into `FUniver`.
|
|
15
|
-
*
|
|
16
|
-
* @example Run the complete quick-start spec in this repository
|
|
17
|
-
* ```sh
|
|
18
|
-
* cd /Users/lilin/Documents/GitHub/univer-pro-2 \
|
|
19
|
-
* && pnpm --filter @univerjs-pro/bases test -- src/facade/__tests__/quick-start.spec.ts
|
|
20
|
-
* ```
|
|
21
|
-
* @example Create a Base facade and save the snapshot
|
|
22
|
-
* ```ts
|
|
23
|
-
* import { Univer } from '@univerjs/core';
|
|
24
|
-
* import { FUniver } from '@univerjs/core/facade';
|
|
25
|
-
* import { UniverBasesPlugin } from '@univerjs-pro/bases';
|
|
26
|
-
* import { BaseEventName } from '@univerjs-pro/bases/facade';
|
|
27
|
-
*
|
|
28
|
-
* const univer = new Univer();
|
|
29
|
-
* univer.registerPlugin(UniverBasesPlugin);
|
|
30
|
-
*
|
|
31
|
-
* const univerAPI = FUniver.newAPI(univer);
|
|
32
|
-
* const base = univerAPI.createBase({
|
|
33
|
-
* id: 'base-demo',
|
|
34
|
-
* name: 'Agent Work Queue',
|
|
35
|
-
* schemaVersion: 1,
|
|
36
|
-
* createdAt: Date.now(),
|
|
37
|
-
* updatedAt: Date.now(),
|
|
38
|
-
* tables: {},
|
|
39
|
-
* tableOrder: [],
|
|
40
|
-
* });
|
|
41
|
-
* const table = base.createTable({ id: 'tasks', name: 'Tasks', primaryFieldName: 'Title' });
|
|
42
|
-
* const status = table.addField({
|
|
43
|
-
* id: 'status',
|
|
44
|
-
* name: 'Status',
|
|
45
|
-
* type: 'singleSelect',
|
|
46
|
-
* config: { options: [{ id: 'todo', name: 'Todo', color: 'blue' }, { id: 'done', name: 'Done', color: 'green' }] },
|
|
47
|
-
* defaultValue: 'todo',
|
|
48
|
-
* });
|
|
49
|
-
* const record = table.addRecord({
|
|
50
|
-
* id: 'task-1',
|
|
51
|
-
* values: { [table.getPrimaryFieldId()]: 'Write docs', [status.getId()]: 'todo' },
|
|
52
|
-
* });
|
|
53
|
-
* record.setValue(status.getId(), 'done');
|
|
54
|
-
*
|
|
55
|
-
* const disposable = base.addEvent(BaseEventName.RecordChanged, (event) => {
|
|
56
|
-
* console.log(event.type, event.recordIds);
|
|
57
|
-
* });
|
|
58
|
-
* disposable.dispose();
|
|
59
|
-
* console.log(JSON.stringify(base.save(), null, 2));
|
|
60
|
-
* univer.dispose();
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export declare class FUniverBaseMixin extends FUniver implements IFUniverBaseMixin {
|
|
64
|
-
_initialize(injector: Injector): void;
|
|
65
5
|
/**
|
|
66
|
-
* Create a
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* runtime facade used for command execution, events, permissions, undo/redo,
|
|
71
|
-
* and saving back to a snapshot.
|
|
72
|
-
*
|
|
73
|
-
* @param snapshot Partial Base snapshot used to initialize the Base.
|
|
74
|
-
* Provide `id`, `schemaVersion`, `tables`, and `tableOrder` when loading a
|
|
75
|
-
* persisted server snapshot. For a new empty Base, pass `tables: {}` and
|
|
76
|
-
* `tableOrder: []`. Missing optional fields are normalized by the Base data
|
|
77
|
-
* model.
|
|
78
|
-
* @param options Unit creation options. Use `{ makeCurrent: false }` when
|
|
79
|
-
* creating a disposable or background Base without changing the active Base.
|
|
80
|
-
* @returns The created Base facade. Call `base.save()` or
|
|
81
|
-
* `base.getSnapshot()` to get the persisted snapshot after runtime edits.
|
|
6
|
+
* Create a new Base unit with the given snapshot and options.
|
|
7
|
+
* @param {Partial<IBaseSnapshot>} snapshot The persisted Base model snapshot.
|
|
8
|
+
* @param {ICreateUnitOptions} [options] Options for creating the unit.
|
|
9
|
+
* @returns {FBase} The Base facade API instance.
|
|
82
10
|
* @example
|
|
83
11
|
* ```ts
|
|
84
|
-
* const
|
|
12
|
+
* const fBase = univerAPI.createBase({
|
|
85
13
|
* id: 'base-1',
|
|
86
|
-
* name: 'Roadmap'
|
|
87
|
-
* schemaVersion: 1,
|
|
88
|
-
* createdAt: Date.now(),
|
|
89
|
-
* updatedAt: Date.now(),
|
|
90
|
-
* tables: {},
|
|
91
|
-
* tableOrder: [],
|
|
14
|
+
* name: 'Roadmap'
|
|
92
15
|
* });
|
|
93
|
-
*
|
|
94
|
-
* ```
|
|
95
|
-
*
|
|
96
|
-
* @example Browser console
|
|
97
|
-
* ```ts
|
|
98
|
-
* console.log((() => {
|
|
99
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
100
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
101
|
-
* try {
|
|
102
|
-
* return { id: base.getId(), activeBaseId: univerAPI.getActiveBase()?.getId() ?? null };
|
|
103
|
-
* } finally {
|
|
104
|
-
* univerAPI.disposeUnit(unitId);
|
|
105
|
-
* }
|
|
106
|
-
* })());
|
|
16
|
+
* console.log(fBase);
|
|
107
17
|
* ```
|
|
108
18
|
*/
|
|
109
|
-
createBase(snapshot
|
|
19
|
+
createBase(snapshot?: Partial<IBaseSnapshot>, options?: ICreateUnitOptions): FBase;
|
|
110
20
|
/**
|
|
111
21
|
* Get the currently active Base unit.
|
|
112
|
-
*
|
|
113
|
-
* The active Base is the most recent current unit of type
|
|
114
|
-
* `UNIVER_BASE` in the Univer instance service. It is useful for shell
|
|
115
|
-
* integrations that should operate on the user's current Base without
|
|
116
|
-
* passing ids around.
|
|
117
|
-
*
|
|
118
|
-
* @returns The active Base facade, or `null` when no Base unit exists or no
|
|
119
|
-
* Base is active.
|
|
22
|
+
* @returns {FBase | null} The active Base facade, or `null` if no Base is active.
|
|
120
23
|
* @example
|
|
121
24
|
* ```ts
|
|
122
|
-
* const
|
|
123
|
-
*
|
|
124
|
-
* console.log(base.getId(), base.getName());
|
|
125
|
-
* }
|
|
126
|
-
* ```
|
|
127
|
-
*
|
|
128
|
-
* @example Browser console
|
|
129
|
-
* ```ts
|
|
130
|
-
* console.log(univerAPI.getActiveBase()?.getId() ?? null);
|
|
25
|
+
* const fBase = univerAPI.getActiveBase();
|
|
26
|
+
* console.log(fBase);
|
|
131
27
|
* ```
|
|
132
28
|
*/
|
|
133
29
|
getActiveBase(): FBase | null;
|
|
134
30
|
/**
|
|
135
31
|
* Get a Base unit by id.
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* operation from an external protocol request.
|
|
139
|
-
*
|
|
140
|
-
* @param baseId The persisted Base unit id.
|
|
141
|
-
* @returns The Base facade, or `null` if the id is missing or the unit is
|
|
142
|
-
* not a Base unit.
|
|
32
|
+
* @param {string} baseId The id of the Base unit to retrieve.
|
|
33
|
+
* @returns {FBase | null} The Base facade, or `null` if the unit does not exist or is not a Base unit.
|
|
143
34
|
* @example
|
|
144
35
|
* ```ts
|
|
145
|
-
* const
|
|
146
|
-
*
|
|
147
|
-
* ```
|
|
148
|
-
*
|
|
149
|
-
* @example Browser console
|
|
150
|
-
* ```ts
|
|
151
|
-
* console.log((() => {
|
|
152
|
-
* const base = univerAPI.getActiveBase();
|
|
153
|
-
* if (!base) throw new Error('No active Base.');
|
|
154
|
-
* return univerAPI.getBase(base.getId())?.getName() ?? null;
|
|
155
|
-
* })());
|
|
36
|
+
* const fBase = univerAPI.getBase('base-1');
|
|
37
|
+
* console.log(fBase);
|
|
156
38
|
* ```
|
|
157
39
|
*/
|
|
158
40
|
getBase(baseId: string): FBase | null;
|
|
159
41
|
/**
|
|
160
42
|
* Get all Base units in the current Univer instance.
|
|
161
|
-
*
|
|
162
|
-
* This is useful for dashboards, server-side snapshot export, or agent
|
|
163
|
-
* tools that need to inspect every loaded Base.
|
|
164
|
-
*
|
|
165
|
-
* @returns All Base facades in instance-service order.
|
|
43
|
+
* @returns {FBase[]} An array of Base facade instances.
|
|
166
44
|
* @example
|
|
167
45
|
* ```ts
|
|
168
|
-
* const
|
|
169
|
-
* const snapshots =
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* @example Browser console
|
|
173
|
-
* ```ts
|
|
174
|
-
* console.log(univerAPI.getBases().map((base) => ({ id: base.getId(), name: base.getName() })));
|
|
46
|
+
* const fBases = univerAPI.getBases();
|
|
47
|
+
* const snapshots = fBases.map((fBase) => fBase.save());
|
|
48
|
+
* console.log(snapshots);
|
|
175
49
|
* ```
|
|
176
50
|
*/
|
|
177
51
|
getBases(): FBase[];
|
|
178
|
-
|
|
52
|
+
}
|
|
53
|
+
export declare class FUniverBaseMixin extends FUniver implements IFUniverBaseMixin {
|
|
54
|
+
_initialize(): void;
|
|
55
|
+
createBase(snapshot?: Partial<IBaseSnapshot>, options?: ICreateUnitOptions): FBase;
|
|
56
|
+
getActiveBase(): FBase | null;
|
|
57
|
+
getBase(baseId: string): FBase | null;
|
|
58
|
+
getBases(): FBase[];
|
|
179
59
|
private _initBaseAfterEvents;
|
|
180
60
|
private _initBaseBeforeEvents;
|
|
181
|
-
private _resolveBaseCommandEvent;
|
|
182
|
-
private _resolveBaseBatchChanged;
|
|
183
|
-
private _resolveBeforeBaseTableCreate;
|
|
184
|
-
private _resolveBeforeBaseFieldCreate;
|
|
185
|
-
private _resolveBeforeBaseRecordCreate;
|
|
186
|
-
private _resolveBeforeBaseCellValueChange;
|
|
187
|
-
private _resolveBeforeBaseViewCreate;
|
|
188
61
|
}
|
|
189
62
|
declare module '@univerjs/core/facade' {
|
|
190
63
|
interface FUniver extends IFUniverBaseMixin {
|