@odoo/owl 2.8.1 → 3.0.0-alpha.2
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/dist/owl-devtools.zip +0 -0
- package/dist/owl.cjs.js +580 -184
- package/dist/owl.es.js +573 -185
- package/dist/owl.iife.js +580 -184
- package/dist/owl.iife.min.js +1 -1
- package/dist/types/common/types.d.ts +28 -0
- package/dist/types/owl.d.ts +161 -77
- package/dist/types/runtime/app.d.ts +3 -0
- package/dist/types/runtime/cancellableContext.d.ts +15 -0
- package/dist/types/runtime/cancellablePromise.d.ts +15 -0
- package/dist/types/runtime/component.d.ts +5 -3
- package/dist/types/runtime/component_node.d.ts +7 -5
- package/dist/types/runtime/executionContext.d.ts +0 -0
- package/dist/types/runtime/index.d.ts +3 -0
- package/dist/types/runtime/listOperation.d.ts +1 -0
- package/dist/types/runtime/plugins.d.ts +39 -0
- package/dist/types/runtime/reactivity.d.ts +1 -12
- package/dist/types/runtime/registry.d.ts +15 -0
- package/dist/types/runtime/relationalModel/discussModel.d.ts +19 -0
- package/dist/types/runtime/relationalModel/discussModelTypes.d.ts +22 -0
- package/dist/types/runtime/relationalModel/field.d.ts +20 -0
- package/dist/types/runtime/relationalModel/model.d.ts +59 -0
- package/dist/types/runtime/relationalModel/modelData.d.ts +18 -0
- package/dist/types/runtime/relationalModel/modelRegistry.d.ts +3 -0
- package/dist/types/runtime/relationalModel/modelUtils.d.ts +4 -0
- package/dist/types/runtime/relationalModel/store.d.ts +16 -0
- package/dist/types/runtime/relationalModel/types.d.ts +83 -0
- package/dist/types/runtime/relationalModel/util.d.ts +1 -0
- package/dist/types/runtime/relationalModel/web/WebDataPoint.d.ts +25 -0
- package/dist/types/runtime/relationalModel/web/WebRecord.d.ts +131 -0
- package/dist/types/runtime/relationalModel/web/WebStaticList.d.ts +63 -0
- package/dist/types/runtime/relationalModel/web/webModel.d.ts +5 -0
- package/dist/types/runtime/relationalModel/web/webModelTypes.d.ts +139 -0
- package/dist/types/runtime/signals.d.ts +17 -0
- package/dist/types/runtime/task.d.ts +12 -0
- package/dist/types/utils/registry.d.ts +15 -0
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
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;
|
|
@@ -0,0 +1,18 @@
|
|
|
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;
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,83 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mapEntries<T, U>(obj: Record<string, T>, fn: (entry: [string, T]) => [string, U]): Record<string, U>;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
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;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Model } from "../model";
|
|
2
|
+
import { DraftContext, InstanceId, ManyFn } from "../types";
|
|
3
|
+
import { DataPoint } from "./WebDataPoint";
|
|
4
|
+
import { MakeWebRecord, WebRecord } from "./WebRecord";
|
|
5
|
+
export declare type StaticListConfig = {
|
|
6
|
+
parentRecord: any;
|
|
7
|
+
orecord: Model;
|
|
8
|
+
fieldName: string;
|
|
9
|
+
makeWebRecord: MakeWebRecord;
|
|
10
|
+
};
|
|
11
|
+
export declare type MakeNewRecordParams = {
|
|
12
|
+
activeFields: Object;
|
|
13
|
+
fields: Object;
|
|
14
|
+
context?: Object;
|
|
15
|
+
withoutParent?: boolean;
|
|
16
|
+
mode?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare class StaticList extends DataPoint {
|
|
19
|
+
sconfig: StaticListConfig;
|
|
20
|
+
_records: () => WebRecord[];
|
|
21
|
+
orecordList: ManyFn<Model>;
|
|
22
|
+
_webRecords: Record<InstanceId, WebRecord>;
|
|
23
|
+
_draftRecord: Map<InstanceId, WebRecord>;
|
|
24
|
+
draftContext: DraftContext;
|
|
25
|
+
draftORecord: Model;
|
|
26
|
+
constructor(sconfig: StaticListConfig);
|
|
27
|
+
_constructor(sconfig: StaticListConfig): void;
|
|
28
|
+
_defineRecords(): void;
|
|
29
|
+
_getRecord(record: Model): WebRecord;
|
|
30
|
+
get count(): number;
|
|
31
|
+
get records(): WebRecord[];
|
|
32
|
+
get resIds(): InstanceId[];
|
|
33
|
+
get currentIds(): string;
|
|
34
|
+
get limit(): number;
|
|
35
|
+
get offset(): number;
|
|
36
|
+
get orderBy(): never[];
|
|
37
|
+
get evalContext(): any;
|
|
38
|
+
extendRecord(params: MakeNewRecordParams, record: WebRecord): Promise<any>;
|
|
39
|
+
_getDraftRecord(params: MakeNewRecordParams, webrecord: WebRecord, activeFields: Record<string, any>): Promise<WebRecord>;
|
|
40
|
+
validateExtendedRecord(record: WebRecord): void;
|
|
41
|
+
_getActiveFields(params: MakeNewRecordParams): Record<string, any>;
|
|
42
|
+
_makeNewRecord(params: any): Promise<WebRecord>;
|
|
43
|
+
_createRecordDatapoint(data: any, params?: any): WebRecord;
|
|
44
|
+
get editedRecord(): null;
|
|
45
|
+
enterEditMode(): void;
|
|
46
|
+
leaveEditMode(): void;
|
|
47
|
+
get selection(): never[];
|
|
48
|
+
canResequence(): void;
|
|
49
|
+
resequence(): void;
|
|
50
|
+
load(): void;
|
|
51
|
+
sortBy(): void;
|
|
52
|
+
addNewRecord(): void;
|
|
53
|
+
addNewRecordAtIndex(): void;
|
|
54
|
+
applyCommands(): void;
|
|
55
|
+
linkTo(): void;
|
|
56
|
+
unlinkFrom(): void;
|
|
57
|
+
forget(): void;
|
|
58
|
+
moveRecord(): void;
|
|
59
|
+
addAndRemove(): void;
|
|
60
|
+
duplicateRecords(): void;
|
|
61
|
+
delete(): void;
|
|
62
|
+
}
|
|
63
|
+
export declare function completeActiveFields(activeFields: Record<string, any>, extraActiveFields: Record<string, any>): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Model } from "../model";
|
|
2
|
+
import { ModelId } from "../types";
|
|
3
|
+
import { WebModelConfig } from "./webModelTypes";
|
|
4
|
+
export declare function getOrMakeModel(modelId: ModelId): typeof Model;
|
|
5
|
+
export declare function makeModelFromWeb(config: WebModelConfig, processedModel?: Set<string>): typeof Model;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export interface WebModelConfig {
|
|
2
|
+
isMonoRecord: boolean;
|
|
3
|
+
context: Record<string, any>;
|
|
4
|
+
fieldsToAggregate: string[];
|
|
5
|
+
activeFields?: {
|
|
6
|
+
[key: string]: ActiveFieldInfo;
|
|
7
|
+
};
|
|
8
|
+
fields: {
|
|
9
|
+
[key: string]: FieldInfo;
|
|
10
|
+
};
|
|
11
|
+
isRoot: boolean;
|
|
12
|
+
resModel: string;
|
|
13
|
+
groupBy: string[];
|
|
14
|
+
resId?: number | false;
|
|
15
|
+
resIds?: number[];
|
|
16
|
+
mode?: "edit" | "readonly";
|
|
17
|
+
domain: any[];
|
|
18
|
+
orderBy: OrderBy[];
|
|
19
|
+
groups?: Record<string, any>;
|
|
20
|
+
offset: number;
|
|
21
|
+
limit: number;
|
|
22
|
+
countLimit: number;
|
|
23
|
+
currentGroups?: {
|
|
24
|
+
params: string;
|
|
25
|
+
groups: any[];
|
|
26
|
+
};
|
|
27
|
+
loadId?: string;
|
|
28
|
+
openGroupsByDefault?: boolean;
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}
|
|
31
|
+
export interface FieldInfo {
|
|
32
|
+
change_default?: boolean;
|
|
33
|
+
groupable?: boolean;
|
|
34
|
+
name?: string;
|
|
35
|
+
readonly?: boolean;
|
|
36
|
+
required?: boolean;
|
|
37
|
+
searchable?: boolean;
|
|
38
|
+
sortable?: boolean;
|
|
39
|
+
store?: boolean;
|
|
40
|
+
string?: string;
|
|
41
|
+
type?: string;
|
|
42
|
+
help?: string;
|
|
43
|
+
translate?: boolean;
|
|
44
|
+
trim?: boolean;
|
|
45
|
+
context?: {};
|
|
46
|
+
domain?: any[];
|
|
47
|
+
relation?: string;
|
|
48
|
+
related?: string;
|
|
49
|
+
selection?: Array<[string, string]>;
|
|
50
|
+
groups?: string;
|
|
51
|
+
relation_field?: string;
|
|
52
|
+
aggregator?: string;
|
|
53
|
+
digits?: [number, number];
|
|
54
|
+
size?: number;
|
|
55
|
+
currency_field?: string;
|
|
56
|
+
sanitize?: boolean;
|
|
57
|
+
sanitize_tags?: boolean;
|
|
58
|
+
definition_record?: string;
|
|
59
|
+
definition_record_field?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ActiveFieldInfo {
|
|
62
|
+
context: {};
|
|
63
|
+
invisible: string | boolean;
|
|
64
|
+
readonly: string | boolean;
|
|
65
|
+
required: string | boolean;
|
|
66
|
+
onChange: boolean;
|
|
67
|
+
forceSave: boolean;
|
|
68
|
+
isHandle: boolean;
|
|
69
|
+
related?: {
|
|
70
|
+
activeFields: {
|
|
71
|
+
[key: string]: ActiveFieldInfo;
|
|
72
|
+
};
|
|
73
|
+
fields: {
|
|
74
|
+
[key: string]: FieldInfo;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export interface WebModelConfigContext {
|
|
79
|
+
default_is_company: boolean;
|
|
80
|
+
lang: string;
|
|
81
|
+
tz: string;
|
|
82
|
+
uid: number;
|
|
83
|
+
allowed_company_ids: number[];
|
|
84
|
+
}
|
|
85
|
+
export interface RelationalModelParams {
|
|
86
|
+
config: {
|
|
87
|
+
activeFields: {
|
|
88
|
+
[key: string]: ActiveFieldInfo;
|
|
89
|
+
};
|
|
90
|
+
[key: string]: any;
|
|
91
|
+
};
|
|
92
|
+
limit?: number;
|
|
93
|
+
groupsLimit?: number;
|
|
94
|
+
countLimit?: number;
|
|
95
|
+
defaultOrderBy?: OrderBy[];
|
|
96
|
+
maxGroupByDepth?: number;
|
|
97
|
+
groupByInfo?: Record<string, any>;
|
|
98
|
+
multiEdit?: boolean;
|
|
99
|
+
activeIdsLimit?: number;
|
|
100
|
+
state?: {
|
|
101
|
+
specialDataCaches?: Record<string, any>;
|
|
102
|
+
};
|
|
103
|
+
useSendBeaconToSaveUrgently?: boolean;
|
|
104
|
+
hooks?: Partial<RelationalModelHooks>;
|
|
105
|
+
[key: string]: any;
|
|
106
|
+
}
|
|
107
|
+
export interface OrderBy {
|
|
108
|
+
name: string;
|
|
109
|
+
asc?: boolean;
|
|
110
|
+
}
|
|
111
|
+
export interface SearchParams {
|
|
112
|
+
context?: Record<string, any>;
|
|
113
|
+
resId?: number | false;
|
|
114
|
+
resIds?: number[];
|
|
115
|
+
domain?: any[];
|
|
116
|
+
groupBy?: string[];
|
|
117
|
+
orderBy?: OrderBy[];
|
|
118
|
+
limit?: number;
|
|
119
|
+
offset?: number;
|
|
120
|
+
countLimit?: number;
|
|
121
|
+
}
|
|
122
|
+
export interface Services {
|
|
123
|
+
action: any;
|
|
124
|
+
dialog: any;
|
|
125
|
+
notification: any;
|
|
126
|
+
orm: any;
|
|
127
|
+
}
|
|
128
|
+
export interface OnChangeParams {
|
|
129
|
+
changes?: Record<string, any>;
|
|
130
|
+
fieldNames?: string[];
|
|
131
|
+
evalContext?: Record<string, any>;
|
|
132
|
+
onError?: (error: any) => void;
|
|
133
|
+
cache?: any;
|
|
134
|
+
}
|
|
135
|
+
export interface RelationalModelHooks {
|
|
136
|
+
onWillLoadRoot: (config: WebModelConfig) => Promise<void>;
|
|
137
|
+
onRootLoaded: (root: any) => Promise<void>;
|
|
138
|
+
onWillDisplayOnchangeWarning: (warning: any) => Promise<void>;
|
|
139
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Atom, Computation, Derived, Opts } from "../common/types";
|
|
2
|
+
export declare function signal<T>(value: T, opts?: Opts): {
|
|
3
|
+
readonly get: () => T;
|
|
4
|
+
readonly set: (newValue: T | ((prevValue: T) => T)) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare function effect<T>(fn: () => T, opts?: Opts): () => void;
|
|
7
|
+
export declare function derived<T>(fn: () => T, opts?: Opts): () => T;
|
|
8
|
+
export declare function onReadAtom(atom: Atom): void;
|
|
9
|
+
export declare function onWriteAtom(atom: Atom): void;
|
|
10
|
+
export declare function withoutReactivity<T extends (...args: any[]) => any>(fn: T): ReturnType<T>;
|
|
11
|
+
export declare function getCurrentComputation(): Computation<any> | undefined;
|
|
12
|
+
export declare function setComputation(computation: Computation | undefined): void;
|
|
13
|
+
export declare function runWithComputation<T>(computation: Computation, fn: () => T): T;
|
|
14
|
+
export declare function setSignalHooks(hooks: {
|
|
15
|
+
onDerived: (derived: Derived<any, any>) => void;
|
|
16
|
+
}): void;
|
|
17
|
+
export declare function resetSignalHooks(): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TaskContext } from "./cancellableContext";
|
|
2
|
+
export declare class Task<T = any> {
|
|
3
|
+
_onCancelled?: Function | undefined;
|
|
4
|
+
_promise: Promise<T>;
|
|
5
|
+
_ctx?: TaskContext;
|
|
6
|
+
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason: any) => void) => void, _onCancelled?: Function | undefined);
|
|
7
|
+
then(onFulfilled: (value: any) => any, onRejected: (error: any) => any): Promise<any>;
|
|
8
|
+
catch(onRejected: (error: any) => any): Promise<any>;
|
|
9
|
+
finally(onFinally: () => any): Promise<T>;
|
|
10
|
+
cancel(): void;
|
|
11
|
+
get [Symbol.toStringTag](): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Schema } from "../runtime/validation";
|
|
2
|
+
declare type Fn<T> = () => T;
|
|
3
|
+
export declare class Registry<T> {
|
|
4
|
+
_map: {
|
|
5
|
+
[key: string]: [number, T];
|
|
6
|
+
};
|
|
7
|
+
_name: string;
|
|
8
|
+
_schema?: Schema;
|
|
9
|
+
items: Fn<T[]>;
|
|
10
|
+
entries: Fn<[string, T][]>;
|
|
11
|
+
constructor(name?: string, schema?: Schema);
|
|
12
|
+
set(key: string, value: T, sequence?: number): void;
|
|
13
|
+
get(key: string, defaultValue?: T): T;
|
|
14
|
+
}
|
|
15
|
+
export {};
|