breeze-client 2.2.2 → 3.0.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 +1 -1
- package/README.md +83 -63
- package/adapters/abstract-data-service-adapter.d.ts +120 -0
- package/adapters/abstract-data-service-adapter.js +395 -0
- package/adapters/abstract-data-service-adapter.js.map +1 -0
- package/adapters/adapter-ajax-fetch.d.ts +12 -0
- package/adapters/adapter-ajax-fetch.js +13 -0
- package/adapters/adapter-ajax-fetch.js.map +1 -0
- package/{adapter-ajax-post → adapters}/adapter-ajax-post.d.ts +40 -36
- package/{fesm2022/breeze-client-adapter-ajax-post.mjs → adapters/adapter-ajax-post.js} +80 -82
- package/adapters/adapter-ajax-post.js.map +1 -0
- package/{adapter-ajax-fetch → adapters}/adapter-core.d.ts +4 -4
- package/{fesm2022/breeze-client-adapter-uri-builder-json.mjs → adapters/adapter-core.js} +48 -91
- package/adapters/adapter-core.js.map +1 -0
- package/adapters/adapter-data-service-webapi.d.ts +9 -0
- package/{fesm2022/breeze-client-adapter-data-service-webapi.mjs → adapters/adapter-data-service-webapi.js} +105 -107
- package/adapters/adapter-data-service-webapi.js.map +1 -0
- package/adapters/adapter-model-library-backing-store.d.ts +32 -0
- package/adapters/adapter-model-library-backing-store.js +321 -0
- package/adapters/adapter-model-library-backing-store.js.map +1 -0
- package/adapters/adapter-uri-builder-json.d.ts +11 -0
- package/adapters/adapter-uri-builder-json.js +40 -0
- package/adapters/adapter-uri-builder-json.js.map +1 -0
- package/adapters/http.d.ts +52 -0
- package/adapters/http.js +202 -0
- package/adapters/http.js.map +1 -0
- package/angular/adapter-angular-httpclient.d.ts +21 -0
- package/angular/adapter-angular-httpclient.js +70 -0
- package/angular/adapter-angular-httpclient.js.map +1 -0
- package/breeze.d.ts +215 -0
- package/breeze.js +141 -0
- package/breeze.js.map +1 -0
- package/config/config.d.ts +212 -0
- package/config/config.js +392 -0
- package/config/config.js.map +1 -0
- package/config/configure.d.ts +66 -0
- package/config/configure.js +46 -0
- package/config/configure.js.map +1 -0
- package/config/default-adapters.d.ts +1 -0
- package/config/default-adapters.js +40 -0
- package/config/default-adapters.js.map +1 -0
- package/config/interface-registry.d.ts +191 -0
- package/config/interface-registry.js +5 -0
- package/config/interface-registry.js.map +1 -0
- package/{src → core}/assert-param.d.ts +52 -60
- package/core/assert-param.js +390 -0
- package/core/assert-param.js.map +1 -0
- package/core/core.d.ts +285 -0
- package/core/core.js +772 -0
- package/core/core.js.map +1 -0
- package/core/enum.d.ts +116 -0
- package/core/enum.js +167 -0
- package/core/enum.js.map +1 -0
- package/core/event.d.ts +169 -0
- package/core/event.js +338 -0
- package/core/event.js.map +1 -0
- package/entity/array.d.ts +3 -0
- package/entity/array.js +4 -0
- package/entity/array.js.map +1 -0
- package/entity/complex-array.d.ts +17 -0
- package/entity/complex-array.js +104 -0
- package/entity/complex-array.js.map +1 -0
- package/entity/default-property-interceptor.d.ts +1 -0
- package/entity/default-property-interceptor.js +496 -0
- package/entity/default-property-interceptor.js.map +1 -0
- package/{src → entity}/entity-action.d.ts +36 -42
- package/entity/entity-action.js +45 -0
- package/entity/entity-action.js.map +1 -0
- package/entity/entity-aspect.d.ts +457 -0
- package/entity/entity-aspect.js +1262 -0
- package/entity/entity-aspect.js.map +1 -0
- package/entity/entity-base.d.ts +55 -0
- package/entity/entity-base.js +41 -0
- package/entity/entity-base.js.map +1 -0
- package/entity/entity-group.d.ts +1 -0
- package/entity/entity-group.js +224 -0
- package/entity/entity-group.js.map +1 -0
- package/entity/entity-key.d.ts +95 -0
- package/entity/entity-key.js +189 -0
- package/entity/entity-key.js.map +1 -0
- package/{src → entity}/entity-state.d.ts +112 -84
- package/entity/entity-state.js +135 -0
- package/entity/entity-state.js.map +1 -0
- package/entity/key-generator.d.ts +57 -0
- package/entity/key-generator.js +155 -0
- package/entity/key-generator.js.map +1 -0
- package/entity/observable-array.d.ts +25 -0
- package/entity/observable-array.js +230 -0
- package/entity/observable-array.js.map +1 -0
- package/entity/primitive-array.d.ts +12 -0
- package/entity/primitive-array.js +71 -0
- package/entity/primitive-array.js.map +1 -0
- package/entity/relation-array.d.ts +24 -0
- package/entity/relation-array.js +176 -0
- package/entity/relation-array.js.map +1 -0
- package/entity/unattached-children-map.d.ts +1 -0
- package/entity/unattached-children-map.js +105 -0
- package/entity/unattached-children-map.js.map +1 -0
- package/generate-entity-classes.js +1176 -0
- package/manager/entity-manager.d.ts +801 -0
- package/manager/entity-manager.js +2395 -0
- package/manager/entity-manager.js.map +1 -0
- package/{src → manager}/save-options.d.ts +48 -42
- package/manager/save-options.js +51 -0
- package/manager/save-options.js.map +1 -0
- package/{src → metadata}/data-service.d.ts +229 -184
- package/metadata/data-service.js +246 -0
- package/metadata/data-service.js.map +1 -0
- package/metadata/data-type.d.ts +122 -0
- package/metadata/data-type.js +465 -0
- package/metadata/data-type.js.map +1 -0
- package/metadata/entity-metadata.d.ts +1193 -0
- package/metadata/entity-metadata.js +2502 -0
- package/metadata/entity-metadata.js.map +1 -0
- package/{src → metadata}/local-query-comparison-options.d.ts +65 -59
- package/metadata/local-query-comparison-options.js +69 -0
- package/metadata/local-query-comparison-options.js.map +1 -0
- package/{src → metadata}/naming-convention.d.ts +75 -72
- package/metadata/naming-convention.js +97 -0
- package/metadata/naming-convention.js.map +1 -0
- package/mixins/mixin-get-entity-graph.d.ts +63 -0
- package/{fesm2022/breeze-client-mixin-get-entity-graph.mjs → mixins/mixin-get-entity-graph.js} +331 -253
- package/mixins/mixin-get-entity-graph.js.map +1 -0
- package/mixins/mixin-save-queuing.d.ts +98 -0
- package/{fesm2022/breeze-client-mixin-save-queuing.mjs → mixins/mixin-save-queuing.js} +493 -365
- package/mixins/mixin-save-queuing.js.map +1 -0
- package/package.json +63 -94
- package/query/entity-query.d.ts +521 -0
- package/query/entity-query.js +1149 -0
- package/query/entity-query.js.map +1 -0
- package/{src → query}/mapping-context.d.ts +44 -46
- package/query/mapping-context.js +412 -0
- package/query/mapping-context.js.map +1 -0
- package/query/predicate.d.ts +394 -0
- package/query/predicate.js +1294 -0
- package/query/predicate.js.map +1 -0
- package/query/property-path.d.ts +252 -0
- package/query/property-path.js +2 -0
- package/query/property-path.js.map +1 -0
- package/{src → query}/query-options.d.ts +143 -119
- package/query/query-options.js +180 -0
- package/query/query-options.js.map +1 -0
- package/rxjs/breeze-rxjs.d.ts +72 -0
- package/rxjs/breeze-rxjs.js +117 -0
- package/rxjs/breeze-rxjs.js.map +1 -0
- package/validation/validate.d.ts +583 -0
- package/validation/validate.js +961 -0
- package/validation/validate.js.map +1 -0
- package/{src → validation}/validation-options.d.ts +67 -63
- package/validation/validation-options.js +70 -0
- package/validation/validation-options.js.map +1 -0
- package/adapter-ajax-angularjs/adapter-ajax-angularjs.d.ts +0 -17
- package/adapter-ajax-angularjs/adapter-core.d.ts +0 -4
- package/adapter-ajax-angularjs/index.d.ts +0 -5
- package/adapter-ajax-fetch/adapter-ajax-fetch.d.ts +0 -18
- package/adapter-ajax-fetch/index.d.ts +0 -5
- package/adapter-ajax-httpclient/adapter-ajax-httpclient.d.ts +0 -13
- package/adapter-ajax-httpclient/adapter-core.d.ts +0 -4
- package/adapter-ajax-httpclient/index.d.ts +0 -5
- package/adapter-ajax-jquery/adapter-ajax-jquery.d.ts +0 -15
- package/adapter-ajax-jquery/index.d.ts +0 -5
- package/adapter-ajax-post/index.d.ts +0 -5
- package/adapter-data-service-odata/adapter-core.d.ts +0 -4
- package/adapter-data-service-odata/adapter-data-service-odata.d.ts +0 -17
- package/adapter-data-service-odata/index.d.ts +0 -5
- package/adapter-data-service-webapi/adapter-data-service-webapi.d.ts +0 -15
- package/adapter-data-service-webapi/index.d.ts +0 -5
- package/adapter-model-library-backing-store/adapter-model-library-backing-store.d.ts +0 -10
- package/adapter-model-library-backing-store/index.d.ts +0 -5
- package/adapter-model-library-ko/adapter-model-library-ko.d.ts +0 -10
- package/adapter-model-library-ko/index.d.ts +0 -5
- package/adapter-uri-builder-json/adapter-core.d.ts +0 -4
- package/adapter-uri-builder-json/adapter-uri-builder-json.d.ts +0 -8
- package/adapter-uri-builder-json/index.d.ts +0 -5
- package/adapter-uri-builder-odata/adapter-core.d.ts +0 -4
- package/adapter-uri-builder-odata/adapter-uri-builder-odata.d.ts +0 -8
- package/adapter-uri-builder-odata/index.d.ts +0 -5
- package/esm2022/adapter-ajax-angularjs/adapter-ajax-angularjs.mjs +0 -135
- package/esm2022/adapter-ajax-angularjs/adapter-core.mjs +0 -49
- package/esm2022/adapter-ajax-angularjs/breeze-client-adapter-ajax-angularjs.mjs +0 -5
- package/esm2022/adapter-ajax-fetch/adapter-ajax-fetch.mjs +0 -135
- package/esm2022/adapter-ajax-fetch/adapter-core.mjs +0 -49
- package/esm2022/adapter-ajax-fetch/breeze-client-adapter-ajax-fetch.mjs +0 -5
- package/esm2022/adapter-ajax-httpclient/adapter-ajax-httpclient.mjs +0 -139
- package/esm2022/adapter-ajax-httpclient/adapter-core.mjs +0 -49
- package/esm2022/adapter-ajax-httpclient/breeze-client-adapter-ajax-httpclient.mjs +0 -5
- package/esm2022/adapter-ajax-jquery/adapter-ajax-jquery.mjs +0 -107
- package/esm2022/adapter-ajax-jquery/breeze-client-adapter-ajax-jquery.mjs +0 -5
- package/esm2022/adapter-ajax-post/adapter-ajax-post.mjs +0 -77
- package/esm2022/adapter-ajax-post/breeze-client-adapter-ajax-post.mjs +0 -5
- package/esm2022/adapter-data-service-odata/adapter-core.mjs +0 -49
- package/esm2022/adapter-data-service-odata/adapter-data-service-odata.mjs +0 -461
- package/esm2022/adapter-data-service-odata/breeze-client-adapter-data-service-odata.mjs +0 -5
- package/esm2022/adapter-data-service-webapi/adapter-data-service-webapi.mjs +0 -100
- package/esm2022/adapter-data-service-webapi/breeze-client-adapter-data-service-webapi.mjs +0 -5
- package/esm2022/adapter-model-library-backing-store/adapter-model-library-backing-store.mjs +0 -269
- package/esm2022/adapter-model-library-backing-store/breeze-client-adapter-model-library-backing-store.mjs +0 -5
- package/esm2022/adapter-model-library-ko/adapter-model-library-ko.mjs +0 -241
- package/esm2022/adapter-model-library-ko/breeze-client-adapter-model-library-ko.mjs +0 -5
- package/esm2022/adapter-uri-builder-json/adapter-core.mjs +0 -49
- package/esm2022/adapter-uri-builder-json/adapter-uri-builder-json.mjs +0 -37
- package/esm2022/adapter-uri-builder-json/breeze-client-adapter-uri-builder-json.mjs +0 -5
- package/esm2022/adapter-uri-builder-odata/adapter-core.mjs +0 -49
- package/esm2022/adapter-uri-builder-odata/adapter-uri-builder-odata.mjs +0 -191
- package/esm2022/adapter-uri-builder-odata/breeze-client-adapter-uri-builder-odata.mjs +0 -5
- package/esm2022/breeze-client.mjs +0 -5
- package/esm2022/index.mjs +0 -2
- package/esm2022/mixin-get-entity-graph/breeze-client-mixin-get-entity-graph.mjs +0 -5
- package/esm2022/mixin-get-entity-graph/mixin-get-entity-graph.mjs +0 -269
- package/esm2022/mixin-save-queuing/breeze-client-mixin-save-queuing.mjs +0 -5
- package/esm2022/mixin-save-queuing/mixin-save-queuing.mjs +0 -421
- package/esm2022/src/abstract-data-service-adapter.mjs +0 -325
- package/esm2022/src/array.mjs +0 -4
- package/esm2022/src/assert-param.mjs +0 -330
- package/esm2022/src/breeze.mjs +0 -85
- package/esm2022/src/complex-array.mjs +0 -117
- package/esm2022/src/config.mjs +0 -232
- package/esm2022/src/core.mjs +0 -712
- package/esm2022/src/csdl-metadata-parser.mjs +0 -385
- package/esm2022/src/data-service.mjs +0 -221
- package/esm2022/src/data-type.mjs +0 -510
- package/esm2022/src/default-property-interceptor.mjs +0 -460
- package/esm2022/src/entity-action.mjs +0 -45
- package/esm2022/src/entity-aspect.mjs +0 -897
- package/esm2022/src/entity-group.mjs +0 -192
- package/esm2022/src/entity-key.mjs +0 -125
- package/esm2022/src/entity-manager.mjs +0 -2163
- package/esm2022/src/entity-metadata.mjs +0 -2242
- package/esm2022/src/entity-query.mjs +0 -1024
- package/esm2022/src/entity-state.mjs +0 -107
- package/esm2022/src/enum.mjs +0 -143
- package/esm2022/src/event.mjs +0 -264
- package/esm2022/src/interface-registry.mjs +0 -39
- package/esm2022/src/key-generator.mjs +0 -110
- package/esm2022/src/local-query-comparison-options.mjs +0 -65
- package/esm2022/src/mapping-context.mjs +0 -411
- package/esm2022/src/naming-convention.mjs +0 -92
- package/esm2022/src/observable-array.mjs +0 -183
- package/esm2022/src/predicate.mjs +0 -1259
- package/esm2022/src/primitive-array.mjs +0 -85
- package/esm2022/src/query-options.mjs +0 -152
- package/esm2022/src/relation-array.mjs +0 -173
- package/esm2022/src/save-options.mjs +0 -41
- package/esm2022/src/unattached-children-map.mjs +0 -56
- package/esm2022/src/validate.mjs +0 -995
- package/esm2022/src/validation-options.mjs +0 -64
- package/fesm2022/breeze-client-adapter-ajax-angularjs.mjs +0 -190
- package/fesm2022/breeze-client-adapter-ajax-angularjs.mjs.map +0 -1
- package/fesm2022/breeze-client-adapter-ajax-fetch.mjs +0 -190
- package/fesm2022/breeze-client-adapter-ajax-fetch.mjs.map +0 -1
- package/fesm2022/breeze-client-adapter-ajax-httpclient.mjs +0 -194
- package/fesm2022/breeze-client-adapter-ajax-httpclient.mjs.map +0 -1
- package/fesm2022/breeze-client-adapter-ajax-jquery.mjs +0 -114
- package/fesm2022/breeze-client-adapter-ajax-jquery.mjs.map +0 -1
- package/fesm2022/breeze-client-adapter-ajax-post.mjs.map +0 -1
- package/fesm2022/breeze-client-adapter-data-service-odata.mjs +0 -516
- package/fesm2022/breeze-client-adapter-data-service-odata.mjs.map +0 -1
- package/fesm2022/breeze-client-adapter-data-service-webapi.mjs.map +0 -1
- package/fesm2022/breeze-client-adapter-model-library-backing-store.mjs +0 -276
- package/fesm2022/breeze-client-adapter-model-library-backing-store.mjs.map +0 -1
- package/fesm2022/breeze-client-adapter-model-library-ko.mjs +0 -248
- package/fesm2022/breeze-client-adapter-model-library-ko.mjs.map +0 -1
- package/fesm2022/breeze-client-adapter-uri-builder-json.mjs.map +0 -1
- package/fesm2022/breeze-client-adapter-uri-builder-odata.mjs +0 -246
- package/fesm2022/breeze-client-adapter-uri-builder-odata.mjs.map +0 -1
- package/fesm2022/breeze-client-mixin-get-entity-graph.mjs.map +0 -1
- package/fesm2022/breeze-client-mixin-save-queuing.mjs.map +0 -1
- package/fesm2022/breeze-client.mjs +0 -14144
- package/fesm2022/breeze-client.mjs.map +0 -1
- package/index.d.ts +0 -1
- package/mixin-get-entity-graph/index.d.ts +0 -5
- package/mixin-get-entity-graph/mixin-get-entity-graph.d.ts +0 -31
- package/mixin-save-queuing/index.d.ts +0 -5
- package/mixin-save-queuing/mixin-save-queuing.d.ts +0 -32
- package/src/abstract-data-service-adapter.d.ts +0 -84
- package/src/array.d.ts +0 -3
- package/src/breeze.d.ts +0 -139
- package/src/complex-array.d.ts +0 -13
- package/src/config.d.ts +0 -104
- package/src/core.d.ts +0 -164
- package/src/csdl-metadata-parser.d.ts +0 -7
- package/src/data-type.d.ts +0 -89
- package/src/default-property-interceptor.d.ts +0 -4
- package/src/entity-aspect.d.ts +0 -332
- package/src/entity-group.d.ts +0 -28
- package/src/entity-key.d.ts +0 -77
- package/src/entity-manager.d.ts +0 -680
- package/src/entity-metadata.d.ts +0 -988
- package/src/entity-query.d.ts +0 -444
- package/src/enum.d.ts +0 -100
- package/src/event.d.ts +0 -142
- package/src/interface-registry.d.ts +0 -150
- package/src/key-generator.d.ts +0 -12
- package/src/observable-array.d.ts +0 -52
- package/src/predicate.d.ts +0 -376
- package/src/primitive-array.d.ts +0 -7
- package/src/relation-array.d.ts +0 -18
- package/src/unattached-children-map.d.ts +0 -19
- package/src/validate.d.ts +0 -650
|
@@ -1,42 +1,36 @@
|
|
|
1
|
-
import { BreezeEnum } from '
|
|
2
|
-
/** EntityAction is an 'Enum' containing all of the valid actions that can occur to an 'Entity'.
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
export declare class EntityAction extends BreezeEnum {
|
|
6
|
-
/** Entity was attached via an AttachEntity call. */
|
|
7
|
-
static Attach: EntityAction;
|
|
8
|
-
/** Entity was attached as a result of a query. */
|
|
9
|
-
static AttachOnQuery: EntityAction;
|
|
10
|
-
/** Entity was attached as a result of an import. */
|
|
11
|
-
static AttachOnImport: EntityAction;
|
|
12
|
-
/** Entity was detached */
|
|
13
|
-
static Detach: EntityAction;
|
|
14
|
-
/** Properties on the entity were merged as a result of a query. */
|
|
15
|
-
static MergeOnQuery: EntityAction;
|
|
16
|
-
/** Properties on the entity were merged as a result of an import. */
|
|
17
|
-
static MergeOnImport: EntityAction;
|
|
18
|
-
/** Properties on the entity were merged as a result of a save */
|
|
19
|
-
static MergeOnSave: EntityAction;
|
|
20
|
-
/** A property on the entity was changed. */
|
|
21
|
-
static PropertyChange: EntityAction;
|
|
22
|
-
/** The EntityState of the entity was changed. */
|
|
23
|
-
static EntityStateChange: EntityAction;
|
|
24
|
-
/** AcceptChanges was called on the entity, or its entityState was set to Unmodified. */
|
|
25
|
-
static AcceptChanges: EntityAction;
|
|
26
|
-
/** RejectChanges was called on the entity. */
|
|
27
|
-
static RejectChanges: EntityAction;
|
|
28
|
-
/** The EntityManager was cleared. All entities detached. */
|
|
29
|
-
static Clear: EntityAction;
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
isAttach(): boolean;
|
|
38
|
-
/** Is this a 'detach' operation? ( Detach, Clear) */
|
|
39
|
-
isDetach(): boolean;
|
|
40
|
-
/** Is this a 'modification' operation? ( PropertyChange, MergeOnQuery, MergeOnSave, MergeOnImport, RejectChanges) */
|
|
41
|
-
isModification(): boolean;
|
|
42
|
-
}
|
|
1
|
+
import { BreezeEnum } from '../core/enum.js';
|
|
2
|
+
/** EntityAction is an 'Enum' containing all of the valid actions that can occur to an 'Entity'.
|
|
3
|
+
|
|
4
|
+
*/
|
|
5
|
+
export declare class EntityAction extends BreezeEnum {
|
|
6
|
+
/** Entity was attached via an AttachEntity call. */
|
|
7
|
+
static Attach: EntityAction;
|
|
8
|
+
/** Entity was attached as a result of a query. */
|
|
9
|
+
static AttachOnQuery: EntityAction;
|
|
10
|
+
/** Entity was attached as a result of an import. */
|
|
11
|
+
static AttachOnImport: EntityAction;
|
|
12
|
+
/** Entity was detached */
|
|
13
|
+
static Detach: EntityAction;
|
|
14
|
+
/** Properties on the entity were merged as a result of a query. */
|
|
15
|
+
static MergeOnQuery: EntityAction;
|
|
16
|
+
/** Properties on the entity were merged as a result of an import. */
|
|
17
|
+
static MergeOnImport: EntityAction;
|
|
18
|
+
/** Properties on the entity were merged as a result of a save */
|
|
19
|
+
static MergeOnSave: EntityAction;
|
|
20
|
+
/** A property on the entity was changed. */
|
|
21
|
+
static PropertyChange: EntityAction;
|
|
22
|
+
/** The EntityState of the entity was changed. */
|
|
23
|
+
static EntityStateChange: EntityAction;
|
|
24
|
+
/** AcceptChanges was called on the entity, or its entityState was set to Unmodified. */
|
|
25
|
+
static AcceptChanges: EntityAction;
|
|
26
|
+
/** RejectChanges was called on the entity. */
|
|
27
|
+
static RejectChanges: EntityAction;
|
|
28
|
+
/** The EntityManager was cleared. All entities detached. */
|
|
29
|
+
static Clear: EntityAction;
|
|
30
|
+
/** Is this an 'attach' operation? ( Attach, AttachOnQuery or AttachOnImport) */
|
|
31
|
+
isAttach(): boolean;
|
|
32
|
+
/** Is this a 'detach' operation? ( Detach, Clear) */
|
|
33
|
+
isDetach(): boolean;
|
|
34
|
+
/** Is this a 'modification' operation? ( PropertyChange, MergeOnQuery, MergeOnSave, MergeOnImport, RejectChanges) */
|
|
35
|
+
isModification(): boolean;
|
|
36
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BreezeEnum } from '../core/enum.js';
|
|
2
|
+
/** EntityAction is an 'Enum' containing all of the valid actions that can occur to an 'Entity'.
|
|
3
|
+
|
|
4
|
+
*/
|
|
5
|
+
export class EntityAction extends BreezeEnum {
|
|
6
|
+
/** Entity was attached via an AttachEntity call. */
|
|
7
|
+
static Attach = new EntityAction({ _isAttach: true });
|
|
8
|
+
/** Entity was attached as a result of a query. */
|
|
9
|
+
static AttachOnQuery = new EntityAction({ _isAttach: true });
|
|
10
|
+
/** Entity was attached as a result of an import. */
|
|
11
|
+
static AttachOnImport = new EntityAction({ _isAttach: true });
|
|
12
|
+
/** Entity was detached */
|
|
13
|
+
static Detach = new EntityAction({ _isDetach: true });
|
|
14
|
+
/** Properties on the entity were merged as a result of a query. */
|
|
15
|
+
static MergeOnQuery = new EntityAction({ _isModification: true });
|
|
16
|
+
/** Properties on the entity were merged as a result of an import. */
|
|
17
|
+
static MergeOnImport = new EntityAction({ _isModification: true });
|
|
18
|
+
/** Properties on the entity were merged as a result of a save */
|
|
19
|
+
static MergeOnSave = new EntityAction({ _isModification: true });
|
|
20
|
+
/** A property on the entity was changed. */
|
|
21
|
+
static PropertyChange = new EntityAction({ _isModification: true });
|
|
22
|
+
/** The EntityState of the entity was changed. */
|
|
23
|
+
static EntityStateChange = new EntityAction();
|
|
24
|
+
/** AcceptChanges was called on the entity, or its entityState was set to Unmodified. */
|
|
25
|
+
static AcceptChanges = new EntityAction();
|
|
26
|
+
/** RejectChanges was called on the entity. */
|
|
27
|
+
static RejectChanges = new EntityAction({ _isModification: true });
|
|
28
|
+
/** The EntityManager was cleared. All entities detached. */
|
|
29
|
+
static Clear = new EntityAction({ _isDetach: true });
|
|
30
|
+
/** Is this an 'attach' operation? ( Attach, AttachOnQuery or AttachOnImport) */
|
|
31
|
+
isAttach() {
|
|
32
|
+
return !!this._isAttach;
|
|
33
|
+
}
|
|
34
|
+
/** Is this a 'detach' operation? ( Detach, Clear) */
|
|
35
|
+
isDetach() {
|
|
36
|
+
return !!this._isDetach;
|
|
37
|
+
}
|
|
38
|
+
/** Is this a 'modification' operation? ( PropertyChange, MergeOnQuery, MergeOnSave, MergeOnImport, RejectChanges) */
|
|
39
|
+
isModification() {
|
|
40
|
+
return !!this._isModification;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
EntityAction.prototype._$typeName = "EntityAction";
|
|
44
|
+
EntityAction.resolveSymbols();
|
|
45
|
+
//# sourceMappingURL=entity-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-action.js","sourceRoot":"","sources":["../../src/entity/entity-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAE5C;;EAEE;AAEF,MAAM,OAAO,YAAa,SAAQ,UAAU;IAE1C,oDAAoD;IACpD,MAAM,CAAC,MAAM,GAAG,IAAI,YAAY,CAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,mDAAmD;IACnD,MAAM,CAAC,aAAa,GAAG,IAAI,YAAY,CAAC,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;IAC5D,qDAAqD;IACrD,MAAM,CAAC,cAAc,GAAG,IAAI,YAAY,CAAC,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;IAE7D,0BAA0B;IAC1B,MAAM,CAAC,MAAM,GAAG,IAAI,YAAY,CAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEvD,mEAAmE;IACnE,MAAM,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,qEAAqE;IACrE,MAAM,CAAC,aAAa,GAAG,IAAI,YAAY,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;IACnE,iEAAiE;IACjE,MAAM,CAAC,WAAW,GAAG,IAAI,YAAY,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjE,4CAA4C;IAC5C,MAAM,CAAC,cAAc,GAAG,IAAI,YAAY,CAAC,EAAE,eAAe,EAAE,IAAI,EAAC,CAAC,CAAC;IAEnE,iDAAiD;IACjD,MAAM,CAAC,iBAAiB,GAAG,IAAI,YAAY,EAAE,CAAC;IAE9C,wFAAwF;IACxF,MAAM,CAAC,aAAa,GAAG,IAAI,YAAY,EAAE,CAAC;IAC1C,8CAA8C;IAC9C,MAAM,CAAC,aAAa,GAAG,IAAI,YAAY,CAAC,EAAE,eAAe,EAAE,IAAI,EAAC,CAAC,CAAC;IAElE,6DAA6D;IAC7D,MAAM,CAAC,KAAK,GAAG,IAAI,YAAY,CAAC,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;IAQpD,gFAAgF;IAChF,QAAQ;QACN,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IACD,qDAAqD;IACrD,QAAQ;QACN,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IACD,qHAAqH;IACrH,cAAc;QACZ,OAAO,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;;AAEH,YAAY,CAAC,SAAS,CAAC,UAAU,GAAG,cAAc,CAAC;AACnD,YAAY,CAAC,cAAc,EAAE,CAAC","sourcesContent":["import { BreezeEnum} from '../core/enum.js';\r\n\r\n/** EntityAction is an 'Enum' containing all of the valid actions that can occur to an 'Entity'. \r\n \r\n*/\r\n\r\nexport class EntityAction extends BreezeEnum {\r\n\r\n /** Entity was attached via an AttachEntity call. */\r\n static Attach = new EntityAction( { _isAttach: true });\r\n /** Entity was attached as a result of a query. */\r\n static AttachOnQuery = new EntityAction({ _isAttach: true});\r\n /** Entity was attached as a result of an import. */\r\n static AttachOnImport = new EntityAction({ _isAttach: true});\r\n\r\n /** Entity was detached */\r\n static Detach = new EntityAction( { _isDetach: true });\r\n\r\n /** Properties on the entity were merged as a result of a query. */\r\n static MergeOnQuery = new EntityAction({ _isModification: true });\r\n /** Properties on the entity were merged as a result of an import. */\r\n static MergeOnImport = new EntityAction({ _isModification: true });\r\n /** Properties on the entity were merged as a result of a save */\r\n static MergeOnSave = new EntityAction({ _isModification: true });\r\n\r\n /** A property on the entity was changed. */\r\n static PropertyChange = new EntityAction({ _isModification: true});\r\n\r\n /** The EntityState of the entity was changed. */\r\n static EntityStateChange = new EntityAction();\r\n\r\n /** AcceptChanges was called on the entity, or its entityState was set to Unmodified. */\r\n static AcceptChanges = new EntityAction();\r\n /** RejectChanges was called on the entity. */\r\n static RejectChanges = new EntityAction({ _isModification: true});\r\n\r\n /** The EntityManager was cleared. All entities detached. */\r\n static Clear = new EntityAction({ _isDetach: true});\r\n\r\n /** @hidden @internal */\r\n declare _isAttach?: boolean;\r\n /** @hidden @internal */\r\n declare _isDetach?: boolean;\r\n /** @hidden @internal */\r\n declare _isModification: boolean;\r\n /** Is this an 'attach' operation? ( Attach, AttachOnQuery or AttachOnImport) */\r\n isAttach() {\r\n return !!this._isAttach;\r\n }\r\n /** Is this a 'detach' operation? ( Detach, Clear) */\r\n isDetach() {\r\n return !!this._isDetach;\r\n }\r\n /** Is this a 'modification' operation? ( PropertyChange, MergeOnQuery, MergeOnSave, MergeOnImport, RejectChanges) */\r\n isModification() {\r\n return !!this._isModification;\r\n }\r\n}\r\nEntityAction.prototype._$typeName = \"EntityAction\";\r\nEntityAction.resolveSymbols();\r\n\r\n\r\n\r\n"]}
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { BreezeEvent } from '../core/event.js';
|
|
2
|
+
import { EntityState } from './entity-state.js';
|
|
3
|
+
import { EntityType, ComplexType, DataProperty, NavigationProperty, EntityProperty } from '../metadata/entity-metadata.js';
|
|
4
|
+
import { EntityKey } from './entity-key.js';
|
|
5
|
+
import { EntityManager, QueryResult, QueryErrorCallback, QuerySuccessCallback, ValidationErrorsChangedEventArgs } from '../manager/entity-manager.js';
|
|
6
|
+
import { Validator, ValidationError } from '../validation/validate.js';
|
|
7
|
+
import type { DataKeys, OriginalValues } from '../query/property-path.js';
|
|
8
|
+
/** An instance of an {@link EntityType}: an object with a key, tracked by an {@link EntityManager}
|
|
9
|
+
once attached. Breeze gives every entity these members, whether its class declares them or not. */
|
|
10
|
+
export interface Entity {
|
|
11
|
+
/** The {@link EntityAspect} that holds this entity's Breeze state: its {@link EntityState}, key,
|
|
12
|
+
original values, validation errors and manager. */
|
|
13
|
+
entityAspect: EntityAspect;
|
|
14
|
+
/** The {@link EntityType} that describes this entity. */
|
|
15
|
+
entityType: EntityType;
|
|
16
|
+
/** Get the property with the given name */
|
|
17
|
+
getProperty(prop: string): any;
|
|
18
|
+
/** Set the property with the given name, exactly as assigning it would.
|
|
19
|
+
|
|
20
|
+
With the backing-store model library it returns the object itself, so calls can be chained.
|
|
21
|
+
The return type is `any` rather than `this` so that a class declaring `setProperty` as returning
|
|
22
|
+
`void` still implements this interface.
|
|
23
|
+
|
|
24
|
+
A name that is not a property of the type is not an error: like an assignment, it creates an
|
|
25
|
+
ordinary property, which Breeze does not track. */
|
|
26
|
+
setProperty(prop: any, value: any): any;
|
|
27
|
+
}
|
|
28
|
+
/** An instance of a {@link ComplexType}: a value with no key of its own, held in a complex property
|
|
29
|
+
of an entity or of another complex object. */
|
|
30
|
+
export interface ComplexObject {
|
|
31
|
+
/** The {@link ComplexAspect} that holds this object's parent, parent property and original values. */
|
|
32
|
+
complexAspect: ComplexAspect;
|
|
33
|
+
/** The {@link ComplexType} that describes this object. */
|
|
34
|
+
complexType: ComplexType;
|
|
35
|
+
/** Get the property with the given name */
|
|
36
|
+
getProperty(prop: string): any;
|
|
37
|
+
/** Set the property with the given name, exactly as assigning it would. Returns the object
|
|
38
|
+
itself with the backing-store model library - see {@link Entity.setProperty}. */
|
|
39
|
+
setProperty(prop: any, value: any): any;
|
|
40
|
+
}
|
|
41
|
+
/** An entity or a complex object - either kind of object Breeze tracks the properties of. Used where
|
|
42
|
+
either is accepted, such as {@link ComplexAspect.parent}. */
|
|
43
|
+
export type StructuralObject = Entity | ComplexObject;
|
|
44
|
+
/**
|
|
45
|
+
* The type of the results of a query built from entities you already have, such as
|
|
46
|
+
* {@link EntityQuery.fromEntities} or {@link RelationArray.load}: the entities' own class when it
|
|
47
|
+
* is known - `QueriedAs<Customer>` is `Customer` - and `any` when all that is known is
|
|
48
|
+
* {@link Entity}, so that `results[0].companyName` compiles without a cast.
|
|
49
|
+
*/
|
|
50
|
+
export type QueriedAs<U> = Entity extends U ? any : U;
|
|
51
|
+
/** The argument to an entity's {@link EntityAspect.propertyChanged} event. It is also the `args` of
|
|
52
|
+
an {@link EntityChangedEventArgs} for {@link EntityAction.PropertyChange}. */
|
|
53
|
+
export interface PropertyChangedEventArgs {
|
|
54
|
+
/** The entity that changed. For a property of a complex object, the entity that holds it. */
|
|
55
|
+
entity: Entity;
|
|
56
|
+
/** The name of the property that changed. For a property of a complex object it is a path from
|
|
57
|
+
the entity, such as `"location.city"`, with no index for an element of a complex array.
|
|
58
|
+
|
|
59
|
+
`null` when any number of properties may have changed at once - when a query or save merges
|
|
60
|
+
values into the entity, or its changes are rejected. The other members are then not set. */
|
|
61
|
+
propertyName: string | null;
|
|
62
|
+
/** The object whose property was set: the entity itself, or the complex object that owns the
|
|
63
|
+
property. */
|
|
64
|
+
parent?: StructuralObject;
|
|
65
|
+
/** The {@link DataProperty} or {@link NavigationProperty} that changed. It belongs to the type of
|
|
66
|
+
`parent`, which is not the entity's type when `parent` is a complex object. */
|
|
67
|
+
property?: EntityProperty;
|
|
68
|
+
/** The value before the change. */
|
|
69
|
+
oldValue?: any;
|
|
70
|
+
/** The value after the change, converted to the property's data type where Breeze can. */
|
|
71
|
+
newValue?: any;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
An EntityAspect instance is associated with every attached entity and is accessed via the entity's 'entityAspect' property.
|
|
75
|
+
|
|
76
|
+
The EntityAspect itself provides properties to determine and modify the EntityState of the entity and has methods
|
|
77
|
+
that provide a variety of services including validation and change tracking.
|
|
78
|
+
|
|
79
|
+
An EntityAspect will almost never need to be constructed directly. You will usually get an EntityAspect by accessing
|
|
80
|
+
an entities 'entityAspect' property. This property will be automatically attached when an entity is created via either
|
|
81
|
+
a query, import or {@link EntityManager.createEntity} call.
|
|
82
|
+
```ts
|
|
83
|
+
// assume order is an order entity attached to an EntityManager.
|
|
84
|
+
var aspect = order.entityAspect;
|
|
85
|
+
var currentState = aspect.entityState;
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
*/
|
|
89
|
+
export declare class EntityAspect {
|
|
90
|
+
/** The Entity that this aspect is associated with. __Read Only__ */
|
|
91
|
+
entity?: Entity;
|
|
92
|
+
/** The {@link EntityManager} that contains this entity. __Read Only__ */
|
|
93
|
+
entityManager?: EntityManager;
|
|
94
|
+
/** The {@link EntityState} of this entity. __Read Only__ */
|
|
95
|
+
get entityState(): EntityState;
|
|
96
|
+
set entityState(entityState: EntityState);
|
|
97
|
+
/** Whether this entity is in the process of being saved. __Read Only__ */
|
|
98
|
+
isBeingSaved: boolean;
|
|
99
|
+
/** The 'original values' of this entity where they are different from the 'current values'.
|
|
100
|
+
This is a map where the key is a property name and the value is the 'original value' of the property. */
|
|
101
|
+
originalValues: Record<string, any>;
|
|
102
|
+
/** Whether this entity has any validation errors. __Read Only__ */
|
|
103
|
+
hasValidationErrors: boolean;
|
|
104
|
+
/** Whether this entity has a temporary {@link EntityKey}. */
|
|
105
|
+
hasTempKey?: boolean;
|
|
106
|
+
/** Whether this entity was created by being loaded from the database */
|
|
107
|
+
wasLoaded?: boolean;
|
|
108
|
+
/** Extra metadata about this entity such as the entity's etag.
|
|
109
|
+
You may extend this object with your own metadata information.
|
|
110
|
+
Breeze (de)serializes this object when importing/exporting the entity. */
|
|
111
|
+
extraMetadata?: any;
|
|
112
|
+
/**
|
|
113
|
+
A {@link BreezeEvent} that fires whenever any of the validation errors on this entity change.
|
|
114
|
+
Note that this might be the removal of an error when some data on the entity is fixed.
|
|
115
|
+
@eventArgs -
|
|
116
|
+
- entity - The entity on which the validation errors are being added or removed.
|
|
117
|
+
- added - An array containing any newly added {@link ValidationError}s
|
|
118
|
+
- removed - An array containing any newly removed {@link ValidationError}s. This is those
|
|
119
|
+
errors that have been 'fixed'.
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
// assume order is an order entity attached to an EntityManager.
|
|
123
|
+
order.entityAspect.validationErrorsChanged.subscribe(
|
|
124
|
+
function (validationChangeArgs) {
|
|
125
|
+
// this code will be executed anytime a property value changes on the 'order' entity.
|
|
126
|
+
var entity == validationChangeArgs.entity; // Note: entity === order
|
|
127
|
+
var errorsAdded = validationChangeArgs.added;
|
|
128
|
+
var errorsCleared = validationChangeArgs.removed;
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
@event
|
|
132
|
+
*/
|
|
133
|
+
validationErrorsChanged: BreezeEvent<ValidationErrorsChangedEventArgs>;
|
|
134
|
+
/**
|
|
135
|
+
A {@link BreezeEvent} that fires whenever a value of one of this entity's properties change.
|
|
136
|
+
@eventArgs -
|
|
137
|
+
- entity - The entity whose property has changed.
|
|
138
|
+
- property - The {@link DataProperty} that changed.
|
|
139
|
+
- propertyName - The name of the property that changed. This value will be 'null' for operations that replace the entire entity. This includes
|
|
140
|
+
queries, imports and saves that require a merge. The remaining parameters will not exist in this case either. This will actually be a "property path"
|
|
141
|
+
for any properties of a complex type.
|
|
142
|
+
- oldValue - The old value of this property before the change.
|
|
143
|
+
- newValue - The new value of this property after the change.
|
|
144
|
+
- parent - The immediate parent object for the changed property. This will be a ComplexType instance as opposed to an Entity
|
|
145
|
+
for any complex type or nested complex type properties.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
// assume order is an order entity attached to an EntityManager.
|
|
149
|
+
order.entityAspect.propertyChanged.subscribe(
|
|
150
|
+
function (propertyChangedArgs) {
|
|
151
|
+
// this code will be executed anytime a property value changes on the 'order' entity.
|
|
152
|
+
var entity = propertyChangedArgs.entity; // Note: entity === order
|
|
153
|
+
var propertyNameChanged = propertyChangedArgs.propertyName;
|
|
154
|
+
var oldValue = propertyChangedArgs.oldValue;
|
|
155
|
+
var newValue = propertyChangedArgs.newValue;
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
@event
|
|
159
|
+
*/
|
|
160
|
+
propertyChanged: BreezeEvent<PropertyChangedEventArgs>;
|
|
161
|
+
/** Whether an async validator is still running for this entity - see
|
|
162
|
+
{@link EntityAspect.validateEntityAsync}. __Read Only__ */
|
|
163
|
+
get isValidating(): boolean;
|
|
164
|
+
/** @hidden */
|
|
165
|
+
static isEntity(obj: StructuralObject): obj is Entity;
|
|
166
|
+
/**
|
|
167
|
+
Returns the value of a specified 'property path' for a specified entity.
|
|
168
|
+
|
|
169
|
+
The propertyPath can be either a string delimited with '.' or a string array.
|
|
170
|
+
*/
|
|
171
|
+
static getPropertyPathValue(obj: Entity, propertyPath: string | string[]): any;
|
|
172
|
+
/**
|
|
173
|
+
Returns the {@link EntityKey} for this Entity.
|
|
174
|
+
```ts
|
|
175
|
+
// assume order is an order entity attached to an EntityManager.
|
|
176
|
+
var entityKey = order.entityAspect.getKey();
|
|
177
|
+
```
|
|
178
|
+
@param forceRefresh - (boolean=false) Forces the recalculation of the key. This should normally be unnecessary.
|
|
179
|
+
@returns The {@link EntityKey} associated with this Entity.
|
|
180
|
+
*/
|
|
181
|
+
getKey(forceRefresh?: boolean): EntityKey;
|
|
182
|
+
/**
|
|
183
|
+
Returns the entity to an {@link EntityState} of 'Unchanged' by committing all changes made since the entity was last queried
|
|
184
|
+
had 'acceptChanges' called on it.
|
|
185
|
+
```ts
|
|
186
|
+
// assume order is an order entity attached to an EntityManager.
|
|
187
|
+
order.entityAspect.acceptChanges();
|
|
188
|
+
// The 'order' entity will now be in an 'Unchanged' state with any changes committed.
|
|
189
|
+
```
|
|
190
|
+
*/
|
|
191
|
+
acceptChanges(): void;
|
|
192
|
+
/**
|
|
193
|
+
Returns the entity to an {@link EntityState} of 'Unchanged' by rejecting all changes made to it since the entity was last queried
|
|
194
|
+
had 'rejectChanges' called on it.
|
|
195
|
+
```ts
|
|
196
|
+
// assume order is an order entity attached to an EntityManager.
|
|
197
|
+
order.entityAspect.rejectChanges();
|
|
198
|
+
// The 'order' entity will now be in an 'Unchanged' state with any changes rejected.
|
|
199
|
+
```
|
|
200
|
+
*/
|
|
201
|
+
rejectChanges(): void;
|
|
202
|
+
/**
|
|
203
|
+
Sets the entity to an EntityState of 'Added'. This is NOT the equivalent of calling {@link EntityManager.addEntity}
|
|
204
|
+
because no key generation will occur for autogenerated keys as a result of this operation. As a result this operation can be problematic
|
|
205
|
+
unless you are certain that the entity being marked 'Added' does not already exist in the database and does not have an autogenerated key.
|
|
206
|
+
The same operation can be performed by calling {@link EntityAspect.setEntityState}.
|
|
207
|
+
```ts
|
|
208
|
+
// assume order is an order entity attached to an EntityManager.
|
|
209
|
+
order.entityAspect.setAdded();
|
|
210
|
+
// The 'order' entity will now be in an 'Added' state.
|
|
211
|
+
```
|
|
212
|
+
*/
|
|
213
|
+
setAdded(): boolean;
|
|
214
|
+
/**
|
|
215
|
+
Sets the entity to an EntityState of 'Unchanged'. This is also the equivalent of calling {@link EntityAspect.acceptChanges}.
|
|
216
|
+
The same operation can be performed by calling {@link EntityAspect.setEntityState}.
|
|
217
|
+
```ts
|
|
218
|
+
// assume order is an order entity attached to an EntityManager.
|
|
219
|
+
order.entityAspect.setUnchanged();
|
|
220
|
+
// The 'order' entity will now be in an 'Unchanged' state with any changes committed.
|
|
221
|
+
```
|
|
222
|
+
*/
|
|
223
|
+
setUnchanged: () => any;
|
|
224
|
+
/**
|
|
225
|
+
Sets the entity to an EntityState of 'Modified'. This can also be achieved by changing the value of any property on an 'Unchanged' entity.
|
|
226
|
+
The same operation can be performed by calling {@link EntityAspect.setEntityState}.
|
|
227
|
+
```ts
|
|
228
|
+
// assume order is an order entity attached to an EntityManager.
|
|
229
|
+
order.entityAspect.setModified();
|
|
230
|
+
// The 'order' entity will now be in a 'Modified' state.
|
|
231
|
+
```
|
|
232
|
+
*/
|
|
233
|
+
setModified: () => any;
|
|
234
|
+
/**
|
|
235
|
+
Sets the entity to an EntityState of 'Deleted'. This both marks the entity as being scheduled for deletion during the next 'Save' call
|
|
236
|
+
but also removes the entity from all of its related entities. If the current entityState is 'Added', then `setDeleted()` will mark it 'Detached'
|
|
237
|
+
The same operation can be performed by calling {@link EntityAspect.setEntityState}.
|
|
238
|
+
```ts
|
|
239
|
+
// assume order is an order entity attached to an EntityManager.
|
|
240
|
+
order.entityAspect.setDeleted();
|
|
241
|
+
// The 'order' entity will now be in a 'Deleted' state and it will no longer have any 'related' entities.
|
|
242
|
+
```
|
|
243
|
+
*/
|
|
244
|
+
setDeleted: () => any;
|
|
245
|
+
/**
|
|
246
|
+
Sets the entity to an EntityState of 'Detached'. This removes the entity from all of its related entities, but does NOT change the EntityState of any existing entities.
|
|
247
|
+
The same operation can be performed by calling {@link EntityAspect.setEntityState}.
|
|
248
|
+
```ts
|
|
249
|
+
// assume order is an order entity attached to an EntityManager.
|
|
250
|
+
order.entityAspect.setDetached();
|
|
251
|
+
// The 'order' entity will now be in a 'Detached' state and it will no longer have any 'related' entities.
|
|
252
|
+
```
|
|
253
|
+
*/
|
|
254
|
+
setDetached: () => any;
|
|
255
|
+
/**
|
|
256
|
+
Sets the entity to the specified EntityState. See also 'setUnchanged', 'setModified', 'setDetached', etc.
|
|
257
|
+
```ts
|
|
258
|
+
// assume order is an order entity attached to an EntityManager.
|
|
259
|
+
order.entityAspect.setEntityState(EntityState.Unchanged);
|
|
260
|
+
// The 'order' entity will now be in a 'Unchanged' state.
|
|
261
|
+
```
|
|
262
|
+
*/
|
|
263
|
+
setEntityState(entityState: EntityState): boolean;
|
|
264
|
+
loadNavigationProperty(navigationProperty: string): Promise<QueryResult>;
|
|
265
|
+
loadNavigationProperty(navigationProperty: NavigationProperty): Promise<QueryResult>;
|
|
266
|
+
/** @deprecated Await the returned promise instead of passing callbacks. */
|
|
267
|
+
loadNavigationProperty(navigationProperty: string, callback?: QuerySuccessCallback, errorCallback?: QueryErrorCallback): Promise<QueryResult>;
|
|
268
|
+
/** @deprecated Await the returned promise instead of passing callbacks. */
|
|
269
|
+
loadNavigationProperty(navigationProperty: NavigationProperty, callback?: QuerySuccessCallback, errorCallback?: QueryErrorCallback): Promise<QueryResult>;
|
|
270
|
+
/**
|
|
271
|
+
Marks this navigationProperty on this entity as already having been loaded.
|
|
272
|
+
```ts
|
|
273
|
+
emp.entityAspect.markNavigationPropertyAsLoaded("Orders");
|
|
274
|
+
```
|
|
275
|
+
@param navigationProperty - The NavigationProperty or name of NavigationProperty to 'load'.
|
|
276
|
+
*/
|
|
277
|
+
markNavigationPropertyAsLoaded(navigationProperty: NavigationProperty | string): void;
|
|
278
|
+
isNavigationPropertyLoaded(navigationProperty: string): boolean;
|
|
279
|
+
isNavigationPropertyLoaded(navigationProperty: NavigationProperty): boolean;
|
|
280
|
+
/**
|
|
281
|
+
Performs validation on the entity, any errors encountered during the validation are available via the
|
|
282
|
+
{@link EntityAspect.getValidationErrors} method. Validating an entity means executing
|
|
283
|
+
all of the validators on both the entity itself as well as those on each of its properties.
|
|
284
|
+
```ts
|
|
285
|
+
// assume order is an order entity attached to an EntityManager.
|
|
286
|
+
var isOk = order.entityAspect.validateEntity();
|
|
287
|
+
// isOk will be 'true' if there are no errors on the entity.
|
|
288
|
+
if (!isOk) {
|
|
289
|
+
var errors = order.entityAspect.getValidationErrors();
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
@returns Whether the entity can be saved: every validator passes, and no error added with
|
|
293
|
+
{@link EntityAspect.addValidationError} remains. Errors from the server are not counted - a save
|
|
294
|
+
clears them before validating, and the server checks again. This is the check `saveChanges`
|
|
295
|
+
makes, so the two always agree.
|
|
296
|
+
*/
|
|
297
|
+
validateEntity(): boolean;
|
|
298
|
+
validateProperty(property: string, context?: any): boolean;
|
|
299
|
+
validateProperty(property: DataProperty, context?: any): boolean;
|
|
300
|
+
validateProperty(property: NavigationProperty, context?: any): boolean;
|
|
301
|
+
/**
|
|
302
|
+
Validates the entity as {@link EntityAspect.validateEntity} does, and also runs its async
|
|
303
|
+
validators - see {@link Validator.isAsync} - resolving when they have all answered. This is the
|
|
304
|
+
check `saveChanges` makes when any of the entities it saves has an async validator.
|
|
305
|
+
```ts
|
|
306
|
+
if (!await order.entityAspect.validateEntityAsync()) {
|
|
307
|
+
const errors = order.entityAspect.getValidationErrors();
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
While it runs, {@link EntityAspect.isValidating} is true. If a property changes while one of its
|
|
311
|
+
checks runs, the check is run again on the new value.
|
|
312
|
+
@returns Whether the entity can be saved, as {@link EntityAspect.validateEntity} answers, once the
|
|
313
|
+
async validators' answers are in.
|
|
314
|
+
*/
|
|
315
|
+
validateEntityAsync(): Promise<boolean>;
|
|
316
|
+
/**
|
|
317
|
+
Validates one property as {@link EntityAspect.validateProperty} does, and also runs its async
|
|
318
|
+
validators, resolving when they have all answered.
|
|
319
|
+
```ts
|
|
320
|
+
const isOk = await customer.entityAspect.validatePropertyAsync("companyName");
|
|
321
|
+
```
|
|
322
|
+
@param property - The property, by {@link DataProperty}, {@link NavigationProperty}, name, or path
|
|
323
|
+
to a property of a complex object.
|
|
324
|
+
@param context - Additional context for each {@link Validator}.
|
|
325
|
+
@returns Whether the property can be saved, once the async validators' answers are in.
|
|
326
|
+
*/
|
|
327
|
+
validatePropertyAsync(property: EntityProperty | string, context?: any): Promise<boolean>;
|
|
328
|
+
getValidationErrors(): ValidationError[];
|
|
329
|
+
getValidationErrors(property: string): ValidationError[];
|
|
330
|
+
getValidationErrors(property: EntityProperty): ValidationError[];
|
|
331
|
+
/**
|
|
332
|
+
The value a property had before the entity's pending changes: its original value if it has been
|
|
333
|
+
edited since the entity was last saved or accepted, and its current value if not. So it answers
|
|
334
|
+
"what was this?" without first asking whether it changed.
|
|
335
|
+
```ts
|
|
336
|
+
order.freight = 99;
|
|
337
|
+
order.entityAspect.getOriginalValue('freight'); // the freight before the edit
|
|
338
|
+
order.entityAspect.getOriginalValue('shipCity'); // unchanged, so its current value
|
|
339
|
+
```
|
|
340
|
+
Also takes a path into a complex property, such as `'location.city'`.
|
|
341
|
+
@param propertyName - A data property of this entity, or a path to one in a complex property.
|
|
342
|
+
*/
|
|
343
|
+
getOriginalValue(propertyName: string): any;
|
|
344
|
+
/**
|
|
345
|
+
The data properties whose value now differs from the one the entity was last saved or accepted
|
|
346
|
+
with - as paths, such as `'location.city'`, for those of a complex property, and by name for an
|
|
347
|
+
array property whose contents changed. A property edited and then set back is not included,
|
|
348
|
+
although it stays in {@link EntityAspect.originalValues}. Dates are compared by time.
|
|
349
|
+
```ts
|
|
350
|
+
order.freight = 99;
|
|
351
|
+
order.shipCity = order.shipCity; // set, but to the same value
|
|
352
|
+
order.entityAspect.getChangedProperties(); // ['freight']
|
|
353
|
+
```
|
|
354
|
+
Always empty for an `Added` entity, which has no original values to differ from.
|
|
355
|
+
*/
|
|
356
|
+
getChangedProperties(): string[];
|
|
357
|
+
/**
|
|
358
|
+
Adds a validation error.
|
|
359
|
+
|
|
360
|
+
An error added here stops the entity being saved - `validateEntity` returns false and
|
|
361
|
+
`saveChanges` rejects - until it is removed with {@link EntityAspect.removeValidationError} or
|
|
362
|
+
{@link EntityAspect.clearValidationErrors}. Editing the property does not remove it: Breeze
|
|
363
|
+
cannot re-check a rule it did not run. Give the error a key, and a failed save names it by that
|
|
364
|
+
key in `errorName`.
|
|
365
|
+
*/
|
|
366
|
+
addValidationError(validationError: ValidationError): void;
|
|
367
|
+
removeValidationError(validationError: ValidationError): void;
|
|
368
|
+
removeValidationError(validationKey: string): void;
|
|
369
|
+
removeValidationError(validator: Validator): void;
|
|
370
|
+
/**
|
|
371
|
+
Removes all of the validation errors for a specified entity
|
|
372
|
+
*/
|
|
373
|
+
clearValidationErrors(): void;
|
|
374
|
+
/**
|
|
375
|
+
Returns an {@link EntityKey} for the entity pointed to by the specified scalar NavigationProperty.
|
|
376
|
+
This only returns an EntityKey if the current entity is a 'child' entity along the specified NavigationProperty.
|
|
377
|
+
i.e. has a single parent.
|
|
378
|
+
|
|
379
|
+
@param navigationProperty - The {@link NavigationProperty} ( pointing to a parent).
|
|
380
|
+
@returns Either a parent EntityKey if this is a 'child' entity or null;
|
|
381
|
+
*/
|
|
382
|
+
getParentKey(navigationProperty: NavigationProperty): EntityKey | null;
|
|
383
|
+
/**
|
|
384
|
+
Returns the value of a specified DataProperty or NavigationProperty or 'property path'.
|
|
385
|
+
*/
|
|
386
|
+
getPropertyValue(property: string | DataProperty | NavigationProperty): any;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
An ComplexAspect instance is associated with every complex object instance and is accessed via the complex object's 'complexAspect' property.
|
|
390
|
+
|
|
391
|
+
The ComplexAspect itself provides properties to determine the parent object, parent property and original values for the complex object.
|
|
392
|
+
|
|
393
|
+
A ComplexAspect will almost never need to be constructed directly. You will usually get an ComplexAspect by accessing
|
|
394
|
+
an entities 'complexAspect' property. This property will be automatically attached when an complex object is created as part of an
|
|
395
|
+
entity via either a query, import or EntityManager.createEntity call.
|
|
396
|
+
```ts
|
|
397
|
+
// assume address is a complex property on the 'Customer' type
|
|
398
|
+
var aspect = aCustomer.address.complexAspect;
|
|
399
|
+
// aCustomer === aspect.parent;
|
|
400
|
+
```
|
|
401
|
+
*/
|
|
402
|
+
export declare class ComplexAspect {
|
|
403
|
+
/** The complex object that this aspect is associated with. __Read Only__ */
|
|
404
|
+
complexObject: ComplexObject;
|
|
405
|
+
/** The 'original values' of this complex object where they are different from the 'current values'.
|
|
406
|
+
This is a map where the key is a property name and the value is the 'original value' of the property.
|
|
407
|
+
__Read Only__ */
|
|
408
|
+
originalValues: Record<string, any>;
|
|
409
|
+
/** The parent object that to which this aspect belongs; this will either be an entity or another complex object. __Read Only__ */
|
|
410
|
+
parent?: StructuralObject;
|
|
411
|
+
/** The {@link DataProperty} on the 'parent' that contains this complex object. __Read Only__ */
|
|
412
|
+
parentProperty?: DataProperty;
|
|
413
|
+
/** Unlike {@link EntityAspect.extraMetadata}, Breeze does not fill this in and does not export it.
|
|
414
|
+
An application may use it to hold its own data about the complex object. */
|
|
415
|
+
extraMetadata?: any;
|
|
416
|
+
/** You will rarely, if ever, create a ComplexAspect directly. */
|
|
417
|
+
constructor(complexObject: ComplexObject, parent: StructuralObject, parentProperty: DataProperty);
|
|
418
|
+
/**
|
|
419
|
+
Returns the EntityAspect for the top level entity that contains this complex object.
|
|
420
|
+
*/
|
|
421
|
+
getEntityAspect(): any;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
An {@link EntityAspect} that knows its entity's class, `T`: the type a generated entity class gives
|
|
425
|
+
its `entityAspect`, as `EntityAspectOf<this>`. It is the same object; only the types are narrower -
|
|
426
|
+
property names are checked, and values have their properties' types:
|
|
427
|
+
```ts
|
|
428
|
+
order.freight = 99;
|
|
429
|
+
order.entityAspect.originalValues.freight; // number | undefined
|
|
430
|
+
order.entityAspect.getOriginalValue('freight'); // number
|
|
431
|
+
order.entityAspect.getOriginalValue('frieght'); // error: not a property of Order
|
|
432
|
+
order.entityAspect.getChangedProperties(); // ('freight' | 'shipCity' | …)[]
|
|
433
|
+
```
|
|
434
|
+
An interface extending the class, rather than a type parameter on it, so that it is an
|
|
435
|
+
`EntityAspect` by declaration: a generic `EntityAspect<T>` whose members read `keyof T` would not be
|
|
436
|
+
one, and every generated class needs its aspect to be. And typed only by `T`'s own data properties:
|
|
437
|
+
to reach through a navigation property, the types would have to ask whether the entity at the other
|
|
438
|
+
end is an `Entity` - which asks about its aspect, and so about this one.
|
|
439
|
+
*/
|
|
440
|
+
export interface EntityAspectOf<T> extends EntityAspect {
|
|
441
|
+
/** {@link EntityAspect.originalValues}, keyed and typed by `T`'s data properties. */
|
|
442
|
+
originalValues: OriginalValues<T>;
|
|
443
|
+
/** {@link EntityAspect.getOriginalValue}, with the name checked against `T` and the value typed. */
|
|
444
|
+
getOriginalValue<K extends DataKeys<T>>(propertyName: K): T[K];
|
|
445
|
+
/** {@link EntityAspect.getOriginalValue} for a path into a complex property, such as `'location.city'`: untyped. */
|
|
446
|
+
getOriginalValue(propertyPath: `${string}.${string}`): any;
|
|
447
|
+
/** {@link EntityAspect.getChangedProperties}: `T`'s data properties, and paths into its complex ones. */
|
|
448
|
+
getChangedProperties(): (DataKeys<T> | `${string}.${string}`)[];
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
A {@link ComplexAspect} that knows its complex object's class, `T`: the type a generated complex type
|
|
452
|
+
class gives its `complexAspect`, as `ComplexAspectOf<this>`. See {@link EntityAspectOf}.
|
|
453
|
+
*/
|
|
454
|
+
export interface ComplexAspectOf<T> extends ComplexAspect {
|
|
455
|
+
/** {@link ComplexAspect.originalValues}, keyed and typed by `T`'s data properties. */
|
|
456
|
+
originalValues: OriginalValues<T>;
|
|
457
|
+
}
|