@furo/open-models 0.0.0-alpha.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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/CustomPrototypes.d.ts +6 -0
- package/dist/CustomPrototypes.js +4 -0
- package/dist/CustomPrototypes.js.map +1 -0
- package/dist/FDM_OPTIONS.d.ts +16 -0
- package/dist/FDM_OPTIONS.js +8 -0
- package/dist/FDM_OPTIONS.js.map +1 -0
- package/dist/FieldConstraints.d.ts +15 -0
- package/dist/FieldConstraints.js +3 -0
- package/dist/FieldConstraints.js.map +1 -0
- package/dist/FieldNode.d.ts +339 -0
- package/dist/FieldNode.js +835 -0
- package/dist/FieldNode.js.map +1 -0
- package/dist/OM_OPTIONS.d.ts +16 -0
- package/dist/OM_OPTIONS.js +8 -0
- package/dist/OM_OPTIONS.js.map +1 -0
- package/dist/OPEN_MODELS_OPTIONS.d.ts +16 -0
- package/dist/OPEN_MODELS_OPTIONS.js +8 -0
- package/dist/OPEN_MODELS_OPTIONS.js.map +1 -0
- package/dist/OPTIONS.d.ts +16 -0
- package/dist/OPTIONS.js +8 -0
- package/dist/OPTIONS.js.map +1 -0
- package/dist/Registry.d.ts +17 -0
- package/dist/Registry.js +29 -0
- package/dist/Registry.js.map +1 -0
- package/dist/Validator.d.ts +7 -0
- package/dist/Validator.js +3 -0
- package/dist/Validator.js.map +1 -0
- package/dist/ValueState.d.ts +37 -0
- package/dist/ValueState.js +39 -0
- package/dist/ValueState.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/primitives/BOOLEAN.d.ts +14 -0
- package/dist/primitives/BOOLEAN.js +56 -0
- package/dist/primitives/BOOLEAN.js.map +1 -0
- package/dist/primitives/ENUM.d.ts +17 -0
- package/dist/primitives/ENUM.js +76 -0
- package/dist/primitives/ENUM.js.map +1 -0
- package/dist/primitives/INT32.d.ts +18 -0
- package/dist/primitives/INT32.js +98 -0
- package/dist/primitives/INT32.js.map +1 -0
- package/dist/primitives/STRING.d.ts +16 -0
- package/dist/primitives/STRING.js +99 -0
- package/dist/primitives/STRING.js.map +1 -0
- package/dist/proxies/ARRAY.d.ts +165 -0
- package/dist/proxies/ARRAY.js +398 -0
- package/dist/proxies/ARRAY.js.map +1 -0
- package/dist/proxies/MAP.d.ts +101 -0
- package/dist/proxies/MAP.js +225 -0
- package/dist/proxies/MAP.js.map +1 -0
- package/dist/proxies/RECURSION.d.ts +13 -0
- package/dist/proxies/RECURSION.js +51 -0
- package/dist/proxies/RECURSION.js.map +1 -0
- package/dist/well_known/ANY.d.ts +20 -0
- package/dist/well_known/ANY.js +91 -0
- package/dist/well_known/ANY.js.map +1 -0
- package/dist/well_known/Int32Value.d.ts +17 -0
- package/dist/well_known/Int32Value.js +115 -0
- package/dist/well_known/Int32Value.js.map +1 -0
- package/dist/well_known/Int64Value.d.ts +16 -0
- package/dist/well_known/Int64Value.js +105 -0
- package/dist/well_known/Int64Value.js.map +1 -0
- package/package.json +83 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 open-models
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
## Naming Conventions
|
|
2
|
+
The generated models are using camelCase notation for the field names, the UseProtoNames uses whatever was defined in the contract.
|
|
3
|
+
If a name start with an underscore, the model will use an X for the first letter.
|
|
4
|
+
|
|
5
|
+
`_user` => `XUser`
|
|
6
|
+
|
|
7
|
+
https://github.com/googleapis/googleapis/blob/master/google/api/field_behavior.proto
|
|
8
|
+
|
|
9
|
+
## Validators
|
|
10
|
+
|
|
11
|
+
### Class Validators
|
|
12
|
+
|
|
13
|
+
### Instance Validators
|
|
14
|
+
|
|
15
|
+
## Options
|
|
16
|
+
```js
|
|
17
|
+
import {OPEN_MODELS_OPTIONS} from "./x/@furo/open-models/core/OPEN_MODELS_OPTIONS";
|
|
18
|
+
|
|
19
|
+
OPEN_MODELS_OPTIONS.labelFormatter = (l)=> customTranslator(l.replaceAll('.','_').toUpperCase())
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## CustomPrototypes
|
|
24
|
+
|
|
25
|
+
## Reserved words
|
|
26
|
+
- toString
|
|
27
|
+
- valueOf
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomPrototypes.js","sourceRoot":"","sources":["../src/CustomPrototypes.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAU9D,MAAM,CAAC,MAAM,QAAQ,GAAuB,IAAI,GAAG,EAAiB,CAAC;AACrE,MAAM,CAAC,MAAM,OAAO,GAAsB,IAAI,GAAG,EAAgB,CAAC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype str = (d: any) => string;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype nr = (d: any) => number;\n\n// Full qualified type name\ntype typeName = string;\n\nexport const ToString: Map<typeName, str> = new Map<typeName, str>();\nexport const ValueOf: Map<typeName, nr> = new Map<typeName, nr>();\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
UseProtoNames: boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Replace with your own label formatter, if you want to use translations for the labels.
|
|
5
|
+
* @param key
|
|
6
|
+
*/
|
|
7
|
+
labelFormatter: (key: string) => string;
|
|
8
|
+
EmitUnpopulated: boolean;
|
|
9
|
+
EmitDefaultValues: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Use this method to translate the value state messages.
|
|
12
|
+
* @param key
|
|
13
|
+
*/
|
|
14
|
+
valueStateMessageFormatter: (key: string[]) => string;
|
|
15
|
+
}
|
|
16
|
+
export declare const FDM_OPTIONS: Options;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const FDM_OPTIONS = {
|
|
2
|
+
UseProtoNames: true,
|
|
3
|
+
labelFormatter: key => key.replaceAll('.', '_').toUpperCase(),
|
|
4
|
+
EmitDefaultValues: false,
|
|
5
|
+
EmitUnpopulated: false,
|
|
6
|
+
valueStateMessageFormatter: key => key.join(' '),
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=FDM_OPTIONS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FDM_OPTIONS.js","sourceRoot":"","sources":["../src/FDM_OPTIONS.ts"],"names":[],"mappings":"AAuDA,MAAM,CAAC,MAAM,WAAW,GAAY;IAClC,aAAa,EAAE,IAAI;IACnB,cAAc,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE;IAC7D,iBAAiB,EAAE,KAAK;IACxB,eAAe,EAAE,KAAK;IACtB,0BAA0B,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;CACjD,CAAC","sourcesContent":["export interface Options {\n\n // UseProtoNames uses proto field name instead of lowerCamelCase name in JSON\n // field names.\n // UseProtoNames bool\n UseProtoNames: boolean;\n /**\n * Replace with your own label formatter, if you want to use translations for the labels.\n * @param key\n */\n labelFormatter: (key: string) => string;\n\n // EmitUnpopulated specifies whether to emit unpopulated fields. It does not\n // emit unpopulated oneof fields or unpopulated extension fields.\n // The JSON value emitted for unpopulated fields are as follows:\n // ╔═══════╤════════════════════════════╗\n // ║ JSON │ Protobuf field ║\n // ╠═══════╪════════════════════════════╣\n // ║ false │ proto3 boolean fields ║\n // ║ 0 │ proto3 numeric fields ║\n // ║ \"\" │ proto3 string/bytes fields ║\n // ║ null │ proto2 scalar fields ║\n // ║ null │ message fields ║\n // ║ [] │ list fields ║\n // ║ {} │ map fields ║\n // ╚═══════╧════════════════════════════╝\n EmitUnpopulated: boolean;\n\n // EmitDefaultValues specifies whether to emit default-valued primitive fields,\n // empty lists, and empty maps. The fields affected are as follows:\n // ╔═══════╤════════════════════════════════════════╗\n // ║ JSON │ Protobuf field ║\n // ╠═══════╪════════════════════════════════════════╣\n // ║ false │ non-optional scalar boolean fields ║\n // ║ 0 │ non-optional scalar numeric fields ║\n // ║ \"\" │ non-optional scalar string/byte fields ║\n // ║ [] │ empty repeated fields ║\n // ║ {} │ empty map fields ║\n // ╚═══════╧════════════════════════════════════════╝\n //\n // Behaves similarly to EmitUnpopulated, but does not emit \"null\"-value fields,\n // i.e. presence-sensing fields that are omitted will remain omitted to preserve\n // presence-sensing.\n // EmitUnpopulated takes precedence over EmitDefaultValues since the former generates\n // a strict superset of the latter.\n // EmitDefaultValues: boolean;\n\n EmitDefaultValues: boolean;\n /**\n * Use this method to translate the value state messages.\n * @param key\n */\n valueStateMessageFormatter: (key: string[]) => string;\n}\n\nexport const FDM_OPTIONS: Options = {\n UseProtoNames: true,\n labelFormatter: key => key.replaceAll('.', '_').toUpperCase(),\n EmitDefaultValues: false,\n EmitUnpopulated: false,\n valueStateMessageFormatter: key => key.join(' '),\n};\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface FieldConstraints {
|
|
2
|
+
multiple_of?: number | undefined;
|
|
3
|
+
maximum?: number | undefined;
|
|
4
|
+
minimum?: number | undefined;
|
|
5
|
+
exclusive_maximum?: boolean | undefined;
|
|
6
|
+
exclusive_minimum?: boolean | undefined;
|
|
7
|
+
max_length?: number | undefined;
|
|
8
|
+
min_length?: number | undefined;
|
|
9
|
+
pattern?: string | undefined;
|
|
10
|
+
max_items?: number | undefined;
|
|
11
|
+
min_items?: number | undefined;
|
|
12
|
+
unique_items?: boolean | undefined;
|
|
13
|
+
not?: FieldConstraints | undefined;
|
|
14
|
+
required?: boolean | undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldConstraints.js","sourceRoot":"","sources":["../src/FieldConstraints.ts"],"names":[],"mappings":"AAAA,qGAAqG","sourcesContent":["// The constraints are quite similar to https://swagger.io/docs/specification/data-models/data-types/\n\nexport interface FieldConstraints {\n // NUMERIC CONSTRAINTS\n // Use the multipleOf keyword to specify that a number must be the multiple of another number\n multiple_of?: number | undefined;\n // Use the minimum and maximum keywords to specify the range of possible values. \"<=\" is used to check.\n maximum?: number | undefined;\n // Use the minimum and maximum keywords to specify the range of possible values. \">=\" is used to check.\n minimum?: number | undefined;\n // makes maximum using < instead of <=\n exclusive_maximum?: boolean | undefined;\n // makes minimum using < instead of >=\n exclusive_minimum?: boolean | undefined;\n\n // STRING CONSTRAINTS\n // String length can be restricted using minLength and maxLength. \"<\" is used to check.\n max_length?: number | undefined;\n // String length can be restricted using minLength and maxLength. \">\" is used to check.\n min_length?: number | undefined;\n // The pattern keyword lets you define a regular expression template for the string value.\n pattern?: string | undefined;\n\n // ARRAY CONSTRAINTS\n // Array size can be restricted using min_items and max_items. \"<=\" is used to check.\n max_items?: number | undefined;\n // Array size can be restricted using min_items and max_items. \">=\" is used to check.\n min_items?: number | undefined;\n // You can use uniqueItems: true to specify that all items in the array must be unique. ?? Set ??\n unique_items?: boolean | undefined;\n\n // use this to negate\n not?: FieldConstraints | undefined; // {not:{max_items:4,min_items:4}} or not:{multiple_of:7}\n\n required?: boolean | undefined;\n}\n"]}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* notes: i18n is not part of the api anymore
|
|
3
|
+
*/
|
|
4
|
+
import { ValueState } from './ValueState.js';
|
|
5
|
+
import { FieldConstraints } from './FieldConstraints.js';
|
|
6
|
+
type EventType = 'field-value-changed' | 'this-field-value-changed' | 'this-state-changed' | 'state-changed' | 'validity-changed' | 'array-changed' | 'this-array-changed' | 'map-changed' | 'this-map-changed' | 'model-injected';
|
|
7
|
+
type Meta = {
|
|
8
|
+
index?: number;
|
|
9
|
+
oldValue?: unknown;
|
|
10
|
+
initialValue: unknown;
|
|
11
|
+
typeName: string;
|
|
12
|
+
fieldName?: string;
|
|
13
|
+
valueState: ValueState;
|
|
14
|
+
stateMessage: string;
|
|
15
|
+
nodeFields: FieldDescriptor[];
|
|
16
|
+
readonly: boolean;
|
|
17
|
+
required: boolean;
|
|
18
|
+
isArrayNode: boolean;
|
|
19
|
+
isRecursionNode: boolean;
|
|
20
|
+
isAnyNode: boolean;
|
|
21
|
+
isValid: boolean;
|
|
22
|
+
isPristine: boolean;
|
|
23
|
+
eventListener: Map<string, {
|
|
24
|
+
callbackfn: CustomEventListener;
|
|
25
|
+
options?: AddEventListenerOptions | boolean;
|
|
26
|
+
}[]>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Primitives have always a value field
|
|
30
|
+
*/
|
|
31
|
+
interface IPrimitive extends FieldNode {
|
|
32
|
+
_value: unknown;
|
|
33
|
+
}
|
|
34
|
+
interface CustomEventListener {
|
|
35
|
+
(evt: CustomEvent): void;
|
|
36
|
+
}
|
|
37
|
+
type FieldDescriptor = {
|
|
38
|
+
fieldName: string;
|
|
39
|
+
jsonName: string;
|
|
40
|
+
FieldConstructor: any;
|
|
41
|
+
ValueConstructor?: new () => FieldNode;
|
|
42
|
+
constraints?: FieldConstraints;
|
|
43
|
+
};
|
|
44
|
+
export interface ValueStateSummary {
|
|
45
|
+
/**
|
|
46
|
+
* path of the field
|
|
47
|
+
*
|
|
48
|
+
* `fullName` for a violation in the `fullName` value
|
|
49
|
+
* `emailAddresses[1].email` for a violation in the `email` field of the first `emailAddresses` message
|
|
50
|
+
* `emailAddresses[3].type[2]` for a violation in the second `type` value in the third `emailAddresses` message.
|
|
51
|
+
*/
|
|
52
|
+
field: string;
|
|
53
|
+
state: ValueState;
|
|
54
|
+
message: string;
|
|
55
|
+
}
|
|
56
|
+
export declare abstract class FieldNode {
|
|
57
|
+
protected ___isEmpty: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Marker for primitive types
|
|
60
|
+
*/
|
|
61
|
+
__isPrimitive: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Parent node of a node. This is undefined on root nodes.
|
|
64
|
+
*/
|
|
65
|
+
__parentNode: FieldNode | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Meta data of a field node.
|
|
68
|
+
*/
|
|
69
|
+
__meta: Meta;
|
|
70
|
+
private ___rootNode;
|
|
71
|
+
private ___readonlyState;
|
|
72
|
+
/**
|
|
73
|
+
* Root node of a node
|
|
74
|
+
*/
|
|
75
|
+
get __rootNode(): FieldNode;
|
|
76
|
+
/**
|
|
77
|
+
* Root node of a node. Do not set this value by yourself.
|
|
78
|
+
* @param value
|
|
79
|
+
*/
|
|
80
|
+
set __rootNode(value: FieldNode);
|
|
81
|
+
/**
|
|
82
|
+
* Empty state of the node
|
|
83
|
+
*/
|
|
84
|
+
get __isEmpty(): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Empty state of the node
|
|
87
|
+
* @param empty
|
|
88
|
+
*/
|
|
89
|
+
set __isEmpty(empty: boolean);
|
|
90
|
+
constructor(_initData: undefined, parent?: FieldNode, parentAttributeName?: string);
|
|
91
|
+
/**
|
|
92
|
+
* Get a FieldNode by giving a field path using the proto names for the fields.
|
|
93
|
+
*
|
|
94
|
+
*
|
|
95
|
+
*
|
|
96
|
+
* - `email_addresses[3].type[2]` for the second `type` value in the third `email_addresses` message.
|
|
97
|
+
* - `user.location.street` for the street in location in user.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} deepPath - Path of the field.
|
|
100
|
+
*/
|
|
101
|
+
__getFieldNodeByPath(deepPath?: string): FieldNode | undefined;
|
|
102
|
+
set __readonly(v: boolean);
|
|
103
|
+
get __readonly(): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Build up the model with the literal type. The literal type matches the interface from ITypeName.
|
|
106
|
+
* @param {} literal - The literal type matches the interface from ITypeName.
|
|
107
|
+
*/
|
|
108
|
+
__fromLiteral(literal: unknown): void;
|
|
109
|
+
private __setModelValidStateTrue;
|
|
110
|
+
/**
|
|
111
|
+
* Updates the model from literal data, without changing the validity and value state.
|
|
112
|
+
*
|
|
113
|
+
* @param literal
|
|
114
|
+
*/
|
|
115
|
+
__updateWithLiteral(literal: unknown): void;
|
|
116
|
+
__stringify(): string;
|
|
117
|
+
/**
|
|
118
|
+
* Converts the model to a JSON struct wich matches the protobuf spec.
|
|
119
|
+
* If the `UseProtoNames` option is set to false, lowerCamelCase is produced.
|
|
120
|
+
*/
|
|
121
|
+
__toJson(): any;
|
|
122
|
+
/**
|
|
123
|
+
* Build up the model, using the transport Json. If UseProtoNames is set to false, lowerCamelCase is expected.
|
|
124
|
+
*
|
|
125
|
+
* @param {JSON} data - Transport Json
|
|
126
|
+
*/
|
|
127
|
+
__fromJson(data: any): void;
|
|
128
|
+
/**
|
|
129
|
+
* Helper function to create a literal type from a json type
|
|
130
|
+
* @param {JSON} data - Transport Json
|
|
131
|
+
*/
|
|
132
|
+
__mapJsonToLiteral(data: any): any;
|
|
133
|
+
/**
|
|
134
|
+
* Converts the model to a literal type. The literal type matches the interface from ITypeName.
|
|
135
|
+
*/
|
|
136
|
+
__toLiteral(): any;
|
|
137
|
+
get __fieldPath(): string;
|
|
138
|
+
___pathBuilder(parts: string[]): string[];
|
|
139
|
+
get __label(): string;
|
|
140
|
+
get __placeholder(): string;
|
|
141
|
+
get __ariaDescription(): string;
|
|
142
|
+
/**
|
|
143
|
+
* Returns a list of all states of a node and its children.
|
|
144
|
+
*
|
|
145
|
+
* ```json
|
|
146
|
+
* [
|
|
147
|
+
* {
|
|
148
|
+
* "field": "id",
|
|
149
|
+
* "state": "Error",
|
|
150
|
+
* "message": "This field is invalid"
|
|
151
|
+
* },
|
|
152
|
+
* {
|
|
153
|
+
* "field": "display_name",
|
|
154
|
+
* "state": "Error",
|
|
155
|
+
* "message": "This field is invalid"
|
|
156
|
+
* }
|
|
157
|
+
* ]
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
__getAllStates(): ValueStateSummary[];
|
|
161
|
+
private ___getAllStates;
|
|
162
|
+
/**
|
|
163
|
+
* Applies a list of states to a node and its children.
|
|
164
|
+
*
|
|
165
|
+
* Keep in mind, that the message must be already translated.
|
|
166
|
+
*
|
|
167
|
+
* ```json
|
|
168
|
+
* {
|
|
169
|
+
* "field": "id",
|
|
170
|
+
* "state": "Error",
|
|
171
|
+
* "message": "This field is invalid"
|
|
172
|
+
*}
|
|
173
|
+
*
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
*/
|
|
177
|
+
__applyValueStates(...states: ValueStateSummary[]): void;
|
|
178
|
+
/**
|
|
179
|
+
* Returns the valid state of a node.
|
|
180
|
+
* - A node is valid when all children are valid.
|
|
181
|
+
* - A node is valid when freshly initialized, even when some children have invalid values.
|
|
182
|
+
*
|
|
183
|
+
* use `validate()` to be sure to have the correct validity state.
|
|
184
|
+
*
|
|
185
|
+
* Use __meta.StateMessage to receive the state of a node. The `__meta.StateMessage` is only available on an explicit field, where the validity state is populated upwards.
|
|
186
|
+
*/
|
|
187
|
+
get __isValid(): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Initialized fields are pristine as long nothing changes inside the model.
|
|
190
|
+
*
|
|
191
|
+
* Use this on rootNodes only.
|
|
192
|
+
*/
|
|
193
|
+
get __isPristine(): boolean;
|
|
194
|
+
/**
|
|
195
|
+
* The toString() method of Object instances returns a string representing this object. This method is meant to be overridden by `CustomPrototypes.ToString`.
|
|
196
|
+
* If no `CustomPrototypes` is set, it will try to find a display_name attribute on the node and uses that for the output.
|
|
197
|
+
*
|
|
198
|
+
* If there is no display_name `[object TypeName]` is returned.
|
|
199
|
+
*/
|
|
200
|
+
toString(): string;
|
|
201
|
+
/**
|
|
202
|
+
* The valueOf() method of Object instances converts the this value to an object.
|
|
203
|
+
* This method is meant to be overridden by derived objects for custom type conversion logic.
|
|
204
|
+
*/
|
|
205
|
+
valueOf(): number;
|
|
206
|
+
/**
|
|
207
|
+
* Helper method to build up labels, placeholders,...
|
|
208
|
+
* @protected
|
|
209
|
+
*/
|
|
210
|
+
protected __getBaseName(): string;
|
|
211
|
+
/**
|
|
212
|
+
* Helper method to construct the __fieldPath
|
|
213
|
+
* @param parts
|
|
214
|
+
* @protected
|
|
215
|
+
*/
|
|
216
|
+
protected ___fieldNameBuilder(parts: string[]): string[];
|
|
217
|
+
/**
|
|
218
|
+
* Validate the node and all child nodes of it.
|
|
219
|
+
*/
|
|
220
|
+
__validate(): void;
|
|
221
|
+
/**
|
|
222
|
+
* Validates all parents of an element. This is done when you set a value on any child/attribute of a node directly
|
|
223
|
+
* @param {FieldNode} node - Any FieldNode
|
|
224
|
+
*/
|
|
225
|
+
protected __validateBottomUp(node: FieldNode): void;
|
|
226
|
+
/**
|
|
227
|
+
* Validates all parent nodes if a sub-field was changed.
|
|
228
|
+
* @protected
|
|
229
|
+
*/
|
|
230
|
+
protected __climbUpValidation(): void;
|
|
231
|
+
/**
|
|
232
|
+
* Additional "constraint" checker for primitive types, i.e. INT32 can only range from -2147483648 to 2147483647, but js uses always a float64 to handle numbers
|
|
233
|
+
* @protected
|
|
234
|
+
*/
|
|
235
|
+
protected __checkTypeBoundaries(): string[] | undefined;
|
|
236
|
+
/**
|
|
237
|
+
* Executes the validation process.
|
|
238
|
+
* @param node
|
|
239
|
+
* @protected
|
|
240
|
+
*/
|
|
241
|
+
protected __validationExecuter(node: FieldNode): void;
|
|
242
|
+
/**
|
|
243
|
+
* Receives all constraints of a node. Use this in your custom validators or components.
|
|
244
|
+
*/
|
|
245
|
+
__getConstraints(): FieldConstraints | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* Set the value state
|
|
248
|
+
* @param {ValueState} state - The state of the node.
|
|
249
|
+
* @param {string[]} message - Description for the formatter.
|
|
250
|
+
*/
|
|
251
|
+
__setValueState(state: ValueState, message: string[]): void;
|
|
252
|
+
/**
|
|
253
|
+
* Resets the node to the last inserted literal or to the initial state.
|
|
254
|
+
* // todo: reset to default values not just the empty state
|
|
255
|
+
*/
|
|
256
|
+
__reset(): void;
|
|
257
|
+
/**
|
|
258
|
+
* Clear clears the element downwards and set __isEmpty to true on all sub nodes.
|
|
259
|
+
*
|
|
260
|
+
* A cleared field is not populated on `__toLiteral` or `__toJson` when the option `EmitUnpopulated` or `EmitDefaultValues` is set to false.
|
|
261
|
+
*/
|
|
262
|
+
__clear(): void;
|
|
263
|
+
/**
|
|
264
|
+
* Helper method to update a skalar / primitive field of a type. Used by the generated models.
|
|
265
|
+
* Triggers also the validation and clearance, if needed.
|
|
266
|
+
*
|
|
267
|
+
* @param {FieldNode} targetNode - The field of a FieldNode
|
|
268
|
+
* @param {string | boolean | number} value - The value you want to set
|
|
269
|
+
* @protected
|
|
270
|
+
*/
|
|
271
|
+
protected __PrimitivesSetter(targetNode: IPrimitive, value: unknown): void;
|
|
272
|
+
/**
|
|
273
|
+
* Helper method to update a field of a type. Used by the generated models.
|
|
274
|
+
* Triggers also the validation and clearance, if needed.
|
|
275
|
+
*
|
|
276
|
+
* @param {FieldNode} targetNode - The field of a FieldNode
|
|
277
|
+
* @param {} literalData - The literal type matches the interface from ITypeName.
|
|
278
|
+
* @protected
|
|
279
|
+
*/
|
|
280
|
+
protected __TypeSetter(targetNode: FieldNode, literalData: unknown | undefined | null): void;
|
|
281
|
+
/**
|
|
282
|
+
* Notifies field changes
|
|
283
|
+
* @param bubbles
|
|
284
|
+
* @protected
|
|
285
|
+
*/
|
|
286
|
+
protected __notifyFieldValueChange(bubbles?: boolean): void;
|
|
287
|
+
/**
|
|
288
|
+
* Returns the child nodes of a node.
|
|
289
|
+
*/
|
|
290
|
+
get __childNodes(): any[];
|
|
291
|
+
/**
|
|
292
|
+
* Broadcast an event to all child nodes of a field node.
|
|
293
|
+
* @param event
|
|
294
|
+
*/
|
|
295
|
+
__broadcastEvent(event: CustomEvent): void;
|
|
296
|
+
/**
|
|
297
|
+
* Dispatches a custom event on a FieldNode
|
|
298
|
+
* @param {CustomEvent} event - A generic custom event.
|
|
299
|
+
*/
|
|
300
|
+
__dispatchEvent(event: CustomEvent): CustomEvent;
|
|
301
|
+
/**
|
|
302
|
+
* Helper method to invoke/execute the event on the current node
|
|
303
|
+
* @param event
|
|
304
|
+
* @protected
|
|
305
|
+
*/
|
|
306
|
+
protected __triggerNodeEvents(event: CustomEvent<FieldNode>): void;
|
|
307
|
+
/**
|
|
308
|
+
* Add a handler to a node
|
|
309
|
+
* @param {string} type - A case-sensitive string representing the event type to listen for.
|
|
310
|
+
* @param {function} listener - The object that receives a notification (an object that implements the Event interface) when an event of the specified type occurs. This must be null, an object with a handleEvent() method, or a JavaScript function. See The event listener callback for details on the callback itself.
|
|
311
|
+
* @param {} options - An object that specifies characteristics about the event listener. \n\nThe available option is `once:boolean`
|
|
312
|
+
*/
|
|
313
|
+
__addEventListener(type: EventType, listener: CustomEventListener, options?: boolean | AddEventListenerOptions): void;
|
|
314
|
+
__addCustomEventListener(type: string, handler: CustomEventListener, options?: boolean | AddEventListenerOptions): void;
|
|
315
|
+
/**
|
|
316
|
+
* Removes the handler from a node
|
|
317
|
+
* @param type
|
|
318
|
+
* @param handler
|
|
319
|
+
* @param options
|
|
320
|
+
*/
|
|
321
|
+
__removeEventListener(type: EventType, handler: CustomEventListener, options?: boolean | EventListenerOptions): void;
|
|
322
|
+
/**
|
|
323
|
+
* Removes the handler from a node
|
|
324
|
+
* @param type
|
|
325
|
+
* @param handler
|
|
326
|
+
* @param options
|
|
327
|
+
*/
|
|
328
|
+
__removeCustomEventListener(type: string, handler: CustomEventListener, options?: boolean | EventListenerOptions): void;
|
|
329
|
+
/**
|
|
330
|
+
* if some child is not empty, set isEmpty to false, all the way up to the root node
|
|
331
|
+
* @private
|
|
332
|
+
*/
|
|
333
|
+
protected ___updateNotEmptyPath(): void;
|
|
334
|
+
protected __checkConstraints(fieldConstraints: FieldConstraints): string[] | undefined;
|
|
335
|
+
private __toLowerCamelCase;
|
|
336
|
+
private __toLowerCamelCaseWithoutXPrefix;
|
|
337
|
+
private __toSnakeCase;
|
|
338
|
+
}
|
|
339
|
+
export {};
|