breeze-client 2.2.1 → 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 +62 -93
- 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,119 +1,143 @@
|
|
|
1
|
-
import { BreezeEnum } from '
|
|
2
|
-
/**
|
|
3
|
-
MergeStrategy is an 'Enum' that determines how entities are merged into an EntityManager.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
FromServer
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
FromLocalCache
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
/** The
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
-
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
using(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
1
|
+
import { BreezeEnum } from '../core/enum.js';
|
|
2
|
+
/**
|
|
3
|
+
MergeStrategy is an 'Enum' that determines how entities are merged into an EntityManager.
|
|
4
|
+
|
|
5
|
+
*/
|
|
6
|
+
export declare class MergeStrategy extends BreezeEnum {
|
|
7
|
+
/**
|
|
8
|
+
MergeStrategy.PreserveChanges updates the cached entity with the incoming values unless the cached entity is in a changed
|
|
9
|
+
state (added, modified, deleted) in which case the incoming values are ignored. The updated cached entity’s EntityState will
|
|
10
|
+
remain {@link EntityState.Unchanged} unless you’re importing entities in which case the new EntityState will
|
|
11
|
+
be that of the imported entities.
|
|
12
|
+
*/
|
|
13
|
+
static PreserveChanges: MergeStrategy;
|
|
14
|
+
/**
|
|
15
|
+
MergeStrategy.OverwriteChanges always updates the cached entity with incoming values even if the entity is in
|
|
16
|
+
a changed state (added, modified, deleted). After the merge, the pending changes are lost.
|
|
17
|
+
The new EntityState will be {@link EntityState.Unchanged} unless you’re importing entities
|
|
18
|
+
in which case the new EntityState will be that of the imported entities.
|
|
19
|
+
*/
|
|
20
|
+
static OverwriteChanges: MergeStrategy;
|
|
21
|
+
/**
|
|
22
|
+
SkipMerge is used to ignore incoming values. Adds the incoming entity to the cache only if there is no cached entity with the same key.
|
|
23
|
+
This is the fastest merge strategy but your existing cached data will remain “stale”.
|
|
24
|
+
*/
|
|
25
|
+
static SkipMerge: MergeStrategy;
|
|
26
|
+
/**
|
|
27
|
+
Disallowed is used to throw an exception if there is an incoming entity with the same key as an entity already in the cache.
|
|
28
|
+
Use this strategy when you want to be sure that the incoming entity is not already in cache.
|
|
29
|
+
This is the default strategy for EntityManager.attachEntity.
|
|
30
|
+
*/
|
|
31
|
+
static Disallowed: MergeStrategy;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
FetchStrategy is an 'Enum' that determines how and where entities are retrieved from as a result of a query.
|
|
35
|
+
*/
|
|
36
|
+
export declare class FetchStrategy extends BreezeEnum {
|
|
37
|
+
/**
|
|
38
|
+
FromServer is used to tell the query to execute the query against a remote data source on the server.
|
|
39
|
+
*/
|
|
40
|
+
static FromServer: FetchStrategy;
|
|
41
|
+
/**
|
|
42
|
+
FromLocalCache is used to tell the query to execute the query against a local EntityManager instead of going to a remote server.
|
|
43
|
+
*/
|
|
44
|
+
static FromLocalCache: FetchStrategy;
|
|
45
|
+
}
|
|
46
|
+
/** Configuration info to be passed to the {@link QueryOptions} constructor. */
|
|
47
|
+
export interface QueryOptionsConfig {
|
|
48
|
+
/** The {@link FetchStrategy} to use with any queries.*/
|
|
49
|
+
fetchStrategy?: FetchStrategy;
|
|
50
|
+
/** The {@link MergeStrategy} to use with any queries.*/
|
|
51
|
+
mergeStrategy?: MergeStrategy;
|
|
52
|
+
/** Whether to include cached deleted entities in a query result (false by default). __Read Only__ */
|
|
53
|
+
includeDeleted?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
A QueryOptions instance is used to specify the 'options' under which a query will occur.
|
|
57
|
+
*/
|
|
58
|
+
export declare class QueryOptions {
|
|
59
|
+
/** The {@link FetchStrategy} to use with any queries. __Read Only__ */
|
|
60
|
+
fetchStrategy: FetchStrategy;
|
|
61
|
+
/** The {@link MergeStrategy} to use with any queries. __Read Only__ */
|
|
62
|
+
mergeStrategy: MergeStrategy;
|
|
63
|
+
/** Whether to include cached deleted entities in a query result (false by default). __Read Only__ */
|
|
64
|
+
includeDeleted: boolean;
|
|
65
|
+
/**
|
|
66
|
+
The default instance for use whenever QueryOptions are not specified.
|
|
67
|
+
*/
|
|
68
|
+
static defaultInstance: QueryOptions;
|
|
69
|
+
/**
|
|
70
|
+
QueryOptions constructor
|
|
71
|
+
```ts
|
|
72
|
+
var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });
|
|
73
|
+
// assume em1 is a preexisting EntityManager
|
|
74
|
+
em1.setProperties( { queryOptions: newQo });
|
|
75
|
+
```
|
|
76
|
+
Any QueryOptions property that is not defined will be defaulted from any QueryOptions defined at a higher level in the breeze hierarchy, i.e.
|
|
77
|
+
- from query.queryOptions
|
|
78
|
+
- to entityManager.queryOptions
|
|
79
|
+
- to QueryOptions.defaultInstance;
|
|
80
|
+
|
|
81
|
+
@param config - A configuration object.
|
|
82
|
+
*/
|
|
83
|
+
constructor(config?: QueryOptionsConfig);
|
|
84
|
+
/**
|
|
85
|
+
Combines several QueryOptions into one, taking each property from the first of them that has it
|
|
86
|
+
set. Breeze uses it to combine a query's own options with its EntityManager's and
|
|
87
|
+
{@link QueryOptions.defaultInstance}; applications do not normally need it.
|
|
88
|
+
@param queryOptionsArray - The QueryOptions to combine, most specific first. Entries may be null
|
|
89
|
+
or undefined.
|
|
90
|
+
*/
|
|
91
|
+
static resolve(queryOptionsArray: any[]): QueryOptions;
|
|
92
|
+
/**
|
|
93
|
+
Returns a copy of this QueryOptions with the specified {@link MergeStrategy},
|
|
94
|
+
{@link FetchStrategy}, or 'includeDeleted' option applied.
|
|
95
|
+
```ts
|
|
96
|
+
// Given an EntityManager instance, em
|
|
97
|
+
var queryOptions = em.queryOptions.using(MergeStrategy.PreserveChanges);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
or
|
|
101
|
+
```ts
|
|
102
|
+
var queryOptions = em.queryOptions.using(FetchStrategy.FromLocalCache);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
or
|
|
106
|
+
```ts
|
|
107
|
+
var queryOptions = em.queryOptions.using({ mergeStrategy: MergeStrategy.OverwriteChanges });
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
or
|
|
111
|
+
```ts
|
|
112
|
+
var queryOptions = em.queryOptions.using({
|
|
113
|
+
includeDeleted: true,
|
|
114
|
+
fetchStrategy: FetchStrategy.FromLocalCache
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
@param qoConfig - A configuration object or a standalone {@link MergeStrategy} or {@link FetchStrategy}
|
|
118
|
+
@returns A new QueryOptions instance.
|
|
119
|
+
*/
|
|
120
|
+
using(qoConfig: QueryOptionsConfig | MergeStrategy | FetchStrategy): QueryOptions;
|
|
121
|
+
/**
|
|
122
|
+
Sets the 'defaultInstance' by creating a copy of the current 'defaultInstance' and then applying all of the properties of the current instance.
|
|
123
|
+
The current instance is returned unchanged.
|
|
124
|
+
```ts
|
|
125
|
+
var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });
|
|
126
|
+
newQo.setAsDefault();
|
|
127
|
+
```
|
|
128
|
+
*/
|
|
129
|
+
setAsDefault(): any;
|
|
130
|
+
/**
|
|
131
|
+
Returns the serializable form of these options: the names of the `fetchStrategy` and
|
|
132
|
+
`mergeStrategy`, and `includeDeleted` when it is `true`. `JSON.stringify` calls it when
|
|
133
|
+
`EntityManager.exportEntities` exports the manager's options and when a query is serialized;
|
|
134
|
+
{@link QueryOptions.fromJSON} reads it back.
|
|
135
|
+
*/
|
|
136
|
+
toJSON(): Object;
|
|
137
|
+
/**
|
|
138
|
+
Creates a QueryOptions from the output of {@link QueryOptions.toJSON}. Used by
|
|
139
|
+
`EntityManager.importEntities` and when a serialized query is read back.
|
|
140
|
+
@param json - A serialized QueryOptions.
|
|
141
|
+
*/
|
|
142
|
+
static fromJSON(json: any): QueryOptions;
|
|
143
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { core } from '../core/core.js';
|
|
2
|
+
import { BreezeEnum } from '../core/enum.js';
|
|
3
|
+
import { assertConfig } from '../core/assert-param.js';
|
|
4
|
+
/**
|
|
5
|
+
MergeStrategy is an 'Enum' that determines how entities are merged into an EntityManager.
|
|
6
|
+
|
|
7
|
+
*/
|
|
8
|
+
export class MergeStrategy extends BreezeEnum {
|
|
9
|
+
/**
|
|
10
|
+
MergeStrategy.PreserveChanges updates the cached entity with the incoming values unless the cached entity is in a changed
|
|
11
|
+
state (added, modified, deleted) in which case the incoming values are ignored. The updated cached entity’s EntityState will
|
|
12
|
+
remain {@link EntityState.Unchanged} unless you’re importing entities in which case the new EntityState will
|
|
13
|
+
be that of the imported entities.
|
|
14
|
+
*/
|
|
15
|
+
static PreserveChanges = new MergeStrategy();
|
|
16
|
+
/**
|
|
17
|
+
MergeStrategy.OverwriteChanges always updates the cached entity with incoming values even if the entity is in
|
|
18
|
+
a changed state (added, modified, deleted). After the merge, the pending changes are lost.
|
|
19
|
+
The new EntityState will be {@link EntityState.Unchanged} unless you’re importing entities
|
|
20
|
+
in which case the new EntityState will be that of the imported entities.
|
|
21
|
+
*/
|
|
22
|
+
static OverwriteChanges = new MergeStrategy();
|
|
23
|
+
/**
|
|
24
|
+
SkipMerge is used to ignore incoming values. Adds the incoming entity to the cache only if there is no cached entity with the same key.
|
|
25
|
+
This is the fastest merge strategy but your existing cached data will remain “stale”.
|
|
26
|
+
*/
|
|
27
|
+
static SkipMerge = new MergeStrategy();
|
|
28
|
+
/**
|
|
29
|
+
Disallowed is used to throw an exception if there is an incoming entity with the same key as an entity already in the cache.
|
|
30
|
+
Use this strategy when you want to be sure that the incoming entity is not already in cache.
|
|
31
|
+
This is the default strategy for EntityManager.attachEntity.
|
|
32
|
+
*/
|
|
33
|
+
static Disallowed = new MergeStrategy();
|
|
34
|
+
}
|
|
35
|
+
MergeStrategy.prototype._$typeName = "MergeStrategy";
|
|
36
|
+
MergeStrategy.resolveSymbols();
|
|
37
|
+
/**
|
|
38
|
+
FetchStrategy is an 'Enum' that determines how and where entities are retrieved from as a result of a query.
|
|
39
|
+
*/
|
|
40
|
+
export class FetchStrategy extends BreezeEnum {
|
|
41
|
+
/**
|
|
42
|
+
FromServer is used to tell the query to execute the query against a remote data source on the server.
|
|
43
|
+
*/
|
|
44
|
+
static FromServer = new FetchStrategy();
|
|
45
|
+
/**
|
|
46
|
+
FromLocalCache is used to tell the query to execute the query against a local EntityManager instead of going to a remote server.
|
|
47
|
+
*/
|
|
48
|
+
static FromLocalCache = new FetchStrategy();
|
|
49
|
+
}
|
|
50
|
+
FetchStrategy.prototype._$typeName = "FetchStrategy";
|
|
51
|
+
FetchStrategy.resolveSymbols();
|
|
52
|
+
/**
|
|
53
|
+
A QueryOptions instance is used to specify the 'options' under which a query will occur.
|
|
54
|
+
*/
|
|
55
|
+
export class QueryOptions {
|
|
56
|
+
/**
|
|
57
|
+
The default instance for use whenever QueryOptions are not specified.
|
|
58
|
+
*/
|
|
59
|
+
static defaultInstance = new QueryOptions({
|
|
60
|
+
fetchStrategy: FetchStrategy.FromServer,
|
|
61
|
+
mergeStrategy: MergeStrategy.PreserveChanges,
|
|
62
|
+
includeDeleted: false
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
QueryOptions constructor
|
|
66
|
+
```ts
|
|
67
|
+
var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });
|
|
68
|
+
// assume em1 is a preexisting EntityManager
|
|
69
|
+
em1.setProperties( { queryOptions: newQo });
|
|
70
|
+
```
|
|
71
|
+
Any QueryOptions property that is not defined will be defaulted from any QueryOptions defined at a higher level in the breeze hierarchy, i.e.
|
|
72
|
+
- from query.queryOptions
|
|
73
|
+
- to entityManager.queryOptions
|
|
74
|
+
- to QueryOptions.defaultInstance;
|
|
75
|
+
|
|
76
|
+
@param config - A configuration object.
|
|
77
|
+
*/
|
|
78
|
+
constructor(config) {
|
|
79
|
+
QueryOptions._updateWithConfig(this, config);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
Combines several QueryOptions into one, taking each property from the first of them that has it
|
|
83
|
+
set. Breeze uses it to combine a query's own options with its EntityManager's and
|
|
84
|
+
{@link QueryOptions.defaultInstance}; applications do not normally need it.
|
|
85
|
+
@param queryOptionsArray - The QueryOptions to combine, most specific first. Entries may be null
|
|
86
|
+
or undefined.
|
|
87
|
+
*/
|
|
88
|
+
static resolve(queryOptionsArray) {
|
|
89
|
+
return new QueryOptions(core.resolveProperties(queryOptionsArray, ["fetchStrategy", "mergeStrategy", "includeDeleted"]));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
Returns a copy of this QueryOptions with the specified {@link MergeStrategy},
|
|
93
|
+
{@link FetchStrategy}, or 'includeDeleted' option applied.
|
|
94
|
+
```ts
|
|
95
|
+
// Given an EntityManager instance, em
|
|
96
|
+
var queryOptions = em.queryOptions.using(MergeStrategy.PreserveChanges);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
or
|
|
100
|
+
```ts
|
|
101
|
+
var queryOptions = em.queryOptions.using(FetchStrategy.FromLocalCache);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
or
|
|
105
|
+
```ts
|
|
106
|
+
var queryOptions = em.queryOptions.using({ mergeStrategy: MergeStrategy.OverwriteChanges });
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
or
|
|
110
|
+
```ts
|
|
111
|
+
var queryOptions = em.queryOptions.using({
|
|
112
|
+
includeDeleted: true,
|
|
113
|
+
fetchStrategy: FetchStrategy.FromLocalCache
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
@param qoConfig - A configuration object or a standalone {@link MergeStrategy} or {@link FetchStrategy}
|
|
117
|
+
@returns A new QueryOptions instance.
|
|
118
|
+
*/
|
|
119
|
+
using(qoConfig) {
|
|
120
|
+
if (!qoConfig)
|
|
121
|
+
return this;
|
|
122
|
+
let result = new QueryOptions(this);
|
|
123
|
+
if (qoConfig instanceof MergeStrategy) {
|
|
124
|
+
qoConfig = { mergeStrategy: qoConfig };
|
|
125
|
+
}
|
|
126
|
+
else if (qoConfig instanceof FetchStrategy) {
|
|
127
|
+
qoConfig = { fetchStrategy: qoConfig };
|
|
128
|
+
}
|
|
129
|
+
return QueryOptions._updateWithConfig(result, qoConfig);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
Sets the 'defaultInstance' by creating a copy of the current 'defaultInstance' and then applying all of the properties of the current instance.
|
|
133
|
+
The current instance is returned unchanged.
|
|
134
|
+
```ts
|
|
135
|
+
var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });
|
|
136
|
+
newQo.setAsDefault();
|
|
137
|
+
```
|
|
138
|
+
*/
|
|
139
|
+
setAsDefault() {
|
|
140
|
+
return core.setAsDefault(this, QueryOptions);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
Returns the serializable form of these options: the names of the `fetchStrategy` and
|
|
144
|
+
`mergeStrategy`, and `includeDeleted` when it is `true`. `JSON.stringify` calls it when
|
|
145
|
+
`EntityManager.exportEntities` exports the manager's options and when a query is serialized;
|
|
146
|
+
{@link QueryOptions.fromJSON} reads it back.
|
|
147
|
+
*/
|
|
148
|
+
toJSON() {
|
|
149
|
+
return core.toJson(this, {
|
|
150
|
+
fetchStrategy: null,
|
|
151
|
+
mergeStrategy: null,
|
|
152
|
+
includeDeleted: false
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
Creates a QueryOptions from the output of {@link QueryOptions.toJSON}. Used by
|
|
157
|
+
`EntityManager.importEntities` and when a serialized query is read back.
|
|
158
|
+
@param json - A serialized QueryOptions.
|
|
159
|
+
*/
|
|
160
|
+
static fromJSON(json) {
|
|
161
|
+
return new QueryOptions({
|
|
162
|
+
fetchStrategy: FetchStrategy.fromName(json.fetchStrategy),
|
|
163
|
+
mergeStrategy: MergeStrategy.fromName(json.mergeStrategy),
|
|
164
|
+
includeDeleted: json.includeDeleted === true
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/** @hidden @internal */
|
|
168
|
+
static _updateWithConfig(obj, config) {
|
|
169
|
+
if (config) {
|
|
170
|
+
assertConfig(config)
|
|
171
|
+
.whereParam("fetchStrategy").isEnumOf(FetchStrategy).isOptional()
|
|
172
|
+
.whereParam("mergeStrategy").isEnumOf(MergeStrategy).isOptional()
|
|
173
|
+
.whereParam("includeDeleted").isBoolean().isOptional()
|
|
174
|
+
.applyAll(obj);
|
|
175
|
+
}
|
|
176
|
+
return obj;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
QueryOptions.prototype._$typeName = "QueryOptions";
|
|
180
|
+
//# sourceMappingURL=query-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-options.js","sourceRoot":"","sources":["../../src/query/query-options.ts"],"names":[],"mappings":"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","sourcesContent":["import { core } from '../core/core.js';\nimport { BreezeEnum } from '../core/enum.js';\nimport { assertConfig } from '../core/assert-param.js';\n\n/**\nMergeStrategy is an 'Enum' that determines how entities are merged into an EntityManager.\n\n*/\nexport class MergeStrategy extends BreezeEnum {\n\n /**\n MergeStrategy.PreserveChanges updates the cached entity with the incoming values unless the cached entity is in a changed\n state (added, modified, deleted) in which case the incoming values are ignored. The updated cached entity’s EntityState will\n remain {@link EntityState.Unchanged} unless you’re importing entities in which case the new EntityState will\n be that of the imported entities.\n */\n static PreserveChanges = new MergeStrategy();\n /**\n MergeStrategy.OverwriteChanges always updates the cached entity with incoming values even if the entity is in\n a changed state (added, modified, deleted). After the merge, the pending changes are lost.\n The new EntityState will be {@link EntityState.Unchanged} unless you’re importing entities\n in which case the new EntityState will be that of the imported entities.\n */\n static OverwriteChanges = new MergeStrategy();\n\n /**\n SkipMerge is used to ignore incoming values. Adds the incoming entity to the cache only if there is no cached entity with the same key.\n This is the fastest merge strategy but your existing cached data will remain “stale”.\n */\n static SkipMerge = new MergeStrategy();\n\n /**\n Disallowed is used to throw an exception if there is an incoming entity with the same key as an entity already in the cache.\n Use this strategy when you want to be sure that the incoming entity is not already in cache.\n This is the default strategy for EntityManager.attachEntity.\n */\n static Disallowed = new MergeStrategy();\n\n\n}\nMergeStrategy.prototype._$typeName = \"MergeStrategy\";\nMergeStrategy.resolveSymbols();\n\n/**\nFetchStrategy is an 'Enum' that determines how and where entities are retrieved from as a result of a query.\n*/\nexport class FetchStrategy extends BreezeEnum {\n\n /**\n FromServer is used to tell the query to execute the query against a remote data source on the server.\n */\n static FromServer = new FetchStrategy();\n /**\n FromLocalCache is used to tell the query to execute the query against a local EntityManager instead of going to a remote server.\n */\n static FromLocalCache = new FetchStrategy();\n\n}\nFetchStrategy.prototype._$typeName = \"FetchStrategy\";\nFetchStrategy.resolveSymbols();\n\n/** Configuration info to be passed to the {@link QueryOptions} constructor. */\nexport interface QueryOptionsConfig {\n /** The {@link FetchStrategy} to use with any queries.*/\n fetchStrategy?: FetchStrategy;\n /** The {@link MergeStrategy} to use with any queries.*/\n mergeStrategy?: MergeStrategy;\n /** Whether to include cached deleted entities in a query result (false by default). __Read Only__ */\n includeDeleted?: boolean;\n}\n\n/**\nA QueryOptions instance is used to specify the 'options' under which a query will occur.\n*/\nexport class QueryOptions {\n /** @hidden @internal */\n declare _$typeName: string;\n /** The {@link FetchStrategy} to use with any queries. __Read Only__ */\n declare fetchStrategy: FetchStrategy;\n /** The {@link MergeStrategy} to use with any queries. __Read Only__ */\n declare mergeStrategy: MergeStrategy;\n /** Whether to include cached deleted entities in a query result (false by default). __Read Only__ */\n declare includeDeleted: boolean;\n\n /**\n The default instance for use whenever QueryOptions are not specified.\n */\n static defaultInstance = new QueryOptions({\n fetchStrategy: FetchStrategy.FromServer,\n mergeStrategy: MergeStrategy.PreserveChanges,\n includeDeleted: false\n });\n\n /**\n QueryOptions constructor\n ```ts\n var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });\n // assume em1 is a preexisting EntityManager\n em1.setProperties( { queryOptions: newQo });\n ```\n Any QueryOptions property that is not defined will be defaulted from any QueryOptions defined at a higher level in the breeze hierarchy, i.e.\n - from query.queryOptions\n - to entityManager.queryOptions\n - to QueryOptions.defaultInstance;\n\n @param config - A configuration object.\n */\n constructor(config?: QueryOptionsConfig) {\n QueryOptions._updateWithConfig(this, config);\n }\n\n /**\n Combines several QueryOptions into one, taking each property from the first of them that has it\n set. Breeze uses it to combine a query's own options with its EntityManager's and\n {@link QueryOptions.defaultInstance}; applications do not normally need it.\n @param queryOptionsArray - The QueryOptions to combine, most specific first. Entries may be null\n or undefined.\n */\n static resolve(queryOptionsArray: any[]) {\n return new QueryOptions(core.resolveProperties(queryOptionsArray, [\"fetchStrategy\", \"mergeStrategy\", \"includeDeleted\"]));\n }\n\n /**\n Returns a copy of this QueryOptions with the specified {@link MergeStrategy},\n {@link FetchStrategy}, or 'includeDeleted' option applied.\n ```ts\n // Given an EntityManager instance, em\n var queryOptions = em.queryOptions.using(MergeStrategy.PreserveChanges);\n ```\n\n or\n ```ts\n var queryOptions = em.queryOptions.using(FetchStrategy.FromLocalCache);\n ```\n\n or\n ```ts\n var queryOptions = em.queryOptions.using({ mergeStrategy: MergeStrategy.OverwriteChanges });\n ```\n\n or\n ```ts\n var queryOptions = em.queryOptions.using({\n includeDeleted: true,\n fetchStrategy: FetchStrategy.FromLocalCache \n });\n ```\n @param qoConfig - A configuration object or a standalone {@link MergeStrategy} or {@link FetchStrategy} \n @returns A new QueryOptions instance.\n */\n using(qoConfig: QueryOptionsConfig | MergeStrategy | FetchStrategy) {\n if (!qoConfig) return this;\n let result = new QueryOptions(this);\n if ( qoConfig instanceof MergeStrategy) {\n qoConfig = { mergeStrategy: qoConfig };\n } else if ( qoConfig instanceof FetchStrategy) {\n qoConfig = { fetchStrategy: qoConfig };\n }\n return QueryOptions._updateWithConfig(result, qoConfig);\n }\n\n /**\n Sets the 'defaultInstance' by creating a copy of the current 'defaultInstance' and then applying all of the properties of the current instance.\n The current instance is returned unchanged.\n ```ts\n var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });\n newQo.setAsDefault();\n ```\n */\n setAsDefault() {\n return core.setAsDefault(this, QueryOptions);\n }\n\n /**\n Returns the serializable form of these options: the names of the `fetchStrategy` and\n `mergeStrategy`, and `includeDeleted` when it is `true`. `JSON.stringify` calls it when\n `EntityManager.exportEntities` exports the manager's options and when a query is serialized;\n {@link QueryOptions.fromJSON} reads it back.\n */\n toJSON() {\n return core.toJson(this, {\n fetchStrategy: null,\n mergeStrategy: null,\n includeDeleted: false\n });\n }\n\n /**\n Creates a QueryOptions from the output of {@link QueryOptions.toJSON}. Used by\n `EntityManager.importEntities` and when a serialized query is read back.\n @param json - A serialized QueryOptions.\n */\n static fromJSON(json: any) {\n return new QueryOptions({\n fetchStrategy: FetchStrategy.fromName(json.fetchStrategy),\n mergeStrategy: MergeStrategy.fromName(json.mergeStrategy),\n includeDeleted: json.includeDeleted === true\n });\n }\n\n /** @hidden @internal */\n private static _updateWithConfig(obj: QueryOptions, config?: QueryOptionsConfig) {\n if (config) {\n assertConfig(config)\n .whereParam(\"fetchStrategy\").isEnumOf(FetchStrategy).isOptional()\n .whereParam(\"mergeStrategy\").isEnumOf(MergeStrategy).isOptional()\n .whereParam(\"includeDeleted\").isBoolean().isOptional()\n .applyAll(obj);\n }\n return obj;\n }\n\n}\nQueryOptions.prototype._$typeName = \"QueryOptions\";\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import type { BreezeEvent } from '../core/event.js';
|
|
3
|
+
import type { Entity, PropertyChangedEventArgs } from '../entity/entity-aspect.js';
|
|
4
|
+
import type { EntityChangedEventArgs, EntityManager, ValidationErrorsChangedEventArgs } from '../manager/entity-manager.js';
|
|
5
|
+
/**
|
|
6
|
+
* Any {@link BreezeEvent} as an Observable: each value the event publishes is emitted, for as long
|
|
7
|
+
* as the subscription lasts.
|
|
8
|
+
*
|
|
9
|
+
* The other functions in this module are this, applied to a particular event. Use it directly for
|
|
10
|
+
* the ones they do not cover - `metadataStore.metadataFetched`, say.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* fromBreezeEvent(em.metadataStore.metadataFetched).subscribe(args => console.log(args.metadata));
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* An error thrown by a subscriber does not reach Breeze: rxjs reports it on its own, and the
|
|
17
|
+
* event's other subscribers still hear about the change.
|
|
18
|
+
*
|
|
19
|
+
* @param event - the event to observe
|
|
20
|
+
* @returns an Observable that subscribes to `event` when it is subscribed to, and unsubscribes when
|
|
21
|
+
* it is torn down
|
|
22
|
+
*/
|
|
23
|
+
export declare function fromBreezeEvent<T>(event: BreezeEvent<T>): Observable<T>;
|
|
24
|
+
/**
|
|
25
|
+
* {@link EntityManager.entityChanged} as an Observable: every entity added, attached, detached,
|
|
26
|
+
* changed, saved or rejected in `em`.
|
|
27
|
+
*
|
|
28
|
+
* Filter for what you want with rxjs:
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* entityChanged$(em).pipe(
|
|
32
|
+
* filter(e => e.entityAction === EntityAction.PropertyChange),
|
|
33
|
+
* ).subscribe(e => markDirty(e.entity));
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function entityChanged$(em: EntityManager): Observable<EntityChangedEventArgs>;
|
|
37
|
+
/**
|
|
38
|
+
* Whether `em` has unsaved changes, as an Observable that starts with the current value.
|
|
39
|
+
*
|
|
40
|
+
* {@link EntityManager.hasChangesChanged} only fires on a change, so on its own it cannot tell a
|
|
41
|
+
* late subscriber what the answer is *now*. This emits `em.hasChanges()` as soon as it is
|
|
42
|
+
* subscribed to, then each change after that, and never the same value twice in a row. Bind a Save
|
|
43
|
+
* button to it and the button is right from the first render.
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* hasChanges$(em).subscribe(dirty => saveButton.disabled = !dirty);
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* The current value is read when you subscribe, not when you call this function.
|
|
50
|
+
*/
|
|
51
|
+
export declare function hasChanges$(em: EntityManager): Observable<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* {@link EntityManager.validationErrorsChanged} as an Observable: validation errors added to or
|
|
54
|
+
* removed from any entity in `em`.
|
|
55
|
+
*
|
|
56
|
+
* Each value says what changed, not the complete set. For "every validation error in the manager
|
|
57
|
+
* right now", see the recipe in the guide, which builds one from this.
|
|
58
|
+
*/
|
|
59
|
+
export declare function validationErrorsChanged$(em: EntityManager): Observable<ValidationErrorsChangedEventArgs>;
|
|
60
|
+
/**
|
|
61
|
+
* {@link EntityAspect.propertyChanged} as an Observable: each property of one entity that changes.
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* propertyChanged$(order).pipe(
|
|
65
|
+
* filter(e => e.propertyName === 'shipCountry'),
|
|
66
|
+
* ).subscribe(() => recalculateTax(order));
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* A live subscription keeps `entity` reachable, as any subscription to it would. Unsubscribe when
|
|
70
|
+
* the screen showing it goes away.
|
|
71
|
+
*/
|
|
72
|
+
export declare function propertyChanged$(entity: Entity): Observable<PropertyChangedEventArgs>;
|