@odoo/owl 3.0.0-alpha.2 → 3.0.0-alpha.21

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.
Files changed (90) hide show
  1. package/README.md +100 -110
  2. package/dist/compile_templates.mjs +2434 -2532
  3. package/dist/compiler.js +2371 -0
  4. package/dist/owl-devtools.zip +0 -0
  5. package/dist/owl.cjs.js +6709 -6616
  6. package/dist/owl.cjs.runtime.js +4480 -0
  7. package/dist/owl.es.js +6697 -6600
  8. package/dist/owl.es.runtime.js +4436 -0
  9. package/dist/owl.iife.js +6710 -6617
  10. package/dist/owl.iife.min.js +1 -1
  11. package/dist/owl.iife.runtime.js +4484 -0
  12. package/dist/owl.iife.runtime.min.js +1 -0
  13. package/dist/types/common/owl_error.d.ts +3 -3
  14. package/dist/types/common/types.d.ts +1 -29
  15. package/dist/types/common/utils.d.ts +8 -8
  16. package/dist/types/compiler/code_generator.d.ts +133 -152
  17. package/dist/types/compiler/index.d.ts +13 -13
  18. package/dist/types/compiler/inline_expressions.d.ts +41 -59
  19. package/dist/types/compiler/parser.d.ts +170 -178
  20. package/dist/types/compiler/standalone/index.d.ts +2 -2
  21. package/dist/types/compiler/standalone/setup_jsdom.d.ts +1 -1
  22. package/dist/types/index.d.ts +1 -1
  23. package/dist/types/owl.d.ts +709 -665
  24. package/dist/types/runtime/app.d.ts +55 -62
  25. package/dist/types/runtime/blockdom/attributes.d.ts +8 -6
  26. package/dist/types/runtime/blockdom/block_compiler.d.ts +21 -21
  27. package/dist/types/runtime/blockdom/config.d.ts +8 -8
  28. package/dist/types/runtime/blockdom/event_catcher.d.ts +7 -7
  29. package/dist/types/runtime/blockdom/events.d.ts +8 -8
  30. package/dist/types/runtime/blockdom/html.d.ts +17 -17
  31. package/dist/types/runtime/blockdom/index.d.ts +25 -26
  32. package/dist/types/runtime/blockdom/list.d.ts +18 -18
  33. package/dist/types/runtime/blockdom/multi.d.ts +17 -17
  34. package/dist/types/runtime/blockdom/text.d.ts +26 -26
  35. package/dist/types/runtime/blockdom/toggler.d.ts +17 -17
  36. package/dist/types/runtime/component.d.ts +17 -28
  37. package/dist/types/runtime/component_node.d.ts +59 -83
  38. package/dist/types/runtime/context.d.ts +36 -0
  39. package/dist/types/runtime/error_handling.d.ts +13 -13
  40. package/dist/types/runtime/event_handling.d.ts +1 -1
  41. package/dist/types/runtime/fibers.d.ts +37 -37
  42. package/dist/types/runtime/hooks.d.ts +32 -57
  43. package/dist/types/runtime/index.d.ts +46 -35
  44. package/dist/types/runtime/lifecycle_hooks.d.ts +10 -12
  45. package/dist/types/runtime/plugin_hooks.d.ts +6 -0
  46. package/dist/types/runtime/plugin_manager.d.ts +36 -0
  47. package/dist/types/runtime/props.d.ts +21 -0
  48. package/dist/types/runtime/reactivity/computations.d.ts +34 -0
  49. package/dist/types/runtime/reactivity/computed.d.ts +6 -0
  50. package/dist/types/runtime/reactivity/effect.d.ts +1 -0
  51. package/dist/types/runtime/reactivity/proxy.d.ts +47 -0
  52. package/dist/types/runtime/reactivity/signal.d.ts +31 -0
  53. package/dist/types/runtime/reactivity.d.ts +57 -46
  54. package/dist/types/runtime/registry.d.ts +24 -15
  55. package/dist/types/runtime/rendering/error_handling.d.ts +13 -0
  56. package/dist/types/runtime/rendering/fibers.d.ts +37 -0
  57. package/dist/types/runtime/rendering/scheduler.d.ts +21 -0
  58. package/dist/types/runtime/rendering/template_helpers.d.ts +51 -0
  59. package/dist/types/runtime/resource.d.ts +18 -0
  60. package/dist/types/runtime/scheduler.d.ts +21 -21
  61. package/dist/types/runtime/status.d.ts +11 -10
  62. package/dist/types/runtime/template_set.d.ts +36 -40
  63. package/dist/types/runtime/types.d.ts +70 -0
  64. package/dist/types/runtime/utils.d.ts +24 -25
  65. package/dist/types/runtime/validation.d.ts +19 -36
  66. package/dist/types/version.d.ts +1 -1
  67. package/package.json +45 -19
  68. package/dist/types/runtime/cancellableContext.d.ts +0 -15
  69. package/dist/types/runtime/cancellablePromise.d.ts +0 -15
  70. package/dist/types/runtime/executionContext.d.ts +0 -0
  71. package/dist/types/runtime/listOperation.d.ts +0 -1
  72. package/dist/types/runtime/plugins.d.ts +0 -39
  73. package/dist/types/runtime/relationalModel/discussModel.d.ts +0 -19
  74. package/dist/types/runtime/relationalModel/discussModelTypes.d.ts +0 -22
  75. package/dist/types/runtime/relationalModel/field.d.ts +0 -20
  76. package/dist/types/runtime/relationalModel/model.d.ts +0 -59
  77. package/dist/types/runtime/relationalModel/modelData.d.ts +0 -18
  78. package/dist/types/runtime/relationalModel/modelRegistry.d.ts +0 -3
  79. package/dist/types/runtime/relationalModel/modelUtils.d.ts +0 -4
  80. package/dist/types/runtime/relationalModel/store.d.ts +0 -16
  81. package/dist/types/runtime/relationalModel/types.d.ts +0 -83
  82. package/dist/types/runtime/relationalModel/util.d.ts +0 -1
  83. package/dist/types/runtime/relationalModel/web/WebDataPoint.d.ts +0 -25
  84. package/dist/types/runtime/relationalModel/web/WebRecord.d.ts +0 -131
  85. package/dist/types/runtime/relationalModel/web/WebStaticList.d.ts +0 -63
  86. package/dist/types/runtime/relationalModel/web/webModel.d.ts +0 -5
  87. package/dist/types/runtime/relationalModel/web/webModelTypes.d.ts +0 -139
  88. package/dist/types/runtime/signals.d.ts +0 -17
  89. package/dist/types/runtime/task.d.ts +0 -12
  90. package/dist/types/utils/registry.d.ts +0 -15
@@ -1,36 +1,19 @@
1
- declare type BaseType = {
2
- new (...args: any[]): any;
3
- } | true | "*";
4
- interface TypeInfo {
5
- type?: TypeDescription;
6
- optional?: boolean;
7
- validate?: Function;
8
- shape?: Schema;
9
- element?: TypeDescription;
10
- values?: TypeDescription;
11
- }
12
- declare type ValueType = {
13
- value: any;
14
- };
15
- declare type TypeDescription = BaseType | TypeInfo | ValueType | TypeDescription[];
16
- declare type SimplifiedSchema = string[];
17
- declare type NormalizedSchema = {
18
- [key: string]: TypeDescription;
19
- };
20
- export declare type Schema = SimplifiedSchema | NormalizedSchema;
21
- export declare function isOptional(t: TypeDescription): Boolean;
22
- /**
23
- * Main validate function
24
- */
25
- export declare function validate(obj: {
26
- [key: string]: any;
27
- }, spec: Schema): void;
28
- /**
29
- * Helper validate function, to get the list of errors. useful if one want to
30
- * manipulate the errors without parsing an error object
31
- */
32
- export declare function validateSchema(obj: {
33
- [key: string]: any;
34
- }, schema: Schema): string[];
35
- export declare function validateType(key: string, value: any, descr: TypeDescription): string | null;
36
- export {};
1
+ export interface ValidationIssue {
2
+ message: string;
3
+ path?: PropertyKey[];
4
+ received?: any;
5
+ [K: string]: any;
6
+ }
7
+ export interface ValidationContext {
8
+ addIssue(issue: ValidationIssue): void;
9
+ isValid: boolean;
10
+ issueDepth: number;
11
+ mergeIssues(issues: ValidationIssue[]): void;
12
+ path: PropertyKey[];
13
+ validate(type: any): void;
14
+ value: any;
15
+ withIssues(issues: ValidationIssue[]): ValidationContext;
16
+ withKey(key: PropertyKey): ValidationContext;
17
+ }
18
+ export declare function assertType(value: any, validation: any, errorMessage?: string): void;
19
+ export declare function validateType(value: any, validation: any): ValidationIssue[];
@@ -1 +1 @@
1
- export declare const version = "2.8.1";
1
+ export declare const version = "3.0.0-alpha.21";
package/package.json CHANGED
@@ -1,10 +1,21 @@
1
1
  {
2
2
  "name": "@odoo/owl",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.21",
4
4
  "description": "Odoo Web Library (OWL)",
5
5
  "main": "dist/owl.cjs.js",
6
6
  "module": "dist/owl.es.js",
7
7
  "types": "dist/types/owl.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types/owl.d.ts",
11
+ "import": "./dist/owl.es.js",
12
+ "require": "./dist/owl.cjs.js",
13
+ "default": "./dist/owl.es.js"
14
+ },
15
+ "./dist/*": "./dist/*",
16
+ "./package.json": "./package.json"
17
+ },
18
+ "type": "module",
8
19
  "files": [
9
20
  "dist"
10
21
  ],
@@ -48,32 +59,46 @@
48
59
  },
49
60
  "homepage": "https://github.com/odoo/owl#readme",
50
61
  "devDependencies": {
51
- "@types/jest": "^27.0.1",
62
+ "@codemirror/autocomplete": "^6.20.1",
63
+ "@codemirror/commands": "^6.10.3",
64
+ "@codemirror/lang-css": "^6.3.1",
65
+ "@codemirror/lang-javascript": "^6.2.5",
66
+ "@codemirror/lang-markdown": "^6.5.0",
67
+ "@codemirror/lang-xml": "^6.1.0",
68
+ "@codemirror/language": "^6.12.2",
69
+ "@codemirror/state": "^6.6.0",
70
+ "@codemirror/theme-one-dark": "^6.1.3",
71
+ "@codemirror/view": "^6.40.0",
72
+ "@emmetio/codemirror6-plugin": "^0.4.0",
73
+ "@rollup/plugin-node-resolve": "^16.0.3",
74
+ "@rollup/plugin-terser": "^0.4.4",
75
+ "@types/jest": "^30.0.0",
52
76
  "@types/jsdom": "^21.1.7",
53
- "@types/node": "^14.11.8",
54
- "@typescript-eslint/eslint-plugin": "5.48.1",
55
- "@typescript-eslint/parser": "5.48.1",
77
+ "@types/node": "^25.2.0",
78
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
79
+ "@typescript-eslint/parser": "^8.54.0",
56
80
  "chalk": "^3.0.0",
81
+ "codemirror": "^6.0.2",
57
82
  "current-git-branch": "^1.1.0",
58
- "eslint": "8.31.0",
83
+ "eslint": "^9.39.2",
59
84
  "git-rev-sync": "^3.0.2",
60
- "github-api": "^3.3.0",
61
- "jest": "^27.1.0",
85
+ "github-api": "^3.4.0",
86
+ "globals": "^17.3.0",
87
+ "jest": "^30.2.0",
62
88
  "jest-diff": "^27.3.1",
63
- "jest-environment-jsdom": "^27.1.0",
89
+ "jest-environment-jsdom": "^30.2.0",
64
90
  "npm-run-all": "^4.1.5",
65
- "prettier": "2.4.1",
66
- "rollup": "^2.56.3",
67
- "rollup-plugin-copy": "^3.3.0",
68
- "rollup-plugin-delete": "^2.0.0",
69
- "rollup-plugin-dts": "^4.2.2",
91
+ "prettier": "^3.8.1",
92
+ "rollup": "^4.57.1",
93
+ "rollup-plugin-copy": "^3.5.0",
94
+ "rollup-plugin-delete": "^3.0.2",
95
+ "rollup-plugin-dts": "^6.3.0",
70
96
  "rollup-plugin-execute": "^1.1.1",
71
97
  "rollup-plugin-string": "^3.0.0",
72
- "rollup-plugin-terser": "^7.0.2",
73
- "rollup-plugin-typescript2": "^0.31.1",
98
+ "rollup-plugin-typescript2": "^0.36.0",
74
99
  "source-map-support": "^0.5.10",
75
- "ts-jest": "^27.0.5",
76
- "typescript": "4.5.2"
100
+ "ts-jest": "^29.4.6",
101
+ "typescript": "^5.9.3"
77
102
  },
78
103
  "jest": {
79
104
  "testEnvironment": "jsdom",
@@ -100,7 +125,8 @@
100
125
  },
101
126
  "prettier": {
102
127
  "printWidth": 100,
103
- "endOfLine": "auto"
128
+ "endOfLine": "auto",
129
+ "trailingComma": "es5"
104
130
  },
105
131
  "dependencies": {
106
132
  "jsdom": "^25.0.1"
@@ -1,15 +0,0 @@
1
- export declare type TaskContext = {
2
- isCancelled: boolean;
3
- cancel: () => void;
4
- meta: Record<string, any>;
5
- };
6
- export declare const taskContextStack: TaskContext[];
7
- export declare function getTaskContext(): TaskContext;
8
- export declare function makeTaskContext(): TaskContext;
9
- export declare function useTaskContext(ctx?: TaskContext): {
10
- ctx: TaskContext;
11
- cleanup: () => void;
12
- };
13
- export declare function pushTaskContext(context: TaskContext): void;
14
- export declare function popTaskContext(): void;
15
- export declare function taskEffect(fn: Function): TaskContext;
@@ -1,15 +0,0 @@
1
- export declare type PromiseExecContext = {
2
- cancelled: boolean;
3
- };
4
- export declare type CancellablePromise<T = any> = Promise<T> & {
5
- execContext?: PromiseExecContext;
6
- };
7
- export declare const setCancellableContext: (ctx: PromiseExecContext | undefined) => PromiseExecContext | undefined;
8
- export declare const resetCancellableContext: (ctx: PromiseExecContext | undefined) => void;
9
- export declare const _exec: (execContext: PromiseExecContext | undefined, cb: Function, args: any[]) => any;
10
- export declare function patchPromise(): void;
11
- export declare function restorePromise(): void;
12
- export declare function getCancellableTask(cb: Function): {
13
- cancel: () => boolean;
14
- readonly isCancel: boolean;
15
- };
File without changes
@@ -1 +0,0 @@
1
- export declare function reactiveMap<A, B>(arr: A[], fn: (a: A, index: number) => B): any;
@@ -1,39 +0,0 @@
1
- export interface PluginCtor {
2
- new (deps: any): Plugin<any>;
3
- id: string;
4
- dependencies: string[];
5
- }
6
- interface PluginMetaData {
7
- isDestroyed: boolean;
8
- }
9
- export declare class Plugin<Deps = {
10
- [name: string]: Plugin;
11
- }> {
12
- static id: string;
13
- static dependencies: string[];
14
- readonly plugins: Deps;
15
- static resources: {};
16
- resources: {
17
- [name: string]: any;
18
- };
19
- __meta__: PluginMetaData;
20
- setup(): void;
21
- destroy(): void;
22
- get isDestroyed(): boolean;
23
- }
24
- export declare class PluginManager {
25
- _parent: PluginManager | null;
26
- _children: PluginManager[];
27
- plugins: {
28
- [id: string]: Plugin;
29
- };
30
- resources: {
31
- [id: string]: any;
32
- };
33
- constructor(parent: PluginManager | null, Plugins: PluginCtor[] | (() => PluginCtor[]));
34
- destroy(): void;
35
- getPlugin(name: string): Plugin | null;
36
- getResource(name: string): any[];
37
- }
38
- export declare function usePlugins(Plugins: PluginCtor[]): void;
39
- export {};
@@ -1,19 +0,0 @@
1
- import { AttrParams, DateParams, DatetimeParams, HtmlParams, ManyParams, RelationParams } from "./discussModelTypes";
2
- import { Model } from "./model";
3
- import { FieldDefinition } from "./types";
4
- export declare class DiscussRecord {
5
- static Model: typeof Model;
6
- static fields: Record<string, FieldDefinition>;
7
- static register(): void;
8
- static insert(data: Partial<any>): any;
9
- record: Model;
10
- constructor();
11
- }
12
- export declare const fields: {
13
- One: (modelName: string, params?: RelationParams) => import("./types").FieldDefinitionMany2One;
14
- Many: (modelName: string, params?: ManyParams) => FieldDefinition;
15
- Attr: (defaultValue: string, params?: AttrParams) => import("./types").FieldDefinitionAny;
16
- Html: (defaultValue: string, params?: HtmlParams) => import("./types").FieldDefinitionAny;
17
- Date: (params?: DateParams) => import("./types").FieldDefinitionAny;
18
- Datetime: (params?: DatetimeParams) => import("./types").FieldDefinitionAny;
19
- };
@@ -1,22 +0,0 @@
1
- import { DiscussRecord } from "./discussModel";
2
- export declare type FieldCommonParams = {
3
- compute?: (record: DiscussRecord) => any;
4
- eager?: boolean;
5
- onUpdate?: (record: DiscussRecord) => void;
6
- };
7
- export declare type RelationParams = FieldCommonParams & {
8
- inverse?: string;
9
- onAdd?: (record: DiscussRecord) => void;
10
- onDelete?: (record: DiscussRecord) => void;
11
- };
12
- export declare type ManyParams = RelationParams & {
13
- sort?: (a: DiscussRecord, b: DiscussRecord) => number;
14
- };
15
- export declare type AttrParams = FieldCommonParams & {
16
- sort?: (a: DiscussRecord, b: DiscussRecord) => number;
17
- type?: string;
18
- };
19
- export declare type HtmlParams = FieldCommonParams;
20
- export declare type DateParams = FieldCommonParams;
21
- export declare type DatetimeParams = FieldCommonParams;
22
- export declare type DManyFn<T extends DiscussRecord> = () => T[];
@@ -1,20 +0,0 @@
1
- import { FieldDefinition, FieldDefinitionAny, FieldDefinitionChar, FieldDefinitionDate, FieldDefinitionDatetime, FieldDefinitionHtml, FieldDefinitionMany2One, FieldDefinitionMany2OneReference, FieldDefinitionNumber, FieldDefinitionOne2Many, FieldDefinitionProperties, FieldDefinitionReference, FieldDefinitionSelection, FieldDefinitionText, FieldTypes, ModelId } from "./types";
2
- export declare const fieldAny: () => FieldDefinitionAny;
3
- export declare const fieldNumber: () => FieldDefinitionNumber;
4
- export declare const fieldChar: () => FieldDefinitionChar;
5
- export declare const fieldText: () => FieldDefinitionText;
6
- export declare const fieldHtml: () => FieldDefinitionHtml;
7
- export declare const fieldDate: () => FieldDefinitionDate;
8
- export declare const fieldDatetime: () => FieldDefinitionDatetime;
9
- export declare const fieldSelection: (selection: any) => FieldDefinitionSelection;
10
- export declare const fieldReference: () => FieldDefinitionReference;
11
- export declare const fieldProperties: () => FieldDefinitionProperties;
12
- export declare const fieldOne2Many: (modelId: ModelId, { relatedField }?: {
13
- relatedField?: string | undefined;
14
- }) => FieldDefinitionOne2Many;
15
- export declare const fieldMany2One: (modelId: ModelId) => FieldDefinitionMany2One;
16
- export declare const fieldMany2Many: (modelId: ModelId, opts?: {
17
- relationTableName?: string;
18
- }) => FieldDefinition;
19
- export declare const fieldMany2OneReference: () => FieldDefinitionMany2OneReference;
20
- export declare const field: (type: FieldTypes, opts?: any) => FieldDefinition;
@@ -1,59 +0,0 @@
1
- import { MakeGetSet } from "../../common/types";
2
- import { ModelId, InstanceId, FieldDefinition, RecordItem, RelationChanges, DraftContext } from "./types";
3
- export declare class Model {
4
- static id: ModelId;
5
- static fields: Record<string, FieldDefinition>;
6
- static relatedFields: Record<string, string>;
7
- static recordsItems: Record<InstanceId, RecordItem>;
8
- static create<T extends typeof Model>(this: T, data: Partial<InstanceType<T>>): InstanceType<T>;
9
- static get<T extends typeof Model>(this: T, id: InstanceId, context?: DraftContext): InstanceType<T>;
10
- static getAll<T extends typeof Model>(this: T): InstanceType<T>[];
11
- static register<T extends typeof Model>(this: T): T;
12
- static getRecordItem(id: InstanceId, defaultData?: Record<string, any>): RecordItem;
13
- static getGlobalInstance<T extends typeof Model>(this: T, id: InstanceId): InstanceType<T>;
14
- static getContextInstance<T extends typeof Model>(this: T, id: InstanceId, draftContext?: DraftContext): InstanceType<T>;
15
- id?: InstanceId;
16
- data: RecordItem["data"];
17
- reactiveData: RecordItem["reactiveData"];
18
- changes: RelationChanges;
19
- reactiveChanges: RelationChanges;
20
- parentRecord?: Model;
21
- childRecords: Model[];
22
- draftContext?: DraftContext;
23
- constructor(idOrParentRecord?: InstanceId | Model, params?: {
24
- createData?: Record<string, any>;
25
- draftContext?: DraftContext;
26
- });
27
- delete(): void;
28
- isNew(): boolean;
29
- hasChanges(): boolean;
30
- makeDraft(): this;
31
- saveDraft(): void;
32
- _saveDraft(parentDraftContext: DraftContext): void;
33
- withContext(fn: () => void): void;
34
- _setDraftItem(id: InstanceId): void;
35
- }
36
- /**
37
- * Define a lazy property on an object that computes its getter and setter on first access.
38
- * Allowing to delay some computation until the property is actually used.
39
- *
40
- * @param object The object on which to define the property.
41
- * @param property The name of the property to define.
42
- * @param makeGetSet A function that returns a tuple containing the getter and optional setter.
43
- * @example
44
- * defineLazyProperty(MyClass.prototype, "myProperty", function() {
45
- * // Some computing that will only run once, on first access.
46
- * return [
47
- * () => this._myProperty,
48
- * (value) => { this._myProperty = value; }
49
- * ];
50
- * });
51
- */
52
- export declare function defineLazyProperty<T, V>(object: object, property: string, makeGetSet: MakeGetSet<T, V>): void;
53
- export declare function combineLists(listA: InstanceId[], deleteList: InstanceId[], addList: InstanceId[]): InstanceId[];
54
- export declare function ensureContext(context: DraftContext, record: Model): Model | undefined;
55
- export declare function withDraftContext<T>(context: DraftContext, fn: () => T): T;
56
- export declare function saveDraftContext(context: DraftContext): void;
57
- export declare function makeDraftContext(parent?: DraftContext): DraftContext;
58
- export declare function formatId(number: number): string;
59
- export declare function resetIdCounter(): void;
@@ -1,18 +0,0 @@
1
- import { Model } from "./model";
2
- import { InstanceId, ModelId, RelationChanges } from "./types";
3
- export declare type DataToSave = Record<ModelId, Record<InstanceId, RelationChanges>>;
4
- export declare const saveHooks: {
5
- onSave: (data: DataToSave) => void;
6
- };
7
- export declare const x2ManyCommands: {
8
- CREATE: number;
9
- UPDATE: number;
10
- DELETE: number;
11
- UNLINK: number;
12
- LINK: number;
13
- CLEAR: number;
14
- SET: number;
15
- };
16
- export declare function getRecordChanges(record: Model, dataToSave?: DataToSave, processedRecords?: Set<Model>): Record<string, any>;
17
- export declare function saveModels(): void;
18
- export declare function commitRecordChanges(record: Model): void;
@@ -1,3 +0,0 @@
1
- import { Model } from "./model";
2
- export declare const Models: Record<string, typeof Model>;
3
- export declare function clearModelRegistry(): void;
@@ -1,4 +0,0 @@
1
- export declare function isRelatedField(fieldType: string): boolean;
2
- export declare function isX2ManyField(fieldType: string): boolean;
3
- export declare function isOne2ManyField(fieldType: string): boolean;
4
- export declare function isMany2OneField(fieldType: string): boolean;
@@ -1,16 +0,0 @@
1
- import { Model } from "./model";
2
- import { ModelId, InstanceId, RecordItem, NormalizedDomain, SearchEntry, DraftContextStore } from "./types";
3
- export declare type StoreData = Record<ModelId, Record<InstanceId, RecordItem>>;
4
- declare class Store {
5
- searches: Record<ModelId, Record<NormalizedDomain, SearchEntry>>;
6
- data: Record<ModelId, Record<InstanceId, RecordItem>>;
7
- getModelData(modelId: ModelId): Record<InstanceId, RecordItem>;
8
- }
9
- export declare const globalStore: Store;
10
- export declare function setStore(store: any): void;
11
- export declare function destroyStore(): void;
12
- export declare function loadRecord(modelId: ModelId, instanceId: InstanceId, data: Record<string, any>): void;
13
- export declare function loadRecordWithRelated(Mod: typeof Model, instanceData: Record<string, any>): Model;
14
- export declare function flushDataToLoad(): void;
15
- export declare function getStoreChanges(store: DraftContextStore): any;
16
- export {};
@@ -1,83 +0,0 @@
1
- import { Model } from "./model";
2
- export declare type FieldTypes = FieldDefinition["type"];
3
- export declare type ModelId = string;
4
- export declare type NormalizedDomain = string;
5
- export declare type InstanceId = number | string;
6
- export declare type FieldName = string;
7
- export declare type ItemData = Record<string, any>;
8
- export declare type RecordItem = {
9
- data: ItemData;
10
- reactiveData: ItemData;
11
- instance: Model;
12
- dataToLoad?: ItemData;
13
- };
14
- export declare type RelationChanges = Record<FieldName, null | InstanceId | [InstanceId[], InstanceId[]]>;
15
- export declare type FieldDefinitionBase = {
16
- fieldName: string;
17
- };
18
- export declare type FieldDefinitionAny = FieldDefinitionBase & {
19
- type: "any";
20
- };
21
- export declare type FieldDefinitionString = FieldDefinitionBase & {
22
- type: "string";
23
- };
24
- export declare type FieldDefinitionChar = FieldDefinitionBase & {
25
- type: "char";
26
- };
27
- export declare type FieldDefinitionText = FieldDefinitionBase & {
28
- type: "text";
29
- };
30
- export declare type FieldDefinitionHtml = FieldDefinitionBase & {
31
- type: "html";
32
- };
33
- export declare type FieldDefinitionDate = FieldDefinitionBase & {
34
- type: "date";
35
- };
36
- export declare type FieldDefinitionDatetime = FieldDefinitionBase & {
37
- type: "datetime";
38
- };
39
- export declare type FieldDefinitionSelection = FieldDefinitionBase & {
40
- type: "selection";
41
- selection: any;
42
- };
43
- export declare type FieldDefinitionReference = FieldDefinitionBase & {
44
- type: "reference";
45
- };
46
- export declare type FieldDefinitionMany2OneReference = FieldDefinitionBase & {
47
- type: "many2one_reference";
48
- };
49
- export declare type FieldDefinitionProperties = FieldDefinitionBase & {
50
- type: "properties";
51
- };
52
- export declare type FieldDefinitionNumber = FieldDefinitionBase & {
53
- type: "number";
54
- };
55
- export declare type FieldDefinitionX2Many = FieldDefinitionBase & {
56
- modelId: ModelId;
57
- };
58
- export declare type FieldDefinitionOne2Many = FieldDefinitionX2Many & {
59
- type: "one2many";
60
- relatedField?: string;
61
- };
62
- export declare type FieldDefinitionMany2One = FieldDefinitionX2Many & {
63
- type: "many2one";
64
- };
65
- export declare type FieldDefinitionMany2Many = FieldDefinitionX2Many & {
66
- type: "many2many";
67
- relationTableName?: string;
68
- };
69
- export declare type X2ManyFieldDefinition = FieldDefinitionOne2Many | FieldDefinitionMany2One | FieldDefinitionMany2Many;
70
- export declare type FieldDefinition = FieldDefinitionAny | FieldDefinitionString | FieldDefinitionChar | FieldDefinitionText | FieldDefinitionHtml | FieldDefinitionDate | FieldDefinitionDatetime | FieldDefinitionSelection | FieldDefinitionReference | FieldDefinitionMany2OneReference | FieldDefinitionProperties | FieldDefinitionNumber | X2ManyFieldDefinition;
71
- export declare type ManyFn<T extends Model> = (() => T[]) & {
72
- add: (m: T) => void;
73
- delete: (m: T) => void;
74
- ids: () => InstanceId[];
75
- };
76
- export declare type SearchEntry = {
77
- ids: InstanceId[];
78
- };
79
- export declare type DraftContextStore = Record<ModelId, Record<InstanceId, Model>>;
80
- export declare type DraftContext = {
81
- parent?: DraftContext;
82
- store: DraftContextStore;
83
- } | undefined;
@@ -1 +0,0 @@
1
- export declare function mapEntries<T, U>(obj: Record<string, T>, fn: (entry: [string, T]) => [string, U]): Record<string, U>;
@@ -1,25 +0,0 @@
1
- export declare class DataPoint {
2
- /**
3
- * @param {RelationalModel} model
4
- * @param {RelationalModelConfig} config
5
- * @param {Record<string, unknown>} data
6
- * @param {unknown} [options]
7
- */
8
- model: any;
9
- _config: any;
10
- _constructor(model: any, config: any, data: any, options: any): void;
11
- /**
12
- * @abstract
13
- * @template [O={}]
14
- * @param {RelationalModelConfig} _config
15
- * @param {Record<string, unknown>} _data
16
- * @param {O | undefined} _options
17
- */
18
- setup(_config: any, _data: any, _options: any): void;
19
- get activeFields(): any;
20
- get fields(): any;
21
- get fieldNames(): string[];
22
- get resModel(): any;
23
- get config(): any;
24
- get context(): any;
25
- }
@@ -1,131 +0,0 @@
1
- import { Model } from "../model";
2
- import { DataPoint } from "./WebDataPoint";
3
- export declare type MakeWebRecord = (model: any, config: any, data: any, options: any) => WebRecord;
4
- export declare class WebRecord extends DataPoint {
5
- static type: string;
6
- orecord: Model;
7
- data: Record<string, any>;
8
- evalContext: Record<string, any>;
9
- evalContextWithVirtualIds: Record<string, any>;
10
- _isEvalContextReady: boolean;
11
- canSaveOnUpdate: boolean;
12
- selected: boolean | undefined;
13
- constructor(...args: Parameters<MakeWebRecord>);
14
- setup(_config: any, data: any, options?: any): void;
15
- get id(): import("../types").InstanceId | undefined;
16
- get resId(): false | import("../types").InstanceId | undefined;
17
- get isNew(): boolean;
18
- get dirty(): boolean;
19
- get isValid(): boolean;
20
- _isRequired(fieldName: string): any;
21
- get isActive(): any;
22
- _isInvisible(fieldName: string): any;
23
- _isReadonly(fieldName: string): any;
24
- update(changes: any, { save }?: any): any;
25
- _updateORecord(orecord: any, changes: any): Promise<void>;
26
- _update(changes: any, { withoutOnchange, withoutParentUpdate }?: any): Promise<void>;
27
- _setEvalContext(): void;
28
- _computeDataContext(): {
29
- withVirtualIds: any;
30
- withoutVirtualIds: any;
31
- };
32
- /**
33
- * @param {Parameters<Record["_save"]>[0]} options
34
- */
35
- save(options: any): Promise<any>;
36
- _save({ reload, onError, nextId }?: any): Promise<any>;
37
- _getChanges(): Record<string, any>;
38
- urgentSave(): Promise<any>;
39
- load(): any;
40
- _load(nextConfig?: {}): Promise<void>;
41
- get resIds(): any;
42
- get hasData(): boolean;
43
- get isInEdition(): boolean;
44
- /**
45
- * @param {Mode} mode
46
- */
47
- switchMode(mode: any): any;
48
- /**
49
- * @param {Mode} mode
50
- */
51
- _switchMode(mode: any): void;
52
- get canBeAbandoned(): boolean;
53
- isDirty(): Promise<boolean>;
54
- toggleSelection(selected: any): any;
55
- _toggleSelection(selected: any): void;
56
- getChanges({ withReadonly }?: any): Promise<any>;
57
- _getOnchangeValues(changes: any): Promise<void>;
58
- /**
59
- * @param {RecordType<string, unknown>} serverValues
60
- * @param {FieldSpecifications} [params]
61
- */
62
- _parseServerValues(serverValues: any, { currentValues, orderBys }?: any): void;
63
- _formatServerValue(fieldType: string, value: any): void;
64
- checkValidity({ displayNotification }?: any): Promise<boolean>;
65
- _checkValidity({ silent, displayNotification, removeInvalidOnly }?: any): void;
66
- /**
67
- * @param {string} fieldName
68
- */
69
- isFieldInvalid(fieldName: string): boolean;
70
- /**
71
- * @param {string} fieldName
72
- */
73
- setInvalidField(fieldName: string): Promise<void>;
74
- _setInvalidField(fieldName: string): Promise<void>;
75
- /**
76
- * @param {string} fieldName
77
- */
78
- resetFieldValidity(fieldName: string): Promise<void>;
79
- _resetFieldValidity(fieldName: string): void;
80
- _removeInvalidFields(...fieldNames: string[]): void;
81
- _displayInvalidFieldNotification(): void;
82
- _setData(data: Record<string, any>, { orderBys, keepChanges }?: any): void;
83
- _applyValues(values: Record<string, any>): void;
84
- _applyChanges(changes: Record<string, any>, serverChanges?: {}): void;
85
- _applyDefaultValues(): void;
86
- _getDefaultValues(fieldNames?: string[]): void;
87
- /**
88
- * This function extracts all properties and adds them to fields and activeFields.
89
- *
90
- * @param {Object[]} properties the list of properties to be extracted
91
- * @param {string} fieldName name of the field containing the properties
92
- * @param {Array} parent Array with ['id, 'display_name'], representing the record to which the definition of properties is linked
93
- * @param {Object} currentValues current values of the record
94
- * @returns An object containing as key `${fieldName}.${property.name}` and as value the value of the property
95
- */
96
- _processProperties(properties: Array<any>, fieldName: string, parent: Array<any>, currentValues?: Object): void;
97
- _preprocessMany2oneChanges(changes: any): Promise<void>;
98
- _preprocessMany2OneReferenceChanges(changes: any): Promise<void>;
99
- _preprocessReferenceChanges(changes: any): Promise<void>;
100
- _preprocessX2manyChanges(changes: any): Promise<void>;
101
- _preprocessPropertiesChanges(changes: any): void;
102
- _preprocessHtmlChanges(changes: any): void;
103
- /**
104
- * Given a possibily incomplete value for a many2one field (i.e. a object { id, display_name } but
105
- * with id and/or display_name being undefined), return the complete value as follows:
106
- * - if a display_name is given but no id, perform a name_create to get an id
107
- * - if an id is given but display_name is undefined, call web_read to get the display_name
108
- * - if both id and display_name are given, return the value as is
109
- * - in any other cases, return false
110
- *
111
- * @param {{ id?: number; display_name?: string }} value
112
- * @param {string} fieldName
113
- * @param {string} resModel
114
- * @returns {Promise<false | { id: number; display_name: string; }>} the completed record { id, display_name } or false
115
- */
116
- _completeMany2OneValue(value: {
117
- id?: number;
118
- display_name?: string;
119
- }, fieldName: string, resModel: string): Promise<void>;
120
- discard(): Promise<void>;
121
- _discard(): void;
122
- duplicate(): void;
123
- delete(): void;
124
- archive(): void;
125
- unarchive(): void;
126
- _toggleArchive(state: boolean): Promise<void>;
127
- _getTextValues(values: any): void;
128
- _addSavePoint(): void;
129
- _createStaticListDatapoint(data: any, fieldName: string, { orderBys }?: any): void;
130
- }
131
- export declare function makeFieldObject(record: any, orecord: Model): any;