@univerjs-pro/engine-formula 1.0.0-alpha.7 → 1.0.0-beta.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/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 +12 -2
- package/lib/types/facade/f-formula.d.ts +110 -60
- package/lib/types/index.d.ts +16 -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 +70 -10
- 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 {
|
|
@@ -1,43 +1,103 @@
|
|
|
1
1
|
import type { IRange } from '@univerjs/core';
|
|
2
|
-
/**
|
|
2
|
+
/** Reference syntax produced by {@link buildFormulaReference} and `FFormula.buildReference()`. */
|
|
3
3
|
export declare enum FormulaReferenceType {
|
|
4
|
+
/** A worksheet A1 range such as `Sheet1!A1:B10` or `'[Sales]Data'!A1:B10`. */
|
|
4
5
|
SHEET_RANGE = "sheet-range",
|
|
6
|
+
/** A Base structured reference such as `Orders[Amount]` or `[Sales]!Orders[Amount]`. */
|
|
5
7
|
TABLE_COLUMN = "table-column"
|
|
6
8
|
}
|
|
7
|
-
/**
|
|
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
|
+
*/
|
|
8
13
|
export interface IFormulaReferenceUnit {
|
|
9
|
-
/**
|
|
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
|
+
*/
|
|
10
18
|
formulaQualifier: string;
|
|
11
|
-
/**
|
|
12
|
-
|
|
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;
|
|
13
24
|
}
|
|
14
25
|
/** Sheet-range reference target accepted by {@link buildFormulaReference}. */
|
|
15
26
|
export interface IFormulaSheetRangeReferenceTarget {
|
|
16
27
|
kind: FormulaReferenceType.SHEET_RANGE;
|
|
28
|
+
/** Source worksheet name, without formula quotes. */
|
|
17
29
|
sheetName: string;
|
|
30
|
+
/** Zero-based inclusive source range. */
|
|
18
31
|
range: IRange;
|
|
19
32
|
}
|
|
20
33
|
/** Base/structured-table reference target accepted by {@link buildFormulaReference}. */
|
|
21
34
|
export interface IFormulaTableColumnReferenceTarget {
|
|
22
35
|
kind: FormulaReferenceType.TABLE_COLUMN;
|
|
36
|
+
/** Source Base table name, without formula quotes. */
|
|
23
37
|
tableName: string;
|
|
38
|
+
/** First source field name. */
|
|
24
39
|
columnName: string;
|
|
25
40
|
/** Optional final column for a contiguous structured-reference range. */
|
|
26
41
|
endColumnName?: string;
|
|
27
42
|
}
|
|
28
43
|
/** A Sheet range or Base structured-reference target serialized by {@link buildFormulaReference}. */
|
|
29
44
|
export type FormulaReferenceTarget = IFormulaSheetRangeReferenceTarget | IFormulaTableColumnReferenceTarget;
|
|
30
|
-
/**
|
|
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
|
+
*/
|
|
31
51
|
export interface IBuildFormulaReferenceOptions {
|
|
32
|
-
/** Unit that
|
|
52
|
+
/** Stable ID of the Unit that will own the formula. */
|
|
33
53
|
hostUnitId: string;
|
|
34
|
-
/**
|
|
54
|
+
/** Stable identity and public qualifier of the referenced Sheet or Base Unit. */
|
|
35
55
|
unit: IFormulaReferenceUnit;
|
|
36
56
|
/** Sheet range or structured-table column to serialize. */
|
|
37
57
|
target: FormulaReferenceTarget;
|
|
38
58
|
}
|
|
39
59
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
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
|
+
* ```
|
|
42
102
|
*/
|
|
43
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 _0x5cfd(_0x23136e,_0x3f2b7b){_0x23136e=_0x23136e-0xcc;var _0x204414=_0x2044();var _0x5cfdd5=_0x204414[_0x23136e];return _0x5cfdd5;}(function(_0x3d5ae3,_0x55bc9a){var _0x4e50f5=_0x5cfd,_0x5007f4=_0x3d5ae3();while(!![]){try{var _0x281e01=-parseInt(_0x4e50f5(0xe0))/0x1+-parseInt(_0x4e50f5(0xe6))/0x2*(parseInt(_0x4e50f5(0xed))/0x3)+parseInt(_0x4e50f5(0xf2))/0x4+parseInt(_0x4e50f5(0xcd))/0x5*(parseInt(_0x4e50f5(0xf1))/0x6)+parseInt(_0x4e50f5(0xf0))/0x7*(parseInt(_0x4e50f5(0xce))/0x8)+-parseInt(_0x4e50f5(0xeb))/0x9*(-parseInt(_0x4e50f5(0xea))/0xa)+-parseInt(_0x4e50f5(0xe3))/0xb*(parseInt(_0x4e50f5(0xe9))/0xc);if(_0x281e01===_0x55bc9a)break;else _0x5007f4['push'](_0x5007f4['shift']());}catch(_0x5050ed){_0x5007f4['push'](_0x5007f4['shift']());}}}(_0x2044,0x5bf8f),function(_0x1a1265,_0x10d836){var _0x4922b6=_0x5cfd;typeof exports==_0x4922b6(0xdd)&&typeof module<'u'?_0x10d836(exports,require('@univerjs/engine-formula/facade'),require('@univerjs-pro/engine-formula'),require('@univerjs/core/facade'),require('@univerjs/core')):typeof define==_0x4922b6(0xd0)&&define['amd']?define(['exports','@univerjs/engine-formula/facade',_0x4922b6(0xe5),_0x4922b6(0xd6),_0x4922b6(0xcf)],_0x10d836):(_0x1a1265=typeof globalThis<'u'?globalThis:_0x1a1265||self,_0x10d836(_0x1a1265['UniverProEngineFormulaFacade']={},_0x1a1265[_0x4922b6(0xec)],_0x1a1265[_0x4922b6(0xe8)],_0x1a1265[_0x4922b6(0xd4)],_0x1a1265['UniverCore']));}(this,function(_0x40a39f,_0x20e34e,_0x49107c,_0x3f2721,_0x271284){var _0x26977a=_0x5cfd;Object['defineProperty'](_0x40a39f,Symbol[_0x26977a(0xe1)],{'value':_0x26977a(0xee)});var _0x1719df=class extends _0x3f2721[_0x26977a(0xd7)]{get[_0x26977a(0xd8)](){var _0x8b34a5=_0x26977a;return _0x49107c[_0x8b34a5(0xd8)];}};_0x3f2721[_0x26977a(0xd7)]['extend'](_0x1719df);var _0x2593e2=class extends _0x20e34e['FFormula']{[_0x26977a(0xe2)](_0xfa7e1f){var _0x4d0a5f=_0x26977a;let {hostUnitId:_0x1ebc26,unit:_0x2a112c,target:_0x1d49ab}=_0xfa7e1f;if(!_0x1ebc26||!_0x2a112c[_0x4d0a5f(0xd3)])throw Error('Formula\x20reference\x20authoring\x20requires\x20stable\x20Host\x20and\x20Source\x20Unit\x20IDs.');if(_0x2a112c[_0x4d0a5f(0xd3)]!==_0x1ebc26&&!this[_0x4d0a5f(0xd2)][_0x4d0a5f(0xcc)](_0x49107c[_0x4d0a5f(0xe7)]['id'],{'unitId':_0x1ebc26,'qualifier':_0x2a112c['formulaQualifier'],'sourceUnitId':_0x2a112c['unitId'],'sourceUnitType':_0x1d49ab[_0x4d0a5f(0xd5)]===_0x49107c[_0x4d0a5f(0xd8)][_0x4d0a5f(0xd9)]?_0x271284[_0x4d0a5f(0xde)]['UNIVER_SHEET']:_0x271284[_0x4d0a5f(0xde)][_0x4d0a5f(0xdb)]}))throw Error(_0x4d0a5f(0xf3)+_0x2a112c[_0x4d0a5f(0xda)]+'\x22.');return(0x0,_0x49107c[_0x4d0a5f(0xdf)])(_0xfa7e1f);}[_0x26977a(0xef)](_0x41dfaf){var _0x4fe984=_0x26977a;return this['_commandService'][_0x4fe984(0xcc)](_0x49107c[_0x4fe984(0xe7)]['id'],_0x41dfaf);}[_0x26977a(0xdc)](_0x3289a0){var _0x344138=_0x26977a;return this[_0x344138(0xd2)]['syncExecuteCommand'](_0x49107c['RemoveHostExternalReferenceCommand']['id'],_0x3289a0);}};_0x20e34e[_0x26977a(0xd1)][_0x26977a(0xe4)](_0x2593e2),Object['defineProperty'](_0x40a39f,_0x26977a(0xd1),{'enumerable':!0x0,'get':function(){var _0x3d1613=_0x26977a;return _0x20e34e[_0x3d1613(0xd1)];}});}));function _0x2044(){var _0x2951dd=['UniverProEngineFormula','12NPdTdS','10smwPUx','5659767szCLpS','UniverEngineFormulaFacade','75RsGoRs','Module','upsertExternalReference','182pBCUlf','6DYcHef','2623476FhduDx','Failed\x20to\x20bind\x20external\x20formula\x20reference\x20\x22','syncExecuteCommand','921355dUnFms','3288iDDLhr','@univerjs/core','function','FFormula','_commandService','unitId','UniverCoreFacade','kind','@univerjs/core/facade','FEnum','FormulaReferenceType','SHEET_RANGE','formulaQualifier','UNIVER_BASE','removeExternalReference','object','UniverInstanceType','buildFormulaReference','83482BvTBSC','toStringTag','buildReference','7753493KaFOdL','extend','@univerjs-pro/engine-formula','25170djuKEw','UpsertHostExternalReferenceCommand'];_0x2044=function(){return _0x2951dd;};return _0x2044();}
|