@univerjs-pro/sheets-mcp 0.10.14 → 0.11.0
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/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/facade.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/controllers/config.schema.d.ts +2 -0
- package/lib/types/facade/f-range.d.ts +41 -0
- package/lib/types/facade/f-univer.d.ts +4 -7
- package/lib/types/facade/f-workbook.d.ts +30 -0
- package/lib/types/facade/f-worksheet.d.ts +39 -0
- package/lib/types/facade/index.d.ts +3 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/services/formula-analysis.service.d.ts +53 -0
- package/lib/types/tools/formula-utils.d.ts +1 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +11 -11
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const SHEET_MCP_PLUGIN_CONFIG_KEY = "sheet-mcp.config";
|
|
2
2
|
export declare const configSymbol: unique symbol;
|
|
3
3
|
export interface IUniverSheetMCPConfig {
|
|
4
|
+
/** Whether to enable worker mode */
|
|
5
|
+
enableWorker?: boolean;
|
|
4
6
|
}
|
|
5
7
|
export declare const defaultPluginConfig: IUniverSheetMCPConfig;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IFormulaUsage, IFormulaUsageAsA1 } from '@univerjs-pro/sheets-mcp';
|
|
2
|
+
import { FRange } from '@univerjs/sheets/facade';
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export interface IFRangeSheetsMCP {
|
|
7
|
+
/**
|
|
8
|
+
* Get all formula usages in the range
|
|
9
|
+
* @returns A promise that resolves to an array of formula usages
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const workbook = univerAPI.getActiveWorkbook()
|
|
14
|
+
* const sheet = workbook.getActiveSheet()
|
|
15
|
+
* const range = sheet.getRangeByA1('A1:C10')
|
|
16
|
+
* const usages = await range.getFormulaUsages();
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
getFormulaUsages(): Promise<IFormulaUsage[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Get all formula usages in the range in A1 notation
|
|
22
|
+
* @returns A promise that resolves to an array of formula usages in A1 notation
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const workbook = univerAPI.getActiveWorkbook()
|
|
27
|
+
* const sheet = workbook.getActiveSheet()
|
|
28
|
+
* const range = sheet.getRangeByA1('A1:C10')
|
|
29
|
+
* const usagesA1 = await range.getFormulaUsagesAsA1();
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
getFormulaUsagesAsA1(): Promise<IFormulaUsageAsA1[]>;
|
|
33
|
+
}
|
|
34
|
+
export declare class FRangeSheetsMCP extends FRange implements IFRangeSheetsMCP {
|
|
35
|
+
getFormulaUsages(): Promise<IFormulaUsage[]>;
|
|
36
|
+
getFormulaUsagesAsA1(): Promise<IFormulaUsageAsA1[]>;
|
|
37
|
+
}
|
|
38
|
+
declare module '@univerjs/sheets/facade' {
|
|
39
|
+
interface FRange extends IFRangeSheetsMCP {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IDataValidationError } from '@univerjs/sheets-data-validation/facade';
|
|
1
|
+
import { ILintErrorReport } from './f-workbook';
|
|
3
2
|
import { FUniver } from '@univerjs/core/facade';
|
|
4
3
|
import '@univerjs/sheets-formula/facade';
|
|
5
4
|
import '@univerjs/sheets-data-validation/facade';
|
|
6
|
-
interface ILintErrorReport {
|
|
7
|
-
formulaErrors: ISheetFormulaError[];
|
|
8
|
-
dataValidationErrors: IDataValidationError[];
|
|
9
|
-
}
|
|
10
5
|
/**
|
|
11
6
|
* @ignore
|
|
12
7
|
*/
|
|
13
8
|
export interface IFUniverLintMCP {
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated use {@link FWorkbookSheetsMCP.getLintErrors} instead.
|
|
11
|
+
*/
|
|
14
12
|
getLintErrors(): Promise<ILintErrorReport>;
|
|
15
13
|
}
|
|
16
14
|
export declare class FUniverLintMCPMixin extends FUniver implements IFUniverLintMCP {
|
|
@@ -20,4 +18,3 @@ declare module '@univerjs/core/facade' {
|
|
|
20
18
|
interface FUniver extends IFUniverLintMCP {
|
|
21
19
|
}
|
|
22
20
|
}
|
|
23
|
-
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ISheetFormulaError } from '@univerjs/engine-formula';
|
|
2
|
+
import { IDataValidationError } from '@univerjs/sheets-data-validation/facade';
|
|
3
|
+
import { FWorkbook } from '@univerjs/sheets/facade';
|
|
4
|
+
export interface ILintErrorReport {
|
|
5
|
+
formulaErrors: ISheetFormulaError[];
|
|
6
|
+
dataValidationErrors: IDataValidationError[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @ignore
|
|
10
|
+
*/
|
|
11
|
+
export interface IFWorkbookSheetsMCPMixin {
|
|
12
|
+
/**
|
|
13
|
+
* Get lint errors report including formula errors and data validation errors
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const workbook = univerAPI.getActiveWorkbook()
|
|
18
|
+
* const lintErrors = await workbook.getLintErrors();
|
|
19
|
+
* console.log(lintErrors.formulaErrors, lintErrors.dataValidationErrors);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
getLintErrors(): Promise<ILintErrorReport>;
|
|
23
|
+
}
|
|
24
|
+
export declare class FWorkbookSheetsMCPMixin extends FWorkbook implements IFWorkbookSheetsMCPMixin {
|
|
25
|
+
getLintErrors(): Promise<ILintErrorReport>;
|
|
26
|
+
}
|
|
27
|
+
declare module '@univerjs/sheets/facade' {
|
|
28
|
+
interface FWorkbook extends IFWorkbookSheetsMCPMixin {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IFormulaUsage, IFormulaUsageAsA1 } from '@univerjs-pro/sheets-mcp';
|
|
2
|
+
import { FWorksheet } from '@univerjs/sheets/facade';
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export interface IFWorksheetSheetsMCP {
|
|
7
|
+
/**
|
|
8
|
+
* Get all formula usages in the worksheet
|
|
9
|
+
* @returns A promise that resolves to an array of formula usages
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const workbook = univerAPI.getActiveWorkbook()
|
|
14
|
+
* const sheet = workbook.getActiveSheet()
|
|
15
|
+
* const usages = await sheet.getFormulaUsages();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
getFormulaUsages(): Promise<IFormulaUsage[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Get all formula usages in the worksheet in A1 notation
|
|
21
|
+
* @returns A promise that resolves to an array of formula usages in A1 notation
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const workbook = univerAPI.getActiveWorkbook()
|
|
26
|
+
* const sheet = workbook.getActiveSheet()
|
|
27
|
+
* const usagesA1 = await sheet.getFormulaUsagesAsA1();
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
getFormulaUsagesAsA1(): Promise<IFormulaUsageAsA1[]>;
|
|
31
|
+
}
|
|
32
|
+
export declare class FWorksheetSheetsMCP extends FWorksheet implements IFWorksheetSheetsMCP {
|
|
33
|
+
getFormulaUsages(): Promise<IFormulaUsage[]>;
|
|
34
|
+
getFormulaUsagesAsA1(): Promise<IFormulaUsageAsA1[]>;
|
|
35
|
+
}
|
|
36
|
+
declare module '@univerjs/sheets/facade' {
|
|
37
|
+
interface FWorksheet extends IFWorksheetSheetsMCP {
|
|
38
|
+
}
|
|
39
|
+
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ICellData, IRange, Nullable } from '@univerjs/core';
|
|
2
|
+
import { ICalculateFormulaService, LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for formula usage information
|
|
5
|
+
*/
|
|
6
|
+
export interface IFormulaUsage {
|
|
7
|
+
/**
|
|
8
|
+
* The formula's first occurrence location
|
|
9
|
+
*/
|
|
10
|
+
formula: string;
|
|
11
|
+
/**
|
|
12
|
+
* The formula's first occurrence cell range
|
|
13
|
+
*/
|
|
14
|
+
firstOccurrence: IRange;
|
|
15
|
+
/**
|
|
16
|
+
* The filled ranges of the formula, including the first occurrence
|
|
17
|
+
*/
|
|
18
|
+
filledRanges: IRange[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Interface for formula usage information in A1 notation
|
|
22
|
+
*/
|
|
23
|
+
export interface IFormulaUsageAsA1 {
|
|
24
|
+
/**
|
|
25
|
+
* The formula's first occurrence location
|
|
26
|
+
*/
|
|
27
|
+
formula: string;
|
|
28
|
+
/**
|
|
29
|
+
* The formula's first occurrence cell range in A1 notation
|
|
30
|
+
*/
|
|
31
|
+
firstOccurrence: string;
|
|
32
|
+
/**
|
|
33
|
+
* The filled ranges of the formula in A1 notation, including the first occurrence
|
|
34
|
+
*/
|
|
35
|
+
filledRanges: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function toA1(usage: IFormulaUsage): IFormulaUsageAsA1;
|
|
38
|
+
/**
|
|
39
|
+
* Convert rectangle coordinates to A1 notation
|
|
40
|
+
* @param param0 [r1, r2, c1, c2]
|
|
41
|
+
* @returns A1 notation string
|
|
42
|
+
*/
|
|
43
|
+
export declare function getA1Notation([r1, r2, c1, c2]: [number, number, number, number]): string;
|
|
44
|
+
export declare const FormulaUsageAnalyzerChannelName = "sheets.mcp.formula-usage-analyzer";
|
|
45
|
+
export declare const IFormulaUsageAnalyzer: import('@wendellhu/redi').IdentifierDecorator<FormulaUsageAnalyzer>;
|
|
46
|
+
export declare class FormulaUsageAnalyzer {
|
|
47
|
+
protected _formulaService: ICalculateFormulaService;
|
|
48
|
+
private _lexerTreeBuilder;
|
|
49
|
+
constructor(_formulaService: ICalculateFormulaService, _lexerTreeBuilder: LexerTreeBuilder);
|
|
50
|
+
getAllFormulaUsages(data: Nullable<ICellData>[][]): IFormulaUsage[];
|
|
51
|
+
getFormulaHash(formulaString: string, refOffsetX: number, refOffsetY: number, ignoreAbsolute?: boolean): string;
|
|
52
|
+
moveFormulaRefOffset(formula: string, refOffsetX: number, refOffsetY: number, ignoreAbsolute?: boolean): string;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractFormulas(univerAPI: any, sheets?: string[]): Promise<string>;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _0x5ce7(_0x5ef5c8,_0x9198c7){const _0x4278b5=_0x4278();return _0x5ce7=function(_0x5ce7aa,_0x24d94a){_0x5ce7aa=_0x5ce7aa-0x116;let _0x568ae2=_0x4278b5[_0x5ce7aa];return _0x568ae2;},_0x5ce7(_0x5ef5c8,_0x9198c7);}(function(_0x23cf83,_0x19d2f2){const _0x1dad50=_0x5ce7,_0x109dc3=_0x23cf83();while(!![]){try{const _0x260ae9=-parseInt(_0x1dad50(0x124))/0x1+-parseInt(_0x1dad50(0x120))/0x2*(-parseInt(_0x1dad50(0x142))/0x3)+-parseInt(_0x1dad50(0x12b))/0x4*(parseInt(_0x1dad50(0x116))/0x5)+parseInt(_0x1dad50(0x133))/0x6+parseInt(_0x1dad50(0x132))/0x7*(-parseInt(_0x1dad50(0x11b))/0x8)+parseInt(_0x1dad50(0x11f))/0x9+parseInt(_0x1dad50(0x135))/0xa;if(_0x260ae9===_0x19d2f2)break;else _0x109dc3['push'](_0x109dc3['shift']());}catch(_0x1568bd){_0x109dc3['push'](_0x109dc3['shift']());}}}(_0x4278,0xf40c8),function(_0x513cad,_0x55aa17){const _0x464f0e=_0x5ce7;typeof exports=='object'&&typeof module<'u'?_0x55aa17(require('@univerjs/core/facade'),require('@univerjs/sheets-formula/facade'),require('@univerjs/sheets-data-validation/facade'),require('@univerjs/sheets/facade'),require('@univerjs-pro/sheets-mcp'),require('@univerjs/core')):typeof define==_0x464f0e(0x125)&&define[_0x464f0e(0x13e)]?define([_0x464f0e(0x11c),_0x464f0e(0x119),_0x464f0e(0x137),'@univerjs/sheets/facade',_0x464f0e(0x130),_0x464f0e(0x118)],_0x55aa17):(_0x513cad=typeof globalThis<'u'?globalThis:_0x513cad||self,_0x55aa17(_0x513cad[_0x464f0e(0x146)],_0x513cad[_0x464f0e(0x11a)],_0x513cad['UniverSheetsDataValidationFacade'],_0x513cad[_0x464f0e(0x134)],_0x513cad['UniverProSheetsMcp'],_0x513cad[_0x464f0e(0x129)]));}(this,function(_0x52b74e,_0x564295,_0x55549b,_0x3fb9b8,_0x2be888,_0x4d0f64){'use strict';const _0x46c8ed=_0x5ce7;class _0x594f53 extends _0x52b74e['FUniver']{async[_0x46c8ed(0x13c)](){const _0x13fc03=_0x46c8ed;return this[_0x13fc03(0x121)]()[_0x13fc03(0x13c)]();}}_0x52b74e[_0x46c8ed(0x144)]['extend'](_0x594f53);class _0x1cbc33 extends _0x3fb9b8[_0x46c8ed(0x12d)]{async[_0x46c8ed(0x13c)](){const _0x113915=_0x46c8ed,_0xef3637=this[_0x113915(0x143)](),_0x3ef277=await this[_0x113915(0x128)]();return{'formulaErrors':_0xef3637,'dataValidationErrors':_0x3ef277};}}_0x3fb9b8[_0x46c8ed(0x12d)][_0x46c8ed(0x13a)](_0x1cbc33);class _0x3926dc extends _0x3fb9b8[_0x46c8ed(0x11e)]{async[_0x46c8ed(0x122)](){const _0x70627f=_0x46c8ed,_0x244b71=this[_0x70627f(0x11d)][_0x70627f(0x117)](_0x2be888[_0x70627f(0x138)]),_0x23655c=this[_0x70627f(0x141)](0x0,0x0,this['getMaxRows']()+0x1,this[_0x70627f(0x12f)]()+0x1)[_0x70627f(0x139)]();return await _0x244b71[_0x70627f(0x131)](_0x23655c);}async['getFormulaUsagesAsA1'](){const _0x21e323=_0x46c8ed;return(await this['getFormulaUsages']())[_0x21e323(0x12c)](_0x2be888[_0x21e323(0x127)]);}}_0x3fb9b8['FWorksheet'][_0x46c8ed(0x13a)](_0x3926dc);class _0x4576e3 extends _0x3fb9b8['FRange']{async[_0x46c8ed(0x122)](){const _0xeee94c=_0x46c8ed,_0x182c7d=this[_0xeee94c(0x11d)]['get'](_0x2be888['IFormulaUsageAnalyzer']),_0x24bb7b=(({startRow:_0x1e4680,endRow:_0x6946c,startColumn:_0x20af19,endColumn:_0xd05730})=>{const _0x343665=_0xeee94c,_0x4befe2=[];for(let _0x530615=_0x1e4680;_0x530615<=_0x6946c;_0x530615++){const _0x25b08c=[];for(let _0x5974b5=_0x20af19;_0x5974b5<=_0xd05730;_0x5974b5++)_0x25b08c[_0x343665(0x13b)](this['_worksheet']['getCellRaw'](_0x530615,_0x5974b5));_0x4befe2[_0x343665(0x13b)](_0x25b08c);}return _0x4befe2;})({'startRow':0x0,'endRow':this[_0xeee94c(0x13d)][_0xeee94c(0x13f)](),'startColumn':0x0,'endColumn':this[_0xeee94c(0x13d)]['getMaxColumns']()}),_0x3252e8=await _0x182c7d[_0xeee94c(0x131)](_0x24bb7b),_0x16fb9e=this['getRange'](),_0x2c775b=[];for(let _0x4d8edb=0x0;_0x4d8edb<_0x3252e8[_0xeee94c(0x123)];_0x4d8edb++){const _0x436d0e=_0x3252e8[_0x4d8edb],_0x23aaca=_0x436d0e[_0xeee94c(0x12e)],_0xb3f477=[];for(let _0x17b14a=0x0;_0x17b14a<_0x23aaca[_0xeee94c(0x123)];_0x17b14a++){const _0x5c137e=_0x23aaca[_0x17b14a],_0x166e4d=_0x4d0f64[_0xeee94c(0x140)](_0x5c137e,_0x16fb9e);_0x166e4d&&_0xb3f477[_0xeee94c(0x13b)](_0x166e4d);}if(_0xb3f477[_0xeee94c(0x123)]>0x0){_0x436d0e['filledRanges']=_0xb3f477;const _0x35f6c2=_0xb3f477[0x0],_0xfac242=_0x35f6c2['startRow']-_0x16fb9e[_0xeee94c(0x145)],_0x438433=_0x35f6c2[_0xeee94c(0x126)]-_0x16fb9e['startColumn'];_0x436d0e['formula']=await _0x182c7d[_0xeee94c(0x147)](_0x436d0e[_0xeee94c(0x136)],_0xfac242,_0x438433),_0x2c775b['push'](_0x436d0e);}}return _0x2c775b;}async[_0x46c8ed(0x12a)](){const _0x1d5c6d=_0x46c8ed;return(await this[_0x1d5c6d(0x122)]())['map'](_0x2be888[_0x1d5c6d(0x127)]);}}_0x3fb9b8['FRange']['extend'](_0x4576e3);}));function _0x4278(){const _0x223bac=['9635838ZkkIVF','UniverSheetsFacade','28111360LLdxPL','formula','@univerjs/sheets-data-validation/facade','IFormulaUsageAnalyzer','getCellDataGrid','extend','push','getLintErrors','_worksheet','amd','getMaxRows','getIntersectRange','getRange','77238XtYXDR','getAllFormulaError','FUniver','startRow','UniverCoreFacade','moveFormulaRefOffset','9971575YaJoxP','get','@univerjs/core','@univerjs/sheets-formula/facade','UniverSheetsFormulaFacade','5872AbvYnJ','@univerjs/core/facade','_injector','FWorksheet','10754415rphVvu','26cVcEqP','getActiveWorkbook','getFormulaUsages','length','1310845UrPQhA','function','startColumn','toA1','getAllDataValidationErrorAsync','UniverCore','getFormulaUsagesAsA1','4blFPeQ','map','FWorkbook','filledRanges','getMaxColumns','@univerjs-pro/sheets-mcp','getAllFormulaUsages','15659TmVHuH'];_0x4278=function(){return _0x223bac;};return _0x4278();}
|