Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
refactor(sheets-data-validation): remove deprecated facade APIs (#6955)
wpxp12345613f905bb74f9
diff --git a/packages/sheets-data-validation/src/facade/__tests__/f-worksheet.spec.ts b/packages/sheets-data-validation/src/facade/__tests__/f-worksheet.spec.tsindex 4e94487a41..6bcbb08dc9 100644--- a/packages/sheets-data-validation/src/facade/__tests__/f-worksheet.spec.ts+++ b/packages/sheets-data-validation/src/facade/__tests__/f-worksheet.spec.ts@@ -31,8 +31,8 @@ describe('Test FWorksheet', () => {expect(activeSheet?.getDataValidations()).toBeDefined();});- it('Worksheet getValidatorStatus', async () => {+ it('Worksheet getValidatorStatusAsync', async () => {const activeSheet = univerAPI.getActiveWorkbook()?.getSheetByName('sheet1');- expect(activeSheet?.getValidatorStatus()).toBeDefined();+ expect(activeSheet?.getValidatorStatusAsync()).toBeDefined();});});diff --git a/packages/sheets-data-validation/src/facade/f-workbook.ts b/packages/sheets-data-validation/src/facade/f-workbook.tsindex 3d20300804..df3edd8709 100644--- a/packages/sheets-data-validation/src/facade/f-workbook.ts+++ b/packages/sheets-data-validation/src/facade/f-workbook.ts@@ -14,34 +14,12 @@* limitations under the License.*/-import type { IDataValidationRule, IDisposable, IExecutionOptions, IRange, Nullable, ObjectMatrix } from '@univerjs/core';-import type { IRuleChange } from '@univerjs/data-validation';-import type {- IAddSheetDataValidationCommandParams,- IRemoveSheetAllDataValidationCommandParams,- IRemoveSheetDataValidationCommandParams,- IUpdateSheetDataValidationOptionsCommandParams,- IUpdateSheetDataValidationRangeCommandParams,- IUpdateSheetDataValidationSettingCommandParams,- IValidStatusChange,-} from '@univerjs/sheets-data-validation';-import { DataValidationStatus, toDisposable } from '@univerjs/core';--import {- AddSheetDataValidationCommand,- RemoveSheetAllDataValidationCommand,- RemoveSheetDataValidationCommand,- SheetDataValidationModel,- SheetsDataValidationValidatorService,- UpdateSheetDataValidationOptionsCommand,- UpdateSheetDataValidationRangeCommand,- UpdateSheetDataValidationSettingCommand,-} from '@univerjs/sheets-data-validation';+import type { IDataValidationRule, IRange, Nullable, ObjectMatrix } from '@univerjs/core';+import { DataValidationStatus } from '@univerjs/core';+import { SheetDataValidationModel, SheetsDataValidationValidatorService } from '@univerjs/sheets-data-validation';import { FWorkbook } from '@univerjs/sheets/facade';-import { filter } from 'rxjs';export interface IDataValidationError {-sheetName: string;/** The row of the cell that triggered the error */@@ -85,68 +63,6 @@ export interface IFWorkbookSheetsDataValidationMixin {* ```*/getAllDataValidationErrorAsync(): Promise<IDataValidationError[]>;-- /**- * @deprecated Use `univerAPI.addEvent(univerAPI.Event.SheetDataValidationChanged, (event) => { ... })` instead- */- onDataValidationChange(- callback: (ruleChange: IRuleChange) => void- ): IDisposable;-- /**- * @deprecated Use `univerAPI.addEvent(univerAPI.Event.SheetDataValidatorStatusChanged, (event) => { ... })` instead- */- onDataValidationStatusChange(- callback: (statusChange: IValidStatusChange) => void- ): IDisposable;-- /**- * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationAdd, (event) => { ... })` instead- */- onBeforeAddDataValidation(- this: FWorkbook,- callback: (params: IAddSheetDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false- ): IDisposable;-- /**- * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationCriteriaUpdate, (event) => { ... })` instead- */- onBeforeUpdateDataValidationCriteria(- this: FWorkbook,- callback: (params: IUpdateSheetDataValidationSettingCommandParams, options: IExecutionOptions | undefined) => void | false- ): IDisposable;-- /**- * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationRangeUpdate, (event) => { ... })` instead- */- onBeforeUpdateDataValidationRange(- this: FWorkbook,- callback: (params: IUpdateSheetDataValidationRangeCommandParams, options: IExecutionOptions | undefined) => void | false- ): IDisposable;-- /**- * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationOptionsUpdate, (event) => { ... })` instead- */- onBeforeUpdateDataValidationOptions(- this: FWorkbook,- callback: (params: IUpdateSheetDataValidationOptionsCommandParams, options: IExecutionOptions | undefined) => void | false- ): IDisposable;-- /**- * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationDelete, (event) => { ... })` instead- */- onBeforeDeleteDataValidation(- this: FWorkbook,- callback: (params: IRemoveSheetDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false- ): IDisposable;-- /**- * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationDeleteAll, (event) => { ... })` instead- */- onBeforeDeleteAllDataValidation(- this: FWorkbook,- callback: (params: IRemoveSheetAllDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false- ): IDisposable;}/**@@ -262,115 +178,6 @@ export class FWorkbookSheetsDataValidationMixin extends FWorkbook implements IFWrule,};}-- // region DataValidationHooks- override onDataValidationChange(- callback: (ruleChange: IRuleChange) => void- ): IDisposable {- return toDisposable(this._dataValidationModel.ruleChange$-- .pipe(filter((change) => change.unitId === this._workbook.getUnitId()))- .subscribe(callback));- }-- override onDataValidationStatusChange(- callback: (statusChange: IValidStatusChange) => void- ): IDisposable {- return toDisposable(this._dataValidationModel.validStatusChange$- .pipe(filter((change) => change.unitId === this._workbook.getUnitId()))- .subscribe(callback));- }-- override onBeforeAddDataValidation(- callback: (params: IAddSheetDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false- ): IDisposable {- return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {- const params = commandInfo.params as IAddSheetDataValidationCommandParams;- if (commandInfo.id === AddSheetDataValidationCommand.id) {- if (params.unitId !== this._workbook.getUnitId()) {- return;- }- if (callback(params, options) === false) {- throw new Error('Command is stopped by the hook onBeforeAddDataValidation');- }- }- }));- }-- override onBeforeUpdateDataValidationCriteria(- callback: (params: IUpdateSheetDataValidationSettingCommandParams, options: IExecutionOptions | undefined) => void | false- ): IDisposable {- return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {- const params = commandInfo.params as IUpdateSheetDataValidationSettingCommandParams;- if (commandInfo.id === UpdateSheetDataValidationSettingCommand.id) {- if (params.unitId !== this._workbook.getUnitId()) {- return;- }-- if (callback(params, options) === false) {- throw new Error('Command is stopped by the hook onBeforeUpdateDataValidationCriteria');- }- }- }));- }-- override onBeforeUpdateDataValidationRange(callback: (params: IUpdateSheetDataValidationRangeCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable {- return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {- const params = commandInfo.params as IUpdateSheetDataValidationRangeCommandParams;- if (commandInfo.id === UpdateSheetDataValidationRangeCommand.id) {- if (params.unitId !== this._workbook.getUnitId()) {- return;- }-- if (callback(params, options) === false) {- throw new Error('Command is stopped by the hook onBeforeUpdateDataValidationRange');- }- }- }));- }-- override onBeforeUpdateDataValidationOptions(callback: (params: IUpdateSheetDataValidationOptionsCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable {- return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {- const params = commandInfo.params as IUpdateSheetDataValidationOptionsCommandParams;- if (commandInfo.id === UpdateSheetDataValidationOptionsCommand.id) {- if (params.unitId !== this._workbook.getUnitId()) {- return;- }-- if (callback(params, options) === false) {- throw new Error('Command is stopped by the hook onBeforeUpdateDataValidationOptions');- }- }- }));- }-- override onBeforeDeleteDataValidation(callback: (params: IRemoveSheetDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable {- return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {- const params = commandInfo.params as IRemoveSheetDataValidationCommandParams;- if (commandInfo.id === RemoveSheetDataValidationCommand.id) {- if (params.unitId !== this._workbook.getUnitId()) {- return;- }- if (callback(params, options) === false) {- throw new Error('Command is stopped by the hook onBeforeDeleteDataValidation');- }- }- }));- }-- override onBeforeDeleteAllDataValidation(callback: (params: IRemoveSheetAllDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable {- return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {- const params = commandInfo.params as IRemoveSheetAllDataValidationCommandParams;- if (commandInfo.id === RemoveSheetAllDataValidationCommand.id) {- if (params.unitId !== this._workbook.getUnitId()) {- return;- }- if (callback(params, options) === false) {- throw new Error('Command is stopped by the hook onBeforeDeleteAllDataValidation');- }- }- }));- }}FWorkbook.extend(FWorkbookSheetsDataValidationMixin);diff --git a/packages/sheets-data-validation/src/facade/f-worksheet.ts b/packages/sheets-data-validation/src/facade/f-worksheet.tsindex c35b050b79..dce0ca78cc 100644--- a/packages/sheets-data-validation/src/facade/f-worksheet.ts+++ b/packages/sheets-data-validation/src/facade/f-worksheet.ts@@ -38,11 +38,6 @@ export interface IFWorksheetDataValidationMixin {*/getDataValidations(): FDataValidation[];- /**- * @deprecated use `getValidatorStatusAsync` instead- */- getValidatorStatus(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>;-/*** Get data validation validator status for current sheet.* @returns {Promise<ObjectMatrix<Nullable<DataValidationStatus>>>} matrix of validator status@@ -91,7 +86,7 @@ export class FWorksheetDataValidationMixin extends FWorksheet implements IFWorksreturn dataValidationModel.getRules(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((rule) => new FDataValidation(rule, this._worksheet, this._injector));}- override getValidatorStatus(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>> {+ override getValidatorStatusAsync(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>> {const validatorService = this._injector.get(SheetsDataValidationValidatorService);return validatorService.validatorWorksheet(this._workbook.getUnitId(),@@ -99,10 +94,6 @@ export class FWorksheetDataValidationMixin extends FWorksheet implements IFWorks);}- override getValidatorStatusAsync(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>> {- return this.getValidatorStatus();- }-override getDataValidation(ruleId: string): Nullable<FDataValidation> {const dataValidationModel = this._injector.get(DataValidationModel);const rule = dataValidationModel.getRuleById(this._workbook.getUnitId(), this._worksheet.getSheetId(), ruleId);