@univerjs-pro/sheets-mcp 0.10.14-nightly.202511031023 → 0.10.14-nightly.202511070628

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.
@@ -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 { ISheetFormulaError } from '@univerjs/engine-formula';
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
+ }
@@ -1 +1,4 @@
1
1
  import './f-univer';
2
+ import './f-workbook';
3
+ import './f-worksheet';
4
+ import './f-range';
@@ -1,2 +1,3 @@
1
1
  export { UniverSheetMCPPlugin } from './plugin';
2
+ export { type IFormulaUsage, IFormulaUsageAnalyzer, type IFormulaUsageAsA1, toA1 } from './services/formula-analysis.service';
2
3
  export * from './tools';
@@ -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
+ }
@@ -11,20 +11,20 @@ export declare const ZodConditionalFormatRuleSchema: z.ZodObject<{
11
11
  colorScale: "colorScale";
12
12
  }>>;
13
13
  min_type: z.ZodOptional<z.ZodEnum<{
14
- formula: "formula";
15
- num: "num";
14
+ percent: "percent";
16
15
  min: "min";
17
16
  max: "max";
18
- percent: "percent";
17
+ formula: "formula";
18
+ num: "num";
19
19
  percentile: "percentile";
20
20
  }>>;
21
21
  min_value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
22
22
  max_type: z.ZodOptional<z.ZodEnum<{
23
- formula: "formula";
24
- num: "num";
23
+ percent: "percent";
25
24
  min: "min";
26
25
  max: "max";
27
- percent: "percent";
26
+ formula: "formula";
27
+ num: "num";
28
28
  percentile: "percentile";
29
29
  }>>;
30
30
  max_value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
@@ -38,11 +38,11 @@ export declare const ZodConditionalFormatRuleSchema: z.ZodObject<{
38
38
  index: z.ZodNumber;
39
39
  color: z.ZodString;
40
40
  value_type: z.ZodEnum<{
41
- formula: "formula";
42
- num: "num";
41
+ percent: "percent";
43
42
  min: "min";
44
43
  max: "max";
45
- percent: "percent";
44
+ formula: "formula";
45
+ num: "num";
46
46
  percentile: "percentile";
47
47
  }>;
48
48
  value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
@@ -50,12 +50,12 @@ export declare const ZodConditionalFormatRuleSchema: z.ZodObject<{
50
50
  sub_type: z.ZodOptional<z.ZodEnum<{
51
51
  number: "number";
52
52
  text: "text";
53
+ formula: "formula";
53
54
  uniqueValues: "uniqueValues";
54
55
  duplicateValues: "duplicateValues";
55
56
  rank: "rank";
56
57
  timePeriod: "timePeriod";
57
58
  average: "average";
58
- formula: "formula";
59
59
  }>>;
60
60
  operator: z.ZodOptional<z.ZodEnum<{
61
61
  endsWith: "endsWith";
@@ -0,0 +1 @@
1
+ export declare function extractFormulas(univerAPI: any, sheets?: string[]): Promise<string>;
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- function _0x3e23(){const _0x2f2fb3=['@univerjs/sheets-formula/facade','28lgvfTA','3222667cFpKaj','19842eyVxrR','895Fasgne','4631121zcsmOq','function','@univerjs/sheets-data-validation/facade','getAllFormulaError','4kYhpux','20328048rBdSuq','getLintErrors','224766RHoxbv','UniverCoreFacade','@univerjs/core/facade','getActiveWorkbook','8GJmZFS','199929QDFrJo','35120lmWiMQ','object','FUniver','13Uewzse','amd','extend','1760hwqChk'];_0x3e23=function(){return _0x2f2fb3;};return _0x3e23();}function _0xabc3(_0x1084b8,_0x1a8a05){const _0x3e23e2=_0x3e23();return _0xabc3=function(_0xabc3da,_0xc2e3d1){_0xabc3da=_0xabc3da-0x17d;let _0x376552=_0x3e23e2[_0xabc3da];return _0x376552;},_0xabc3(_0x1084b8,_0x1a8a05);}(function(_0x366e10,_0x164182){const _0x207728=_0xabc3,_0x16d4ef=_0x366e10();while(!![]){try{const _0x131244=parseInt(_0x207728(0x181))/0x1*(parseInt(_0x207728(0x192))/0x2)+-parseInt(_0x207728(0x195))/0x3*(parseInt(_0x207728(0x18a))/0x4)+-parseInt(_0x207728(0x18d))/0x5*(-parseInt(_0x207728(0x18c))/0x6)+parseInt(_0x207728(0x18b))/0x7*(parseInt(_0x207728(0x180))/0x8)+parseInt(_0x207728(0x18e))/0x9+parseInt(_0x207728(0x182))/0xa*(parseInt(_0x207728(0x188))/0xb)+-parseInt(_0x207728(0x193))/0xc*(parseInt(_0x207728(0x185))/0xd);if(_0x131244===_0x164182)break;else _0x16d4ef['push'](_0x16d4ef['shift']());}catch(_0x464b7d){_0x16d4ef['push'](_0x16d4ef['shift']());}}}(_0x3e23,0x4bbcf),function(_0x209c21,_0x5dee5f){const _0x37b9d9=_0xabc3;typeof exports==_0x37b9d9(0x183)&&typeof module<'u'?_0x5dee5f(require('@univerjs/core/facade'),require('@univerjs/sheets-formula/facade'),require('@univerjs/sheets-data-validation/facade')):typeof define==_0x37b9d9(0x18f)&&define[_0x37b9d9(0x186)]?define([_0x37b9d9(0x17e),_0x37b9d9(0x189),_0x37b9d9(0x190)],_0x5dee5f):(_0x209c21=typeof globalThis<'u'?globalThis:_0x209c21||self,_0x5dee5f(_0x209c21[_0x37b9d9(0x17d)]));}(this,function(_0x175fce){'use strict';const _0x3ca421=_0xabc3;class _0x6e5202 extends _0x175fce[_0x3ca421(0x184)]{async[_0x3ca421(0x194)](){const _0x58cdb7=_0x3ca421,_0xd85fcc=this[_0x58cdb7(0x17f)](),_0x1c8722=_0xd85fcc[_0x58cdb7(0x191)](),_0xc44e44=await _0xd85fcc['getAllDataValidationErrorAsync']();return{'formulaErrors':_0x1c8722,'dataValidationErrors':_0xc44e44};}}_0x175fce['FUniver'][_0x3ca421(0x187)](_0x6e5202);}));
1
+ function _0x5ad4(_0x3ec7ae,_0x3c0823){const _0x18c36e=_0x18c3();return _0x5ad4=function(_0x5ad47b,_0x189ae7){_0x5ad47b=_0x5ad47b-0xf1;let _0x4960a6=_0x18c36e[_0x5ad47b];return _0x4960a6;},_0x5ad4(_0x3ec7ae,_0x3c0823);}(function(_0x1c8d87,_0x2b76aa){const _0x1ba799=_0x5ad4,_0x842404=_0x1c8d87();while(!![]){try{const _0x39ad64=-parseInt(_0x1ba799(0xf4))/0x1+-parseInt(_0x1ba799(0xfb))/0x2+-parseInt(_0x1ba799(0x10d))/0x3+-parseInt(_0x1ba799(0xf7))/0x4*(parseInt(_0x1ba799(0x120))/0x5)+parseInt(_0x1ba799(0x103))/0x6+parseInt(_0x1ba799(0xf3))/0x7*(-parseInt(_0x1ba799(0xf2))/0x8)+parseInt(_0x1ba799(0xf9))/0x9*(parseInt(_0x1ba799(0x10f))/0xa);if(_0x39ad64===_0x2b76aa)break;else _0x842404['push'](_0x842404['shift']());}catch(_0xf462c){_0x842404['push'](_0x842404['shift']());}}}(_0x18c3,0xcd2df),function(_0xb71768,_0x5ecd66){const _0x2f9cd3=_0x5ad4;typeof exports=='object'&&typeof module<'u'?_0x5ecd66(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==_0x2f9cd3(0x122)&&define[_0x2f9cd3(0x11a)]?define([_0x2f9cd3(0x107),_0x2f9cd3(0x117),_0x2f9cd3(0xfc),_0x2f9cd3(0x115),'@univerjs-pro/sheets-mcp','@univerjs/core'],_0x5ecd66):(_0xb71768=typeof globalThis<'u'?globalThis:_0xb71768||self,_0x5ecd66(_0xb71768[_0x2f9cd3(0x109)],_0xb71768[_0x2f9cd3(0x108)],_0xb71768[_0x2f9cd3(0x121)],_0xb71768[_0x2f9cd3(0x112)],_0xb71768[_0x2f9cd3(0xf6)],_0xb71768[_0x2f9cd3(0x116)]));}(this,function(_0x36c38b,_0x22d62a,_0x279530,_0x2d6655,_0x26566b,_0x4de718){'use strict';const _0xb383ba=_0x5ad4;class _0x5d5750 extends _0x36c38b[_0xb383ba(0x10c)]{async['getLintErrors'](){const _0x38edd0=_0xb383ba;return this['getActiveWorkbook']()[_0x38edd0(0x106)]();}}_0x36c38b[_0xb383ba(0x10c)][_0xb383ba(0x101)](_0x5d5750);class _0x3ee3dd extends _0x2d6655[_0xb383ba(0x102)]{async[_0xb383ba(0x106)](){const _0x243e6a=_0xb383ba,_0x441c53=this[_0x243e6a(0x11d)](),_0x4e1ca0=await this[_0x243e6a(0x10e)]();return{'formulaErrors':_0x441c53,'dataValidationErrors':_0x4e1ca0};}}_0x2d6655['FWorkbook'][_0xb383ba(0x101)](_0x3ee3dd);class _0x4a466d extends _0x2d6655['FWorksheet']{async[_0xb383ba(0x114)](){const _0x1cb207=_0xb383ba,_0x59057b=this['_injector'][_0x1cb207(0x100)](_0x26566b[_0x1cb207(0xfd)]),_0x38e4fd=this[_0x1cb207(0x11e)](0x0,0x0,this[_0x1cb207(0xf8)]()+0x1,this[_0x1cb207(0x104)]()+0x1)['getCellDataGrid']();return await _0x59057b[_0x1cb207(0x119)](_0x38e4fd);}async['getFormulaUsagesAsA1'](){const _0x2e15b3=_0xb383ba;return(await this['getFormulaUsages']())[_0x2e15b3(0xf1)](_0x26566b[_0x2e15b3(0x118)]);}}_0x2d6655[_0xb383ba(0xfe)]['extend'](_0x4a466d);class _0x4124af extends _0x2d6655[_0xb383ba(0x11c)]{async['getFormulaUsages'](){const _0xf7b7fc=_0xb383ba,_0x428e0d=this[_0xf7b7fc(0x105)][_0xf7b7fc(0x100)](_0x26566b[_0xf7b7fc(0xfd)]),_0x25cc11=(({startRow:_0x2622f3,endRow:_0x12d42d,startColumn:_0x2bddbe,endColumn:_0x3bc8b2})=>{const _0x2b0613=_0xf7b7fc,_0x2922e2=[];for(let _0x5129d0=_0x2622f3;_0x5129d0<=_0x12d42d;_0x5129d0++){const _0x45db52=[];for(let _0x515b47=_0x2bddbe;_0x515b47<=_0x3bc8b2;_0x515b47++)_0x45db52[_0x2b0613(0xfa)](this[_0x2b0613(0x111)][_0x2b0613(0x11b)](_0x5129d0,_0x515b47));_0x2922e2[_0x2b0613(0xfa)](_0x45db52);}return _0x2922e2;})({'startRow':0x0,'endRow':this[_0xf7b7fc(0x111)][_0xf7b7fc(0xf8)](),'startColumn':0x0,'endColumn':this[_0xf7b7fc(0x111)]['getMaxColumns']()}),_0x1ad2b5=await _0x428e0d[_0xf7b7fc(0x119)](_0x25cc11),_0x2394ed=this['getRange'](),_0x7c417b=[];for(let _0x4d0515=0x0;_0x4d0515<_0x1ad2b5[_0xf7b7fc(0x113)];_0x4d0515++){const _0xcc55db=_0x1ad2b5[_0x4d0515],_0x8388eb=_0xcc55db[_0xf7b7fc(0x10a)],_0x3e365a=[];for(let _0x493a98=0x0;_0x493a98<_0x8388eb[_0xf7b7fc(0x113)];_0x493a98++){const _0x653555=_0x8388eb[_0x493a98],_0x4c8f4d=_0x4de718[_0xf7b7fc(0xf5)](_0x653555,_0x2394ed);_0x4c8f4d&&_0x3e365a[_0xf7b7fc(0xfa)](_0x4c8f4d);}if(_0x3e365a['length']>0x0){_0xcc55db['filledRanges']=_0x3e365a;const _0x2da9a1=_0x3e365a[0x0],_0x19126f=_0x2da9a1[_0xf7b7fc(0x110)]-_0x2394ed[_0xf7b7fc(0x110)],_0x17e754=_0x2da9a1[_0xf7b7fc(0xff)]-_0x2394ed[_0xf7b7fc(0xff)];_0xcc55db[_0xf7b7fc(0x11f)]=await _0x428e0d[_0xf7b7fc(0x10b)](_0xcc55db[_0xf7b7fc(0x11f)],_0x19126f,_0x17e754),_0x7c417b[_0xf7b7fc(0xfa)](_0xcc55db);}}return _0x7c417b;}async['getFormulaUsagesAsA1'](){const _0x319533=_0xb383ba;return(await this[_0x319533(0x114)]())['map'](_0x26566b[_0x319533(0x118)]);}}_0x2d6655[_0xb383ba(0x11c)]['extend'](_0x4124af);}));function _0x18c3(){const _0x2298d9=['FUniver','253779kCTWtZ','getAllDataValidationErrorAsync','4262270sRLoBl','startRow','_worksheet','UniverSheetsFacade','length','getFormulaUsages','@univerjs/sheets/facade','UniverCore','@univerjs/sheets-formula/facade','toA1','getAllFormulaUsages','amd','getCellRaw','FRange','getAllFormulaError','getRange','formula','10HpVDRs','UniverSheetsDataValidationFacade','function','map','11472HOsTlH','3031vSFTKU','1579693RrgYqJ','getIntersectRange','UniverProSheetsMcp','15572CvifoK','getMaxRows','54SmAIDl','push','1842856KXqvXQ','@univerjs/sheets-data-validation/facade','IFormulaUsageAnalyzer','FWorksheet','startColumn','get','extend','FWorkbook','8984850thZZOy','getMaxColumns','_injector','getLintErrors','@univerjs/core/facade','UniverSheetsFormulaFacade','UniverCoreFacade','filledRanges','moveFormulaRefOffset'];_0x18c3=function(){return _0x2298d9;};return _0x18c3();}