@univerjs-pro/engine-formula 1.0.0-alpha.6 → 1.0.0-alpha.8
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/commands/commands/host-external-reference.command.d.ts +43 -0
- package/lib/types/commands/commands/persist-formula-last-values.command.d.ts +6 -0
- package/lib/types/commands/mutations/set-host-external-reference.mutation.d.ts +7 -0
- package/lib/types/controllers/formula-last-value-persistence.controller.d.ts +9 -0
- package/lib/types/controllers/host-external-reference-active-dirty.controller.d.ts +5 -0
- package/lib/types/controllers/host-external-reference-calculation.controller.d.ts +9 -0
- package/lib/types/controllers/host-external-reference.controller.d.ts +5 -0
- package/lib/types/engine/dependency-engine/dependency-engine.d.ts +6 -5
- package/lib/types/engine/dependency-engine/formula-cell-index.d.ts +3 -2
- package/lib/types/engine/dependency-engine/helpers.d.ts +7 -6
- package/lib/types/engine/dependency-engine/point-subscription-index.d.ts +3 -2
- package/lib/types/engine/dependency-engine/range-index.d.ts +5 -4
- package/lib/types/engine/dependency-engine/types.d.ts +3 -20
- package/lib/types/engine/formula-dependency.d.ts +2 -2
- package/lib/types/facade/f-enum.d.ts +76 -0
- package/lib/types/facade/f-formula.d.ts +139 -0
- package/lib/types/facade/index.d.ts +5 -1
- package/lib/types/index.d.ts +18 -1
- package/lib/types/models/formula-last-value.d.ts +14 -0
- package/lib/types/models/host-external-reference.model.d.ts +61 -0
- package/lib/types/services/calculate-formula.service.d.ts +8 -14
- package/lib/types/services/dependency-manager.service.d.ts +4 -4
- package/lib/types/services/formula-cache-eligibility.service.d.ts +18 -0
- package/lib/types/services/formula-last-value-persistence.service.d.ts +18 -0
- package/lib/types/services/formula-reference-data.service.d.ts +11 -1
- package/lib/types/services/formula-reference-unit.service.d.ts +103 -0
- package/lib/types/services/formula-result-presentation.d.ts +22 -0
- package/lib/types/services/host-external-reference-data-loader.service.d.ts +31 -0
- package/lib/types/services/host-formula-binding.service.d.ts +15 -0
- package/lib/types/services/main-formula-reference-data.service.d.ts +1 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { FormulaUnitType } from '@univerjs/engine-formula';
|
|
2
|
+
import { Disposable } from '@univerjs/core';
|
|
3
|
+
/**
|
|
4
|
+
* Snapshot resource key shared by Sheet, Document, Slide, Board, and Base Hosts.
|
|
5
|
+
* The resource stores identity mappings only; it never stores Source formula data.
|
|
6
|
+
*/
|
|
7
|
+
export declare const UNIVER_EXTERNAL_REFERENCE_PLUGIN = "UNIVER_EXTERNAL_REFERENCE_PLUGIN";
|
|
8
|
+
export declare const HOST_EXTERNAL_REFERENCE_SCHEMA_VERSION: 1;
|
|
9
|
+
/** One Host-owned mapping from a public formula qualifier to a stable Source Unit. */
|
|
10
|
+
export interface IHostExternalReference {
|
|
11
|
+
/** Source name used in formula text, without brackets or quotes. */
|
|
12
|
+
qualifier: string;
|
|
13
|
+
/** Stable Source Unit ID used for external data reads. */
|
|
14
|
+
sourceUnitId: string;
|
|
15
|
+
/** Sheet or Base Source type. */
|
|
16
|
+
sourceUnitType: FormulaUnitType;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Value persisted under {@link UNIVER_EXTERNAL_REFERENCE_PLUGIN}.
|
|
20
|
+
*
|
|
21
|
+
* `references` is keyed by an opaque Host-local reference ID. Callers should use
|
|
22
|
+
* Facade/command APIs for runtime writes instead of constructing those IDs.
|
|
23
|
+
*/
|
|
24
|
+
export interface IHostExternalReferenceResource {
|
|
25
|
+
schemaVersion: typeof HOST_EXTERNAL_REFERENCE_SCHEMA_VERSION;
|
|
26
|
+
references: Record<string, IHostExternalReference>;
|
|
27
|
+
}
|
|
28
|
+
export type HostExternalReferenceBindingResult = {
|
|
29
|
+
status: 'resolved';
|
|
30
|
+
referenceId: string;
|
|
31
|
+
reference: IHostExternalReference;
|
|
32
|
+
} | {
|
|
33
|
+
status: 'missing' | 'ambiguous';
|
|
34
|
+
};
|
|
35
|
+
export type HostExternalReferenceLoadError = 'invalid-resource' | 'unsupported-version';
|
|
36
|
+
export declare function createEmptyHostExternalReferenceResource(): IHostExternalReferenceResource;
|
|
37
|
+
export declare function isReservedExternalReferenceQualifier(qualifier: string): boolean;
|
|
38
|
+
export declare function normalizeHostExternalReferenceQualifier(qualifier: string): string;
|
|
39
|
+
export declare function isHostExternalReference(value: unknown): value is IHostExternalReference;
|
|
40
|
+
export declare class HostExternalReferenceModel extends Disposable {
|
|
41
|
+
private readonly _resources;
|
|
42
|
+
private readonly _rawResources;
|
|
43
|
+
private readonly _loadErrors;
|
|
44
|
+
private readonly _revisions;
|
|
45
|
+
load(hostUnitId: string, value: unknown): boolean;
|
|
46
|
+
set(hostUnitId: string, resource: IHostExternalReferenceResource): boolean;
|
|
47
|
+
serialize(hostUnitId: string): unknown;
|
|
48
|
+
get(hostUnitId: string): IHostExternalReferenceResource | undefined;
|
|
49
|
+
getAll(): Record<string, IHostExternalReferenceResource>;
|
|
50
|
+
getLoadError(hostUnitId: string): HostExternalReferenceLoadError | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Runtime revision used by derived Formula cache compare-and-set mutations.
|
|
53
|
+
* It is intentionally not serialized into the Host resource.
|
|
54
|
+
*/
|
|
55
|
+
getRevision(hostUnitId: string): number;
|
|
56
|
+
resolveBinding(hostUnitId: string, qualifier: string): HostExternalReferenceBindingResult;
|
|
57
|
+
remove(hostUnitId: string): void;
|
|
58
|
+
dispose(): void;
|
|
59
|
+
private _preserveInvalid;
|
|
60
|
+
private _bumpRevision;
|
|
61
|
+
}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import type { IFormulaDatasetConfig } from '@univerjs/engine-formula';
|
|
2
|
-
import type { CalcNodeIndex,
|
|
2
|
+
import type { CalcNodeIndex, ICalculationOrderResult, IDynamicResolver } from '../engine/dependency-engine/types';
|
|
3
3
|
import type { IFormulaCalculationTree } from '../engine/formula-dependency';
|
|
4
4
|
import { IConfigService } from '@univerjs/core';
|
|
5
|
-
import { AstTreeBuilder, CalculateFormulaService, IFormulaCurrentConfigService, IFormulaDependencyGenerator, IFormulaRuntimeService, Interpreter, Lexer } from '@univerjs/engine-formula';
|
|
6
|
-
import { ExternalReferencePrefetchPlanner } from './external-reference-prefetch-planner';
|
|
7
|
-
import { ExternalReferencePrefetchService } from './external-reference-prefetch.service';
|
|
5
|
+
import { AstTreeBuilder, CalculateFormulaService, IFormulaCurrentConfigService, IFormulaDependencyGenerator, IFormulaExternalReferenceDataLoader, IFormulaRuntimeService, Interpreter, Lexer } from '@univerjs/engine-formula';
|
|
8
6
|
export declare class CalculateFormulaProService extends CalculateFormulaService {
|
|
9
|
-
private readonly
|
|
10
|
-
private readonly _externalPrefetchService;
|
|
7
|
+
private readonly _externalReferenceDataLoader;
|
|
11
8
|
private _dynamicRuntimeRanges;
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
constructor(configService: IConfigService, lexer: Lexer, currentConfigService: IFormulaCurrentConfigService, runtimeService: IFormulaRuntimeService, formulaDependencyGenerator: IFormulaDependencyGenerator, interpreter: Interpreter, astTreeBuilder: AstTreeBuilder, _externalPrefetchPlanner: ExternalReferencePrefetchPlanner, _externalPrefetchService: ExternalReferencePrefetchService);
|
|
9
|
+
private _runtimeExternalDataLoaded;
|
|
10
|
+
constructor(configService: IConfigService, lexer: Lexer, currentConfigService: IFormulaCurrentConfigService, runtimeService: IFormulaRuntimeService, formulaDependencyGenerator: IFormulaDependencyGenerator, interpreter: Interpreter, astTreeBuilder: AstTreeBuilder, _externalReferenceDataLoader: IFormulaExternalReferenceDataLoader);
|
|
15
11
|
execute(formulaDatasetConfig: IFormulaDatasetConfig): Promise<void>;
|
|
16
12
|
protected _executeStep(cycleReferenceCount?: number): Promise<true | undefined>;
|
|
17
13
|
protected _apply(isArrayFormulaState?: boolean, cycleReferenceCount?: number): Promise<import("@univerjs/engine-formula").IAllRuntimeData | undefined>;
|
|
@@ -21,15 +17,13 @@ export declare class CalculateFormulaProService extends CalculateFormulaService
|
|
|
21
17
|
protected _forEachCalculationPlanTree(calculationOrderResult: Pick<ICalculationOrderResult, 'calculationForest'>, dependencyTree: Map<CalcNodeIndex, IFormulaCalculationTree>, cycleReferenceCount: number, visitor: (tree: IFormulaCalculationTree, nodeIndex: CalcNodeIndex, cycleIndex?: number, shouldPreserveCycleTree?: boolean) => Promise<boolean | void>): Promise<void>;
|
|
22
18
|
private _calculationPlanHasSelfReference;
|
|
23
19
|
protected _getCalculationPlanTreeCount(calculationOrderResult: Pick<ICalculationOrderResult, 'calculationForest'>, dependencyTree: Map<CalcNodeIndex, IFormulaCalculationTree>, cycleReferenceCount: number): number;
|
|
24
|
-
protected _getDynamicResolver():
|
|
20
|
+
protected _getDynamicResolver(): IDynamicResolver | undefined;
|
|
25
21
|
private _refreshDynamicDepsAfterCalculate;
|
|
26
|
-
private
|
|
27
|
-
private
|
|
22
|
+
private _collectAddressFunctionRuntimeReferences;
|
|
23
|
+
private _collectAddressFunctionRuntimeReferencesInternal;
|
|
28
24
|
private _getRangeSignature;
|
|
29
25
|
private _waitForExecutionSlot;
|
|
30
26
|
private _calculateDependencyTree;
|
|
31
|
-
private _prefetchDynamicExternalReferences;
|
|
32
|
-
private _collectAddressFunctionRuntimeReferences;
|
|
33
27
|
private _setFunctionRefInfoForTree;
|
|
34
28
|
private _formulaReferencesTreeCell;
|
|
35
29
|
private _isReferenceMetadataFunctionArgument;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IUnitRange } from '@univerjs/core';
|
|
2
2
|
import type { FormulaDependencyTree, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetNameMap, IFormulaDependencyTree } from '@univerjs/engine-formula';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ICalcNodeRef, ICompressedSharedFormulaGroup, IDynamicResolver } from '../engine/dependency-engine/types';
|
|
4
4
|
import { DependencyManagerBaseService } from '@univerjs/engine-formula';
|
|
5
5
|
export declare class DependencyManagerProService extends DependencyManagerBaseService {
|
|
6
6
|
private _dependencyEngineCache;
|
|
@@ -42,12 +42,12 @@ export declare class DependencyManagerProService extends DependencyManagerBaseSe
|
|
|
42
42
|
clearCalculatedDirty(indices: number[]): void;
|
|
43
43
|
hasDynamicDeps(node: ICalcNodeRef): boolean;
|
|
44
44
|
hasDynamicDepsByIndex(nodeIndex: number): boolean;
|
|
45
|
-
refreshDynamicDeps(node: ICalcNodeRef, resolver:
|
|
46
|
-
refreshDynamicDepsByIndex(nodeIndex: number, resolver:
|
|
45
|
+
refreshDynamicDeps(node: ICalcNodeRef, resolver: IDynamicResolver): boolean;
|
|
46
|
+
refreshDynamicDepsByIndex(nodeIndex: number, resolver: IDynamicResolver): boolean;
|
|
47
47
|
hasUncalculatedDirtyPrecedentByIndex(nodeIndex: number, calculatedNodeIndices: ReadonlySet<number>): boolean;
|
|
48
48
|
forEachPrecedentNodeByIndex(nodeIndex: number, cb: (precedentNodeIndex: number) => void): void;
|
|
49
49
|
forEachDependentNodeByIndex(nodeIndex: number, cb: (dependentNodeIndex: number) => void): void;
|
|
50
|
-
prepareDynamicDependencies(resolver:
|
|
50
|
+
prepareDynamicDependencies(resolver: IDynamicResolver): boolean;
|
|
51
51
|
getCalculationOrder(options?: {
|
|
52
52
|
detectCycles?: boolean;
|
|
53
53
|
}): import("../engine/dependency-engine/types").ICalculationOrderResult;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IOtherFormulaResult } from '@univerjs/engine-formula';
|
|
2
|
+
import { LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
3
|
+
export type FormulaCacheIneligibleReason = 'not-successful' | 'volatile';
|
|
4
|
+
export interface IFormulaCacheEligibility {
|
|
5
|
+
eligible: boolean;
|
|
6
|
+
reason?: FormulaCacheIneligibleReason;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Central Formula-engine authority for last-value cache eligibility.
|
|
10
|
+
*
|
|
11
|
+
* Volatility is derived from parsed Formula nodes, never function-name substrings
|
|
12
|
+
* or rendered error text. Availability is represented by the structured result status.
|
|
13
|
+
*/
|
|
14
|
+
export declare class FormulaCacheEligibilityService {
|
|
15
|
+
private readonly _lexerTreeBuilder;
|
|
16
|
+
constructor(_lexerTreeBuilder: LexerTreeBuilder);
|
|
17
|
+
assess(formula: string, result: IOtherFormulaResult | undefined): IFormulaCacheEligibility;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IDisposable, IMutationInfo } from '@univerjs/core';
|
|
2
|
+
import { Disposable } from '@univerjs/core';
|
|
3
|
+
/**
|
|
4
|
+
* A Formula host contributes compare-and-set mutations for successful scalar results.
|
|
5
|
+
*
|
|
6
|
+
* Providers omit unavailable, failed, non-scalar, and volatile results. Every returned
|
|
7
|
+
* mutation revalidates its captured Formula source before writing, so a late result cannot
|
|
8
|
+
* overwrite a newer edit.
|
|
9
|
+
*/
|
|
10
|
+
export interface IFormulaLastValuePersistenceProvider {
|
|
11
|
+
collectMutations(sessionId: number): readonly IMutationInfo[];
|
|
12
|
+
}
|
|
13
|
+
export declare class FormulaLastValuePersistenceService extends Disposable {
|
|
14
|
+
private readonly _providers;
|
|
15
|
+
registerProvider(provider: IFormulaLastValuePersistenceProvider): IDisposable;
|
|
16
|
+
collectMutations(sessionId: number): IMutationInfo[];
|
|
17
|
+
dispose(): void;
|
|
18
|
+
}
|
|
@@ -13,11 +13,13 @@ export interface IFormulaReferenceDataRequest {
|
|
|
13
13
|
requestId: string;
|
|
14
14
|
calculationId: string;
|
|
15
15
|
hostUnitId: string;
|
|
16
|
-
bindingSlot
|
|
16
|
+
bindingSlot?: number;
|
|
17
|
+
referenceId?: string;
|
|
17
18
|
syntheticUnitId: string;
|
|
18
19
|
target: {
|
|
19
20
|
name: string;
|
|
20
21
|
unitType: FormulaUnitType;
|
|
22
|
+
sourceUnitId?: string;
|
|
21
23
|
uri?: string;
|
|
22
24
|
liveUnitId?: string;
|
|
23
25
|
};
|
|
@@ -38,6 +40,13 @@ export interface IFormulaReferenceDataSheet {
|
|
|
38
40
|
coverage: IRange[];
|
|
39
41
|
cells: IFormulaReferenceDataCell[];
|
|
40
42
|
}
|
|
43
|
+
export interface IFormulaReferenceDataTable {
|
|
44
|
+
name: string;
|
|
45
|
+
sheetId: string;
|
|
46
|
+
range: IRange;
|
|
47
|
+
columns: string[];
|
|
48
|
+
showHeader?: boolean;
|
|
49
|
+
}
|
|
41
50
|
export interface IFormulaReferenceDataResponse {
|
|
42
51
|
requestId: string;
|
|
43
52
|
calculationId: string;
|
|
@@ -45,6 +54,7 @@ export interface IFormulaReferenceDataResponse {
|
|
|
45
54
|
freshness: FormulaReferenceDataFreshness;
|
|
46
55
|
revision?: string;
|
|
47
56
|
sheets: IFormulaReferenceDataSheet[];
|
|
57
|
+
tables?: IFormulaReferenceDataTable[];
|
|
48
58
|
error?: '#N/A' | '#REF!' | '#CYCLE!';
|
|
49
59
|
}
|
|
50
60
|
export interface IFormulaReferenceDataService {
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { IRange } from '@univerjs/core';
|
|
2
|
+
/** Reference syntax produced by {@link buildFormulaReference} and `FFormula.buildReference()`. */
|
|
3
|
+
export declare enum FormulaReferenceType {
|
|
4
|
+
/** A worksheet A1 range such as `Sheet1!A1:B10` or `'[Sales]Data'!A1:B10`. */
|
|
5
|
+
SHEET_RANGE = "sheet-range",
|
|
6
|
+
/** A Base structured reference such as `Orders[Amount]` or `[Sales]!Orders[Amount]`. */
|
|
7
|
+
TABLE_COLUMN = "table-column"
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Explicit Unit identity supplied by the caller when serializing a formula reference.
|
|
11
|
+
* Always use the stable Unit ID; never infer it from `formulaQualifier`.
|
|
12
|
+
*/
|
|
13
|
+
export interface IFormulaReferenceUnit {
|
|
14
|
+
/**
|
|
15
|
+
* Display name written into the formula qualifier. Supply the name only, without
|
|
16
|
+
* surrounding brackets or quotes; the builder applies formula escaping.
|
|
17
|
+
*/
|
|
18
|
+
formulaQualifier: string;
|
|
19
|
+
/**
|
|
20
|
+
* Stable Sheet or Base Unit ID. When it equals `hostUnitId`, the builder emits
|
|
21
|
+
* a Host-local reference; otherwise it emits a cross-Unit qualifier.
|
|
22
|
+
*/
|
|
23
|
+
unitId: string;
|
|
24
|
+
}
|
|
25
|
+
/** Sheet-range reference target accepted by {@link buildFormulaReference}. */
|
|
26
|
+
export interface IFormulaSheetRangeReferenceTarget {
|
|
27
|
+
kind: FormulaReferenceType.SHEET_RANGE;
|
|
28
|
+
/** Source worksheet name, without formula quotes. */
|
|
29
|
+
sheetName: string;
|
|
30
|
+
/** Zero-based inclusive source range. */
|
|
31
|
+
range: IRange;
|
|
32
|
+
}
|
|
33
|
+
/** Base/structured-table reference target accepted by {@link buildFormulaReference}. */
|
|
34
|
+
export interface IFormulaTableColumnReferenceTarget {
|
|
35
|
+
kind: FormulaReferenceType.TABLE_COLUMN;
|
|
36
|
+
/** Source Base table name, without formula quotes. */
|
|
37
|
+
tableName: string;
|
|
38
|
+
/** First source field name. */
|
|
39
|
+
columnName: string;
|
|
40
|
+
/** Optional final column for a contiguous structured-reference range. */
|
|
41
|
+
endColumnName?: string;
|
|
42
|
+
}
|
|
43
|
+
/** A Sheet range or Base structured-reference target serialized by {@link buildFormulaReference}. */
|
|
44
|
+
export type FormulaReferenceTarget = IFormulaSheetRangeReferenceTarget | IFormulaTableColumnReferenceTarget;
|
|
45
|
+
/**
|
|
46
|
+
* Input used to serialize one formula reference fragment.
|
|
47
|
+
*
|
|
48
|
+
* `hostUnitId === unit.unitId` produces Host-local syntax. Different IDs produce
|
|
49
|
+
* cross-Unit syntax using `unit.formulaQualifier`.
|
|
50
|
+
*/
|
|
51
|
+
export interface IBuildFormulaReferenceOptions {
|
|
52
|
+
/** Stable ID of the Unit that will own the formula. */
|
|
53
|
+
hostUnitId: string;
|
|
54
|
+
/** Stable identity and public qualifier of the referenced Sheet or Base Unit. */
|
|
55
|
+
unit: IFormulaReferenceUnit;
|
|
56
|
+
/** Sheet range or structured-table column to serialize. */
|
|
57
|
+
target: FormulaReferenceTarget;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Purely serializes a Sheet-range or Base-table reference fragment.
|
|
61
|
+
*
|
|
62
|
+
* This low-level helper never persists a Host External Reference, loads a Unit, or
|
|
63
|
+
* starts calculation. Use `univerAPI.getFormula().buildReference()` for normal
|
|
64
|
+
* Facade authoring because that method also synchronizes cross-Unit bindings.
|
|
65
|
+
* The returned fragment has no leading `=` and is intended to be embedded in a
|
|
66
|
+
* complete formula.
|
|
67
|
+
*
|
|
68
|
+
* @example Serialize a Host-local Sheet range
|
|
69
|
+
* ```ts
|
|
70
|
+
* const reference = buildFormulaReference({
|
|
71
|
+
* hostUnitId: 'host-workbook',
|
|
72
|
+
* unit: {
|
|
73
|
+
* unitId: 'host-workbook',
|
|
74
|
+
* formulaQualifier: 'Host Workbook',
|
|
75
|
+
* },
|
|
76
|
+
* target: {
|
|
77
|
+
* kind: FormulaReferenceType.SHEET_RANGE,
|
|
78
|
+
* sheetName: 'Data',
|
|
79
|
+
* range: { startRow: 0, endRow: 9, startColumn: 1, endColumn: 1 },
|
|
80
|
+
* },
|
|
81
|
+
* });
|
|
82
|
+
* // reference === 'Data!B1:B10'
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @example Serialize a cross-Unit Base column
|
|
86
|
+
* ```ts
|
|
87
|
+
* const reference = buildFormulaReference({
|
|
88
|
+
* hostUnitId: 'host-document',
|
|
89
|
+
* unit: {
|
|
90
|
+
* unitId: 'sales-base',
|
|
91
|
+
* formulaQualifier: 'Sales Base',
|
|
92
|
+
* },
|
|
93
|
+
* target: {
|
|
94
|
+
* kind: FormulaReferenceType.TABLE_COLUMN,
|
|
95
|
+
* tableName: 'Orders',
|
|
96
|
+
* columnName: 'Amount',
|
|
97
|
+
* },
|
|
98
|
+
* });
|
|
99
|
+
* // reference === '[Sales Base]!Orders[Amount]'
|
|
100
|
+
* // The caller must persist the Host External Reference separately.
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function buildFormulaReference(options: IBuildFormulaReferenceOptions): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ICellData } from '@univerjs/core';
|
|
2
|
+
import type { IOtherFormulaResult } from '@univerjs/engine-formula';
|
|
3
|
+
import type { IFormulaLastValue } from '../models/formula-last-value';
|
|
4
|
+
export interface IFormulaResultPresentation {
|
|
5
|
+
text: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
pattern: string;
|
|
8
|
+
cell?: ICellData;
|
|
9
|
+
source: 'persisted' | 'calculated';
|
|
10
|
+
stale: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface IResolveFormulaResultPresentationOptions {
|
|
13
|
+
numberFormat?: {
|
|
14
|
+
pattern: string;
|
|
15
|
+
};
|
|
16
|
+
lastValue?: IFormulaLastValue;
|
|
17
|
+
result?: IOtherFormulaResult;
|
|
18
|
+
}
|
|
19
|
+
export declare function resolveFormulaResultPresentation(options: IResolveFormulaResultPresentationOptions): IFormulaResultPresentation;
|
|
20
|
+
export declare function getFormulaResultCell(result: IOtherFormulaResult | undefined): ICellData | undefined;
|
|
21
|
+
export declare function getScalarFormulaResultCell(result: IOtherFormulaResult | undefined): ICellData | undefined;
|
|
22
|
+
export declare function toFormulaLastValue(cell: ICellData): IFormulaLastValue | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { IRange } from '@univerjs/core';
|
|
2
|
+
import type { IFormulaExternalReferenceDataLoader, IFormulaExternalReferenceLoadInput } from '@univerjs/engine-formula';
|
|
3
|
+
import { ErrorType, IFormulaCurrentConfigService, ISuperTableService } from '@univerjs/engine-formula';
|
|
4
|
+
import { ExternalReferenceModel } from '../models/external-reference.model';
|
|
5
|
+
import { IFormulaReferenceDataService } from './formula-reference-data.service';
|
|
6
|
+
export declare class HostExternalReferenceDataLoader implements IFormulaExternalReferenceDataLoader {
|
|
7
|
+
private readonly _currentConfigService;
|
|
8
|
+
private readonly _referenceDataService;
|
|
9
|
+
private readonly _excelExternalReferenceModel;
|
|
10
|
+
private readonly _superTableService;
|
|
11
|
+
private _requestCounter;
|
|
12
|
+
private _generation;
|
|
13
|
+
private readonly _inflight;
|
|
14
|
+
private readonly _completed;
|
|
15
|
+
constructor(_currentConfigService: IFormulaCurrentConfigService, _referenceDataService: IFormulaReferenceDataService, _excelExternalReferenceModel: ExternalReferenceModel, _superTableService: ISuperTableService);
|
|
16
|
+
load(input: IFormulaExternalReferenceLoadInput): Promise<ErrorType | void>;
|
|
17
|
+
loadRuntimeRange(input: {
|
|
18
|
+
hostUnitId: string;
|
|
19
|
+
unitId: string;
|
|
20
|
+
sheetId: string;
|
|
21
|
+
sheetName?: string;
|
|
22
|
+
range: IRange;
|
|
23
|
+
}): Promise<ErrorType | boolean | void>;
|
|
24
|
+
private _resolveRuntimeRange;
|
|
25
|
+
private _runtimeRangeSheetName;
|
|
26
|
+
private _createRequest;
|
|
27
|
+
private _createA1RangeRequest;
|
|
28
|
+
private _loadRequest;
|
|
29
|
+
private _materialize;
|
|
30
|
+
private _materializeSheet;
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FormulaSequenceNode } from '@univerjs/engine-formula';
|
|
2
|
+
import type { HostExternalReferenceBindingResult, IHostExternalReference } from '../models/host-external-reference.model';
|
|
3
|
+
export type HostFormulaExternalReferenceResolution = {
|
|
4
|
+
status: 'resolved';
|
|
5
|
+
references: readonly IHostExternalReference[];
|
|
6
|
+
} | {
|
|
7
|
+
status: 'missing' | 'ambiguous';
|
|
8
|
+
qualifier: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function collectFormulaExternalReferenceQualifiers(sequenceNodes: FormulaSequenceNode[]): string[];
|
|
11
|
+
export declare function resolveHostFormulaExternalReferences(options: {
|
|
12
|
+
qualifiers: readonly string[];
|
|
13
|
+
explicitReferences: readonly IHostExternalReference[];
|
|
14
|
+
resolveBinding: (qualifier: string) => HostExternalReferenceBindingResult;
|
|
15
|
+
}): HostFormulaExternalReferenceResolution;
|
|
@@ -7,6 +7,7 @@ export declare class MainFormulaReferenceDataService implements IFormulaReferenc
|
|
|
7
7
|
private readonly _providerRegistry;
|
|
8
8
|
constructor(_formulaDataModel: FormulaDataModel, _superTableService: ISuperTableService, _providerRegistry: IFormulaReferenceDataProviderRegistry);
|
|
9
9
|
readData(request: IFormulaReferenceDataRequest): Promise<IFormulaReferenceDataResponse>;
|
|
10
|
+
private _readLiveTables;
|
|
10
11
|
private _readLiveSheets;
|
|
11
12
|
private _resolveLiveRange;
|
|
12
13
|
}
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x2b4e62,_0x504782){var _0xff5d77=_0x579a,_0x237ec5=_0x2b4e62();while(!![]){try{var _0x389e22=-parseInt(_0xff5d77(0x1c9))/0x1+parseInt(_0xff5d77(0x1e0))/0x2*(parseInt(_0xff5d77(0x1ec))/0x3)+-parseInt(_0xff5d77(0x1dd))/0x4*(parseInt(_0xff5d77(0x1de))/0x5)+-parseInt(_0xff5d77(0x1e5))/0x6+parseInt(_0xff5d77(0x1cd))/0x7*(-parseInt(_0xff5d77(0x1cc))/0x8)+-parseInt(_0xff5d77(0x1ca))/0x9*(-parseInt(_0xff5d77(0x1ea))/0xa)+parseInt(_0xff5d77(0x1e3))/0xb;if(_0x389e22===_0x504782)break;else _0x237ec5['push'](_0x237ec5['shift']());}catch(_0x8448f6){_0x237ec5['push'](_0x237ec5['shift']());}}}(_0x148c,0x44240),function(_0x331042,_0x3f4d11){var _0x157715=_0x579a;typeof exports==_0x157715(0x1c6)&&typeof module<'u'?_0x3f4d11(exports,require('@univerjs/engine-formula/facade'),require('@univerjs-pro/engine-formula'),require('@univerjs/core/facade'),require('@univerjs/core')):typeof define==_0x157715(0x1dc)&&define['amd']?define([_0x157715(0x1e1),_0x157715(0x1e8),_0x157715(0x1c7),_0x157715(0x1d2),_0x157715(0x1db)],_0x3f4d11):(_0x331042=typeof globalThis<'u'?globalThis:_0x331042||self,_0x3f4d11(_0x331042['UniverProEngineFormulaFacade']={},_0x331042[_0x157715(0x1ce)],_0x331042[_0x157715(0x1df)],_0x331042[_0x157715(0x1cb)],_0x331042[_0x157715(0x1e4)]));}(this,function(_0xc7e3ad,_0x19e3dc,_0x1921b7,_0x3fab13,_0x5de9cf){var _0x59805f=_0x579a;Object[_0x59805f(0x1e6)](_0xc7e3ad,Symbol[_0x59805f(0x1e2)],{'value':'Module'});var _0x1f4e43=class extends _0x3fab13[_0x59805f(0x1eb)]{get['FormulaReferenceType'](){var _0x48c21d=_0x59805f;return _0x1921b7[_0x48c21d(0x1d4)];}};_0x3fab13[_0x59805f(0x1eb)]['extend'](_0x1f4e43);var _0x2b013c=class extends _0x19e3dc[_0x59805f(0x1e9)]{[_0x59805f(0x1d1)](_0x2e9086){var _0x337139=_0x59805f;let {hostUnitId:_0x2d1634,unit:_0x40ff1a,target:_0x445c3b}=_0x2e9086;if(!_0x2d1634||!_0x40ff1a[_0x337139(0x1c4)])throw Error('Formula\x20reference\x20authoring\x20requires\x20stable\x20Host\x20and\x20Source\x20Unit\x20IDs.');if(_0x40ff1a[_0x337139(0x1c4)]!==_0x2d1634&&!this[_0x337139(0x1c8)][_0x337139(0x1cf)](_0x1921b7[_0x337139(0x1d5)]['id'],{'unitId':_0x2d1634,'qualifier':_0x40ff1a[_0x337139(0x1d6)],'sourceUnitId':_0x40ff1a[_0x337139(0x1c4)],'sourceUnitType':_0x445c3b[_0x337139(0x1d8)]===_0x1921b7[_0x337139(0x1d4)][_0x337139(0x1d9)]?_0x5de9cf[_0x337139(0x1d0)][_0x337139(0x1d3)]:_0x5de9cf[_0x337139(0x1d0)]['UNIVER_BASE']}))throw Error('Failed\x20to\x20bind\x20external\x20formula\x20reference\x20\x22'+_0x40ff1a['formulaQualifier']+'\x22.');return(0x0,_0x1921b7[_0x337139(0x1da)])(_0x2e9086);}[_0x59805f(0x1c5)](_0x181d84){var _0x4dbf2d=_0x59805f;return this[_0x4dbf2d(0x1c8)]['syncExecuteCommand'](_0x1921b7[_0x4dbf2d(0x1d5)]['id'],_0x181d84);}[_0x59805f(0x1e7)](_0x3a6141){var _0x5b5391=_0x59805f;return this['_commandService'][_0x5b5391(0x1cf)](_0x1921b7[_0x5b5391(0x1d7)]['id'],_0x3a6141);}};_0x19e3dc[_0x59805f(0x1e9)]['extend'](_0x2b013c),Object[_0x59805f(0x1e6)](_0xc7e3ad,_0x59805f(0x1e9),{'enumerable':!0x0,'get':function(){var _0x175dc2=_0x59805f;return _0x19e3dc[_0x175dc2(0x1e9)];}});}));function _0x579a(_0x23a05e,_0xcbfb5a){_0x23a05e=_0x23a05e-0x1c4;var _0x148c22=_0x148c();var _0x579ab4=_0x148c22[_0x23a05e];return _0x579ab4;}function _0x148c(){var _0x37e7de=['479284usfwZn','27DqdcsX','UniverCoreFacade','1250168bmOOtL','21fXkheW','UniverEngineFormulaFacade','syncExecuteCommand','UniverInstanceType','buildReference','@univerjs/core/facade','UNIVER_SHEET','FormulaReferenceType','UpsertHostExternalReferenceCommand','formulaQualifier','RemoveHostExternalReferenceCommand','kind','SHEET_RANGE','buildFormulaReference','@univerjs/core','function','8848iadoWV','5cbLPem','UniverProEngineFormula','6OFIBgd','exports','toStringTag','13672516ctQIqF','UniverCore','2619510Tnfqic','defineProperty','removeExternalReference','@univerjs/engine-formula/facade','FFormula','670nzNHqU','FEnum','422841lvOpAc','unitId','upsertExternalReference','object','@univerjs-pro/engine-formula','_commandService'];_0x148c=function(){return _0x37e7de;};return _0x148c();}
|