@yudaocode/univer-bases 0.0.0-stage → 1.6.218

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.
@@ -0,0 +1,140 @@
1
+ import { Injector, ICommandService, IUniverInstanceService, ICreateUnitOptions } from '@univerjs/core';
2
+ import { BaseUnitModel, IBaseUnitData, IBaseTable, IBaseField, BaseFieldType, IBaseFieldConfig, BaseCellValue, BaseViewType, UpdateBaseViewCommand, IBaseViewQueryOverrides, IBaseViewQueryResult, IBaseGanttLayoutResult, IBaseDashboardWidget, IBaseDashboardWidgetResult, IBaseIoAdapter } from '@yudaocode/univer-bases';
3
+ import { FUniver } from '@univerjs/core/facade';
4
+
5
+ declare class FBase {
6
+ private readonly _baseModel;
7
+ private readonly _injector;
8
+ private readonly _commandService;
9
+ private readonly _instanceService;
10
+ constructor(_baseModel: BaseUnitModel, _injector: Injector, _commandService: ICommandService, _instanceService: IUniverInstanceService);
11
+ getId(): string;
12
+ getModel(): BaseUnitModel;
13
+ getName(): string;
14
+ setName(name: string): void;
15
+ getSnapshot(): IBaseUnitData;
16
+ loadSnapshot(snapshot: IBaseUnitData): boolean;
17
+ getTables(): IBaseTable[];
18
+ getTable(tableId: string): IBaseTable | undefined;
19
+ addTable(params: {
20
+ tableId?: string;
21
+ name?: string;
22
+ description?: string;
23
+ fields?: IBaseField[];
24
+ makeActive?: boolean;
25
+ }): string | null;
26
+ updateTable(tableId: string, patch: {
27
+ name?: string;
28
+ description?: string;
29
+ icon?: string;
30
+ }): boolean;
31
+ deleteTable(tableId: string): boolean;
32
+ setActiveTable(tableId: string, viewId?: string): boolean;
33
+ addField(params: {
34
+ tableId?: string;
35
+ fieldId?: string;
36
+ name: string;
37
+ type: BaseFieldType;
38
+ width?: number;
39
+ required?: boolean;
40
+ config?: IBaseFieldConfig;
41
+ createSymmetric?: boolean;
42
+ symmetricFieldName?: string;
43
+ }): string | null;
44
+ updateField(fieldId: string, patch: Partial<Omit<IBaseField, 'id'>>, tableId?: string): boolean;
45
+ deleteField(fieldId: string, tableId?: string): boolean;
46
+ addRecord(cells?: Record<string, BaseCellValue>, options?: {
47
+ tableId?: string;
48
+ recordId?: string;
49
+ createdBy?: string;
50
+ }): string | null;
51
+ updateRecord(recordId: string, cells: Record<string, BaseCellValue>, tableId?: string): boolean;
52
+ deleteRecords(recordIds: string[], tableId?: string): boolean;
53
+ addView(params: {
54
+ tableId?: string;
55
+ viewId?: string;
56
+ name?: string;
57
+ type: BaseViewType;
58
+ makeActive?: boolean;
59
+ }): string | null;
60
+ updateView(patch: Parameters<typeof UpdateBaseViewCommand.handler>[1] extends {
61
+ patch: infer P;
62
+ } ? P : never, options?: {
63
+ tableId?: string;
64
+ viewId?: string;
65
+ }): boolean;
66
+ setActiveView(viewId: string, tableId?: string): boolean;
67
+ queryView(tableId?: string, viewId?: string, overrides?: IBaseViewQueryOverrides): IBaseViewQueryResult;
68
+ computeGanttTasks(tableId?: string, viewId?: string): IBaseGanttLayoutResult;
69
+ computeDashboardWidget(widget: IBaseDashboardWidget): IBaseDashboardWidgetResult;
70
+ submitForm(values: Record<string, BaseCellValue>, options?: {
71
+ tableId?: string;
72
+ viewId?: string;
73
+ submittedBy?: string;
74
+ }): string | null;
75
+ exportXlsx(options?: {
76
+ tableIds?: string[];
77
+ }): Uint8Array;
78
+ exportCsv(tableId?: string, options?: {
79
+ delimiter?: ',' | '\t';
80
+ viewId?: string;
81
+ }): string;
82
+ undo(): boolean;
83
+ redo(): boolean;
84
+ }
85
+
86
+ interface IFUniverBasesMixin {
87
+ /**
88
+ * Creates a new `UNIVER_BASE` unit and returns its `FBase` facade instance.
89
+ */
90
+ createBase(data?: Partial<IBaseUnitData>, options?: ICreateUnitOptions): FBase;
91
+ /**
92
+ * Returns the currently active `FBase` facade instance, or `null` if none is active.
93
+ */
94
+ getActiveBase(): FBase | null;
95
+ /**
96
+ * Returns the `FBase` facade instance for the specified `unitId`, or `null` if not found.
97
+ */
98
+ getBase(unitId: string): FBase | null;
99
+ /**
100
+ * Imports `.xlsx` bytes directly into a newly mounted `UNIVER_BASE` unit and returns its `FBase` facade.
101
+ */
102
+ importBaseXlsx(bytes: Uint8Array, options?: {
103
+ id?: string;
104
+ name?: string;
105
+ }, createOptions?: ICreateUnitOptions): FBase;
106
+ /**
107
+ * Exports the specified `unitIdOrBase` (or active `FBase` when omitted) to `.xlsx` bytes.
108
+ */
109
+ exportBaseXlsx(unitIdOrBase?: string | FBase, options?: {
110
+ tableIds?: string[];
111
+ }): Uint8Array;
112
+ /**
113
+ * Sets a custom pluggable Import / Export / Save IO adapter for Univer Bases.
114
+ */
115
+ setBaseIoAdapter(adapter: IBaseIoAdapter): void;
116
+ /**
117
+ * Gets the currently configured Univer Bases IO adapter.
118
+ */
119
+ getBaseIoAdapter(): IBaseIoAdapter;
120
+ }
121
+ declare class FUniverBasesMixin extends FUniver implements IFUniverBasesMixin {
122
+ createBase(data?: Partial<IBaseUnitData>, options?: ICreateUnitOptions): FBase;
123
+ getActiveBase(): FBase | null;
124
+ getBase(unitId: string): FBase | null;
125
+ importBaseXlsx(bytes: Uint8Array, options?: {
126
+ id?: string;
127
+ name?: string;
128
+ }, createOptions?: ICreateUnitOptions): FBase;
129
+ exportBaseXlsx(unitIdOrBase?: string | FBase, options?: {
130
+ tableIds?: string[];
131
+ }): Uint8Array;
132
+ setBaseIoAdapter(adapter: IBaseIoAdapter): void;
133
+ getBaseIoAdapter(): IBaseIoAdapter;
134
+ }
135
+ declare module '@univerjs/core/facade' {
136
+ interface FUniver extends IFUniverBasesMixin {
137
+ }
138
+ }
139
+
140
+ export { FBase, FUniverBasesMixin, type IFUniverBasesMixin };