@odoo/o-spreadsheet 17.2.0-alpha.0 → 17.2.0-alpha.1

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.
@@ -2,17 +2,6 @@ import * as _odoo_owl from '@odoo/owl';
2
2
  import { ComponentConstructor, Component } from '@odoo/owl';
3
3
  import { ChartConfiguration, ChartData, ChartDataset, ChartOptions } from 'chart.js';
4
4
 
5
- declare enum CellErrorLevel {
6
- silent = 0,
7
- error = 1
8
- }
9
- declare class EvaluationError extends Error {
10
- readonly errorType: string;
11
- readonly logLevel: number;
12
- constructor(errorType: string, message: string, logLevel?: number);
13
- get isVerbose(): boolean;
14
- }
15
-
16
5
  declare const functionCache: {
17
6
  [key: string]: Omit<CompiledFormula, "dependencies" | "tokens">;
18
7
  };
@@ -2606,9 +2595,9 @@ interface Border$1 {
2606
2595
  bottom?: BorderDescr;
2607
2596
  right?: BorderDescr;
2608
2597
  }
2609
- type ReferenceDenormalizer = (range: Range, isMeta: boolean, functionName: string, paramNumber: number) => any | any[][];
2610
- type EnsureRange = (range: Range) => Matrix<ValueAndFormat>;
2611
- type _CompiledFormula = (deps: Range[], refFn: ReferenceDenormalizer, range: EnsureRange, ctx: {}) => Matrix<ValueAndFormat> | ValueAndFormat;
2598
+ type ReferenceDenormalizer = (range: Range, isMeta: boolean, functionName: string, paramNumber: number) => FPayload;
2599
+ type EnsureRange = (range: Range) => Matrix<FPayload>;
2600
+ type _CompiledFormula = (deps: Range[], refFn: ReferenceDenormalizer, range: EnsureRange, ctx: {}) => Matrix<FPayload> | FPayload;
2612
2601
  interface CompiledFormula {
2613
2602
  execute: _CompiledFormula;
2614
2603
  tokens: Token[];
@@ -2618,12 +2607,12 @@ interface RangeCompiledFormula extends Omit<CompiledFormula, "dependencies"> {
2618
2607
  dependencies: Range[];
2619
2608
  }
2620
2609
  type Matrix<T = unknown> = T[][];
2621
- type ValueAndFormat = {
2610
+ type FPayload = {
2622
2611
  value: CellValue;
2623
2612
  format?: Format;
2613
+ message?: string;
2624
2614
  };
2625
- type Arg = Maybe<ValueAndFormat> | Matrix<ValueAndFormat>;
2626
- type ArgValue = Maybe<CellValue> | Matrix<CellValue>;
2615
+ type Arg = Maybe<FPayload> | Matrix<FPayload>;
2627
2616
  declare function isMatrix(x: any): x is Matrix<any>;
2628
2617
  interface HeaderDimensions {
2629
2618
  start: Pixel;
@@ -2806,7 +2795,7 @@ interface EmptyCell extends EvaluatedCellProperties {
2806
2795
  interface ErrorCell extends EvaluatedCellProperties {
2807
2796
  readonly type: CellValueType.error;
2808
2797
  readonly value: string;
2809
- readonly error: EvaluationError;
2798
+ readonly message?: string;
2810
2799
  }
2811
2800
  declare enum CellValueType {
2812
2801
  boolean = "boolean",
@@ -5192,16 +5181,15 @@ type ArgType = "ANY" | "BOOLEAN" | "NUMBER" | "STRING" | "DATE" | "RANGE" | "RAN
5192
5181
  interface ArgDefinition {
5193
5182
  repeating?: boolean;
5194
5183
  optional?: boolean;
5195
- lazy?: boolean;
5196
5184
  description: string;
5197
5185
  name: string;
5198
5186
  type: ArgType[];
5199
5187
  default?: boolean;
5200
5188
  defaultValue?: any;
5201
5189
  }
5202
- type ComputeFunctionArg<T> = T | (() => T);
5203
- type ComputeFunction<T, R> = (this: EvalContext, ...args: ComputeFunctionArg<T>[]) => R;
5204
- interface AddFunctionDescriptionBase {
5190
+ type ComputeFunction<R> = (this: EvalContext, ...args: Arg[]) => R;
5191
+ interface AddFunctionDescription {
5192
+ compute: ComputeFunction<FPayload | Matrix<FPayload> | CellValue | Matrix<CellValue>>;
5205
5193
  description: string;
5206
5194
  category?: string;
5207
5195
  args: ArgDefinition[];
@@ -5209,16 +5197,6 @@ interface AddFunctionDescriptionBase {
5209
5197
  isExported?: boolean;
5210
5198
  hidden?: boolean;
5211
5199
  }
5212
- interface ComputeValue {
5213
- compute: ComputeFunction<ArgValue, CellValue | Matrix<CellValue>>;
5214
- }
5215
- interface ComputeFormat {
5216
- computeFormat: ComputeFunction<Arg, Format | undefined | Matrix<Format | undefined>>;
5217
- }
5218
- interface ComputeValueAndFormat {
5219
- computeValueAndFormat: ComputeFunction<Arg, Matrix<ValueAndFormat> | ValueAndFormat>;
5220
- }
5221
- type AddFunctionDescription = (AddFunctionDescriptionBase & ComputeValue & Partial<ComputeFormat>) | (AddFunctionDescriptionBase & ComputeValueAndFormat);
5222
5200
  type FunctionDescription = AddFunctionDescription & {
5223
5201
  minArgRequired: number;
5224
5202
  maxArgPossible: number;
@@ -5226,7 +5204,6 @@ type FunctionDescription = AddFunctionDescription & {
5226
5204
  getArgToFocus: (argPosition: number) => number;
5227
5205
  };
5228
5206
  type EvalContext = {
5229
- __lastFnCalled?: string;
5230
5207
  __originSheetId: UID;
5231
5208
  __originCellXC: () => string | undefined;
5232
5209
  locale: Locale;
@@ -8494,10 +8471,11 @@ declare class ChartPanel extends Component<Props, SpreadsheetChildEnv> {
8494
8471
  activatePanel(panel: "configuration" | "design"): void;
8495
8472
  }
8496
8473
 
8497
- declare function toNumber(value: string | number | boolean | null | undefined, locale: Locale): number;
8498
- declare function toString(value: string | number | boolean | null | undefined): string;
8499
- declare function toBoolean(value: string | number | boolean | null | undefined): boolean;
8500
- declare function toJsDate(value: string | number | boolean | null | undefined, locale: Locale): DateTime;
8474
+ declare function isEvaluationError(error: Maybe<CellValue>): boolean;
8475
+ declare function toNumber(data: FPayload | CellValue | undefined, locale: Locale): number;
8476
+ declare function toString(data: FPayload | CellValue | undefined): string;
8477
+ declare function toBoolean(data: FPayload | CellValue | undefined): boolean;
8478
+ declare function toJsDate(data: FPayload | CellValue | undefined, locale: Locale): DateTime;
8501
8479
 
8502
8480
  declare function arg(definition: string, description?: string): ArgDefinition;
8503
8481
 
@@ -8543,6 +8521,19 @@ type TranslationFunction = (string: string, ...values: SprintfValues) => string;
8543
8521
  */
8544
8522
  declare function setTranslationMethod(tfn: TranslationFunction, loaded?: () => boolean): void;
8545
8523
 
8524
+ declare const CellErrorType: {
8525
+ readonly NotAvailable: "#N/A";
8526
+ readonly InvalidReference: "#REF";
8527
+ readonly BadExpression: "#BAD_EXPR";
8528
+ readonly CircularDependency: "#CYCLE";
8529
+ readonly UnknownFunction: "#NAME?";
8530
+ readonly GenericError: "#ERROR";
8531
+ };
8532
+ declare class EvaluationError extends Error {
8533
+ readonly value: string;
8534
+ constructor(message?: string, value?: string);
8535
+ }
8536
+
8546
8537
  /**
8547
8538
  * We export here all entities that needs to be accessed publicly by Odoo.
8548
8539
  *
@@ -8567,10 +8558,11 @@ declare const registries: {
8567
8558
  autofillRulesRegistry: Registry<AutofillRule>;
8568
8559
  cellMenuRegistry: MenuItemRegistry;
8569
8560
  colMenuRegistry: MenuItemRegistry;
8561
+ errorTypes: Set<string>;
8570
8562
  linkMenuRegistry: MenuItemRegistry;
8571
8563
  functionRegistry: {
8572
8564
  mapping: {
8573
- [key: string]: ComputeFunction<Arg, ValueAndFormat | Matrix<ValueAndFormat>>;
8565
+ [key: string]: ComputeFunction<FPayload | Matrix<FPayload>>;
8574
8566
  };
8575
8567
  add(name: string, addDescr: AddFunctionDescription): any;
8576
8568
  content: {
@@ -8619,6 +8611,7 @@ declare const registries: {
8619
8611
  };
8620
8612
  declare const helpers: {
8621
8613
  arg: typeof arg;
8614
+ isEvaluationError: typeof isEvaluationError;
8622
8615
  toBoolean: typeof toBoolean;
8623
8616
  toJsDate: typeof toJsDate;
8624
8617
  toNumber: typeof toNumber;
@@ -8639,8 +8632,6 @@ declare const helpers: {
8639
8632
  getDefaultChartJsRuntime: typeof getDefaultChartJsRuntime;
8640
8633
  chartFontColor: typeof chartFontColor;
8641
8634
  ChartColors: typeof ChartColors;
8642
- EvaluationError: typeof EvaluationError;
8643
- CellErrorLevel: typeof CellErrorLevel;
8644
8635
  getFillingMode: typeof getFillingMode;
8645
8636
  rgbaToHex: typeof rgbaToHex;
8646
8637
  colorToRGBA: typeof colorToRGBA;
@@ -8690,4 +8681,4 @@ declare const constants: {
8690
8681
  DEFAULT_LOCALE: Locale;
8691
8682
  };
8692
8683
 
8693
- export { AbstractChart, CancelledReason, Client, ClientJoinedMessage, ClientLeftMessage, ClientMovedMessage, CollaborationMessage, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, RemoteRevisionMessage, Revision, RevisionRedoneMessage, RevisionUndoneMessage, SPREADSHEET_DIMENSIONS, Spreadsheet, TransportService, UIPlugin, __info__, addFunction, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
8684
+ export { AbstractChart, CancelledReason, CellErrorType, Client, ClientJoinedMessage, ClientLeftMessage, ClientMovedMessage, CollaborationMessage, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, RemoteRevisionMessage, Revision, RevisionRedoneMessage, RevisionUndoneMessage, SPREADSHEET_DIMENSIONS, Spreadsheet, TransportService, UIPlugin, __info__, addFunction, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };