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.
Files changed (299) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +83 -63
  3. package/adapters/abstract-data-service-adapter.d.ts +120 -0
  4. package/adapters/abstract-data-service-adapter.js +395 -0
  5. package/adapters/abstract-data-service-adapter.js.map +1 -0
  6. package/adapters/adapter-ajax-fetch.d.ts +12 -0
  7. package/adapters/adapter-ajax-fetch.js +13 -0
  8. package/adapters/adapter-ajax-fetch.js.map +1 -0
  9. package/{adapter-ajax-post → adapters}/adapter-ajax-post.d.ts +40 -36
  10. package/{fesm2022/breeze-client-adapter-ajax-post.mjs → adapters/adapter-ajax-post.js} +80 -82
  11. package/adapters/adapter-ajax-post.js.map +1 -0
  12. package/{adapter-ajax-fetch → adapters}/adapter-core.d.ts +4 -4
  13. package/{fesm2022/breeze-client-adapter-uri-builder-json.mjs → adapters/adapter-core.js} +48 -91
  14. package/adapters/adapter-core.js.map +1 -0
  15. package/adapters/adapter-data-service-webapi.d.ts +9 -0
  16. package/{fesm2022/breeze-client-adapter-data-service-webapi.mjs → adapters/adapter-data-service-webapi.js} +105 -107
  17. package/adapters/adapter-data-service-webapi.js.map +1 -0
  18. package/adapters/adapter-model-library-backing-store.d.ts +32 -0
  19. package/adapters/adapter-model-library-backing-store.js +321 -0
  20. package/adapters/adapter-model-library-backing-store.js.map +1 -0
  21. package/adapters/adapter-uri-builder-json.d.ts +11 -0
  22. package/adapters/adapter-uri-builder-json.js +40 -0
  23. package/adapters/adapter-uri-builder-json.js.map +1 -0
  24. package/adapters/http.d.ts +52 -0
  25. package/adapters/http.js +202 -0
  26. package/adapters/http.js.map +1 -0
  27. package/angular/adapter-angular-httpclient.d.ts +21 -0
  28. package/angular/adapter-angular-httpclient.js +70 -0
  29. package/angular/adapter-angular-httpclient.js.map +1 -0
  30. package/breeze.d.ts +215 -0
  31. package/breeze.js +141 -0
  32. package/breeze.js.map +1 -0
  33. package/config/config.d.ts +212 -0
  34. package/config/config.js +392 -0
  35. package/config/config.js.map +1 -0
  36. package/config/configure.d.ts +66 -0
  37. package/config/configure.js +46 -0
  38. package/config/configure.js.map +1 -0
  39. package/config/default-adapters.d.ts +1 -0
  40. package/config/default-adapters.js +40 -0
  41. package/config/default-adapters.js.map +1 -0
  42. package/config/interface-registry.d.ts +191 -0
  43. package/config/interface-registry.js +5 -0
  44. package/config/interface-registry.js.map +1 -0
  45. package/{src → core}/assert-param.d.ts +52 -60
  46. package/core/assert-param.js +390 -0
  47. package/core/assert-param.js.map +1 -0
  48. package/core/core.d.ts +285 -0
  49. package/core/core.js +772 -0
  50. package/core/core.js.map +1 -0
  51. package/core/enum.d.ts +116 -0
  52. package/core/enum.js +167 -0
  53. package/core/enum.js.map +1 -0
  54. package/core/event.d.ts +169 -0
  55. package/core/event.js +338 -0
  56. package/core/event.js.map +1 -0
  57. package/entity/array.d.ts +3 -0
  58. package/entity/array.js +4 -0
  59. package/entity/array.js.map +1 -0
  60. package/entity/complex-array.d.ts +17 -0
  61. package/entity/complex-array.js +104 -0
  62. package/entity/complex-array.js.map +1 -0
  63. package/entity/default-property-interceptor.d.ts +1 -0
  64. package/entity/default-property-interceptor.js +496 -0
  65. package/entity/default-property-interceptor.js.map +1 -0
  66. package/{src → entity}/entity-action.d.ts +36 -42
  67. package/entity/entity-action.js +45 -0
  68. package/entity/entity-action.js.map +1 -0
  69. package/entity/entity-aspect.d.ts +457 -0
  70. package/entity/entity-aspect.js +1262 -0
  71. package/entity/entity-aspect.js.map +1 -0
  72. package/entity/entity-base.d.ts +55 -0
  73. package/entity/entity-base.js +41 -0
  74. package/entity/entity-base.js.map +1 -0
  75. package/entity/entity-group.d.ts +1 -0
  76. package/entity/entity-group.js +224 -0
  77. package/entity/entity-group.js.map +1 -0
  78. package/entity/entity-key.d.ts +95 -0
  79. package/entity/entity-key.js +189 -0
  80. package/entity/entity-key.js.map +1 -0
  81. package/{src → entity}/entity-state.d.ts +112 -84
  82. package/entity/entity-state.js +135 -0
  83. package/entity/entity-state.js.map +1 -0
  84. package/entity/key-generator.d.ts +57 -0
  85. package/entity/key-generator.js +155 -0
  86. package/entity/key-generator.js.map +1 -0
  87. package/entity/observable-array.d.ts +25 -0
  88. package/entity/observable-array.js +230 -0
  89. package/entity/observable-array.js.map +1 -0
  90. package/entity/primitive-array.d.ts +12 -0
  91. package/entity/primitive-array.js +71 -0
  92. package/entity/primitive-array.js.map +1 -0
  93. package/entity/relation-array.d.ts +24 -0
  94. package/entity/relation-array.js +176 -0
  95. package/entity/relation-array.js.map +1 -0
  96. package/entity/unattached-children-map.d.ts +1 -0
  97. package/entity/unattached-children-map.js +105 -0
  98. package/entity/unattached-children-map.js.map +1 -0
  99. package/generate-entity-classes.js +1176 -0
  100. package/manager/entity-manager.d.ts +801 -0
  101. package/manager/entity-manager.js +2395 -0
  102. package/manager/entity-manager.js.map +1 -0
  103. package/{src → manager}/save-options.d.ts +48 -42
  104. package/manager/save-options.js +51 -0
  105. package/manager/save-options.js.map +1 -0
  106. package/{src → metadata}/data-service.d.ts +229 -184
  107. package/metadata/data-service.js +246 -0
  108. package/metadata/data-service.js.map +1 -0
  109. package/metadata/data-type.d.ts +122 -0
  110. package/metadata/data-type.js +465 -0
  111. package/metadata/data-type.js.map +1 -0
  112. package/metadata/entity-metadata.d.ts +1193 -0
  113. package/metadata/entity-metadata.js +2502 -0
  114. package/metadata/entity-metadata.js.map +1 -0
  115. package/{src → metadata}/local-query-comparison-options.d.ts +65 -59
  116. package/metadata/local-query-comparison-options.js +69 -0
  117. package/metadata/local-query-comparison-options.js.map +1 -0
  118. package/{src → metadata}/naming-convention.d.ts +75 -72
  119. package/metadata/naming-convention.js +97 -0
  120. package/metadata/naming-convention.js.map +1 -0
  121. package/mixins/mixin-get-entity-graph.d.ts +63 -0
  122. package/{fesm2022/breeze-client-mixin-get-entity-graph.mjs → mixins/mixin-get-entity-graph.js} +331 -253
  123. package/mixins/mixin-get-entity-graph.js.map +1 -0
  124. package/mixins/mixin-save-queuing.d.ts +98 -0
  125. package/{fesm2022/breeze-client-mixin-save-queuing.mjs → mixins/mixin-save-queuing.js} +493 -365
  126. package/mixins/mixin-save-queuing.js.map +1 -0
  127. package/package.json +62 -93
  128. package/query/entity-query.d.ts +521 -0
  129. package/query/entity-query.js +1149 -0
  130. package/query/entity-query.js.map +1 -0
  131. package/{src → query}/mapping-context.d.ts +44 -46
  132. package/query/mapping-context.js +412 -0
  133. package/query/mapping-context.js.map +1 -0
  134. package/query/predicate.d.ts +394 -0
  135. package/query/predicate.js +1294 -0
  136. package/query/predicate.js.map +1 -0
  137. package/query/property-path.d.ts +252 -0
  138. package/query/property-path.js +2 -0
  139. package/query/property-path.js.map +1 -0
  140. package/{src → query}/query-options.d.ts +143 -119
  141. package/query/query-options.js +180 -0
  142. package/query/query-options.js.map +1 -0
  143. package/rxjs/breeze-rxjs.d.ts +72 -0
  144. package/rxjs/breeze-rxjs.js +117 -0
  145. package/rxjs/breeze-rxjs.js.map +1 -0
  146. package/validation/validate.d.ts +583 -0
  147. package/validation/validate.js +961 -0
  148. package/validation/validate.js.map +1 -0
  149. package/{src → validation}/validation-options.d.ts +67 -63
  150. package/validation/validation-options.js +70 -0
  151. package/validation/validation-options.js.map +1 -0
  152. package/adapter-ajax-angularjs/adapter-ajax-angularjs.d.ts +0 -17
  153. package/adapter-ajax-angularjs/adapter-core.d.ts +0 -4
  154. package/adapter-ajax-angularjs/index.d.ts +0 -5
  155. package/adapter-ajax-fetch/adapter-ajax-fetch.d.ts +0 -18
  156. package/adapter-ajax-fetch/index.d.ts +0 -5
  157. package/adapter-ajax-httpclient/adapter-ajax-httpclient.d.ts +0 -13
  158. package/adapter-ajax-httpclient/adapter-core.d.ts +0 -4
  159. package/adapter-ajax-httpclient/index.d.ts +0 -5
  160. package/adapter-ajax-jquery/adapter-ajax-jquery.d.ts +0 -15
  161. package/adapter-ajax-jquery/index.d.ts +0 -5
  162. package/adapter-ajax-post/index.d.ts +0 -5
  163. package/adapter-data-service-odata/adapter-core.d.ts +0 -4
  164. package/adapter-data-service-odata/adapter-data-service-odata.d.ts +0 -17
  165. package/adapter-data-service-odata/index.d.ts +0 -5
  166. package/adapter-data-service-webapi/adapter-data-service-webapi.d.ts +0 -15
  167. package/adapter-data-service-webapi/index.d.ts +0 -5
  168. package/adapter-model-library-backing-store/adapter-model-library-backing-store.d.ts +0 -10
  169. package/adapter-model-library-backing-store/index.d.ts +0 -5
  170. package/adapter-model-library-ko/adapter-model-library-ko.d.ts +0 -10
  171. package/adapter-model-library-ko/index.d.ts +0 -5
  172. package/adapter-uri-builder-json/adapter-core.d.ts +0 -4
  173. package/adapter-uri-builder-json/adapter-uri-builder-json.d.ts +0 -8
  174. package/adapter-uri-builder-json/index.d.ts +0 -5
  175. package/adapter-uri-builder-odata/adapter-core.d.ts +0 -4
  176. package/adapter-uri-builder-odata/adapter-uri-builder-odata.d.ts +0 -8
  177. package/adapter-uri-builder-odata/index.d.ts +0 -5
  178. package/esm2022/adapter-ajax-angularjs/adapter-ajax-angularjs.mjs +0 -135
  179. package/esm2022/adapter-ajax-angularjs/adapter-core.mjs +0 -49
  180. package/esm2022/adapter-ajax-angularjs/breeze-client-adapter-ajax-angularjs.mjs +0 -5
  181. package/esm2022/adapter-ajax-fetch/adapter-ajax-fetch.mjs +0 -135
  182. package/esm2022/adapter-ajax-fetch/adapter-core.mjs +0 -49
  183. package/esm2022/adapter-ajax-fetch/breeze-client-adapter-ajax-fetch.mjs +0 -5
  184. package/esm2022/adapter-ajax-httpclient/adapter-ajax-httpclient.mjs +0 -139
  185. package/esm2022/adapter-ajax-httpclient/adapter-core.mjs +0 -49
  186. package/esm2022/adapter-ajax-httpclient/breeze-client-adapter-ajax-httpclient.mjs +0 -5
  187. package/esm2022/adapter-ajax-jquery/adapter-ajax-jquery.mjs +0 -107
  188. package/esm2022/adapter-ajax-jquery/breeze-client-adapter-ajax-jquery.mjs +0 -5
  189. package/esm2022/adapter-ajax-post/adapter-ajax-post.mjs +0 -77
  190. package/esm2022/adapter-ajax-post/breeze-client-adapter-ajax-post.mjs +0 -5
  191. package/esm2022/adapter-data-service-odata/adapter-core.mjs +0 -49
  192. package/esm2022/adapter-data-service-odata/adapter-data-service-odata.mjs +0 -461
  193. package/esm2022/adapter-data-service-odata/breeze-client-adapter-data-service-odata.mjs +0 -5
  194. package/esm2022/adapter-data-service-webapi/adapter-data-service-webapi.mjs +0 -100
  195. package/esm2022/adapter-data-service-webapi/breeze-client-adapter-data-service-webapi.mjs +0 -5
  196. package/esm2022/adapter-model-library-backing-store/adapter-model-library-backing-store.mjs +0 -269
  197. package/esm2022/adapter-model-library-backing-store/breeze-client-adapter-model-library-backing-store.mjs +0 -5
  198. package/esm2022/adapter-model-library-ko/adapter-model-library-ko.mjs +0 -241
  199. package/esm2022/adapter-model-library-ko/breeze-client-adapter-model-library-ko.mjs +0 -5
  200. package/esm2022/adapter-uri-builder-json/adapter-core.mjs +0 -49
  201. package/esm2022/adapter-uri-builder-json/adapter-uri-builder-json.mjs +0 -37
  202. package/esm2022/adapter-uri-builder-json/breeze-client-adapter-uri-builder-json.mjs +0 -5
  203. package/esm2022/adapter-uri-builder-odata/adapter-core.mjs +0 -49
  204. package/esm2022/adapter-uri-builder-odata/adapter-uri-builder-odata.mjs +0 -191
  205. package/esm2022/adapter-uri-builder-odata/breeze-client-adapter-uri-builder-odata.mjs +0 -5
  206. package/esm2022/breeze-client.mjs +0 -5
  207. package/esm2022/index.mjs +0 -2
  208. package/esm2022/mixin-get-entity-graph/breeze-client-mixin-get-entity-graph.mjs +0 -5
  209. package/esm2022/mixin-get-entity-graph/mixin-get-entity-graph.mjs +0 -269
  210. package/esm2022/mixin-save-queuing/breeze-client-mixin-save-queuing.mjs +0 -5
  211. package/esm2022/mixin-save-queuing/mixin-save-queuing.mjs +0 -421
  212. package/esm2022/src/abstract-data-service-adapter.mjs +0 -325
  213. package/esm2022/src/array.mjs +0 -4
  214. package/esm2022/src/assert-param.mjs +0 -330
  215. package/esm2022/src/breeze.mjs +0 -85
  216. package/esm2022/src/complex-array.mjs +0 -117
  217. package/esm2022/src/config.mjs +0 -232
  218. package/esm2022/src/core.mjs +0 -712
  219. package/esm2022/src/csdl-metadata-parser.mjs +0 -385
  220. package/esm2022/src/data-service.mjs +0 -221
  221. package/esm2022/src/data-type.mjs +0 -510
  222. package/esm2022/src/default-property-interceptor.mjs +0 -460
  223. package/esm2022/src/entity-action.mjs +0 -45
  224. package/esm2022/src/entity-aspect.mjs +0 -897
  225. package/esm2022/src/entity-group.mjs +0 -192
  226. package/esm2022/src/entity-key.mjs +0 -125
  227. package/esm2022/src/entity-manager.mjs +0 -2163
  228. package/esm2022/src/entity-metadata.mjs +0 -2242
  229. package/esm2022/src/entity-query.mjs +0 -1024
  230. package/esm2022/src/entity-state.mjs +0 -107
  231. package/esm2022/src/enum.mjs +0 -143
  232. package/esm2022/src/event.mjs +0 -264
  233. package/esm2022/src/interface-registry.mjs +0 -39
  234. package/esm2022/src/key-generator.mjs +0 -110
  235. package/esm2022/src/local-query-comparison-options.mjs +0 -65
  236. package/esm2022/src/mapping-context.mjs +0 -411
  237. package/esm2022/src/naming-convention.mjs +0 -92
  238. package/esm2022/src/observable-array.mjs +0 -183
  239. package/esm2022/src/predicate.mjs +0 -1259
  240. package/esm2022/src/primitive-array.mjs +0 -85
  241. package/esm2022/src/query-options.mjs +0 -152
  242. package/esm2022/src/relation-array.mjs +0 -173
  243. package/esm2022/src/save-options.mjs +0 -41
  244. package/esm2022/src/unattached-children-map.mjs +0 -56
  245. package/esm2022/src/validate.mjs +0 -995
  246. package/esm2022/src/validation-options.mjs +0 -64
  247. package/fesm2022/breeze-client-adapter-ajax-angularjs.mjs +0 -190
  248. package/fesm2022/breeze-client-adapter-ajax-angularjs.mjs.map +0 -1
  249. package/fesm2022/breeze-client-adapter-ajax-fetch.mjs +0 -190
  250. package/fesm2022/breeze-client-adapter-ajax-fetch.mjs.map +0 -1
  251. package/fesm2022/breeze-client-adapter-ajax-httpclient.mjs +0 -194
  252. package/fesm2022/breeze-client-adapter-ajax-httpclient.mjs.map +0 -1
  253. package/fesm2022/breeze-client-adapter-ajax-jquery.mjs +0 -114
  254. package/fesm2022/breeze-client-adapter-ajax-jquery.mjs.map +0 -1
  255. package/fesm2022/breeze-client-adapter-ajax-post.mjs.map +0 -1
  256. package/fesm2022/breeze-client-adapter-data-service-odata.mjs +0 -516
  257. package/fesm2022/breeze-client-adapter-data-service-odata.mjs.map +0 -1
  258. package/fesm2022/breeze-client-adapter-data-service-webapi.mjs.map +0 -1
  259. package/fesm2022/breeze-client-adapter-model-library-backing-store.mjs +0 -276
  260. package/fesm2022/breeze-client-adapter-model-library-backing-store.mjs.map +0 -1
  261. package/fesm2022/breeze-client-adapter-model-library-ko.mjs +0 -248
  262. package/fesm2022/breeze-client-adapter-model-library-ko.mjs.map +0 -1
  263. package/fesm2022/breeze-client-adapter-uri-builder-json.mjs.map +0 -1
  264. package/fesm2022/breeze-client-adapter-uri-builder-odata.mjs +0 -246
  265. package/fesm2022/breeze-client-adapter-uri-builder-odata.mjs.map +0 -1
  266. package/fesm2022/breeze-client-mixin-get-entity-graph.mjs.map +0 -1
  267. package/fesm2022/breeze-client-mixin-save-queuing.mjs.map +0 -1
  268. package/fesm2022/breeze-client.mjs +0 -14144
  269. package/fesm2022/breeze-client.mjs.map +0 -1
  270. package/index.d.ts +0 -1
  271. package/mixin-get-entity-graph/index.d.ts +0 -5
  272. package/mixin-get-entity-graph/mixin-get-entity-graph.d.ts +0 -31
  273. package/mixin-save-queuing/index.d.ts +0 -5
  274. package/mixin-save-queuing/mixin-save-queuing.d.ts +0 -32
  275. package/src/abstract-data-service-adapter.d.ts +0 -84
  276. package/src/array.d.ts +0 -3
  277. package/src/breeze.d.ts +0 -139
  278. package/src/complex-array.d.ts +0 -13
  279. package/src/config.d.ts +0 -104
  280. package/src/core.d.ts +0 -164
  281. package/src/csdl-metadata-parser.d.ts +0 -7
  282. package/src/data-type.d.ts +0 -89
  283. package/src/default-property-interceptor.d.ts +0 -4
  284. package/src/entity-aspect.d.ts +0 -332
  285. package/src/entity-group.d.ts +0 -28
  286. package/src/entity-key.d.ts +0 -77
  287. package/src/entity-manager.d.ts +0 -680
  288. package/src/entity-metadata.d.ts +0 -988
  289. package/src/entity-query.d.ts +0 -444
  290. package/src/enum.d.ts +0 -100
  291. package/src/event.d.ts +0 -142
  292. package/src/interface-registry.d.ts +0 -150
  293. package/src/key-generator.d.ts +0 -12
  294. package/src/observable-array.d.ts +0 -52
  295. package/src/predicate.d.ts +0 -376
  296. package/src/primitive-array.d.ts +0 -7
  297. package/src/relation-array.d.ts +0 -18
  298. package/src/unattached-children-map.d.ts +0 -19
  299. package/src/validate.d.ts +0 -650
@@ -1,119 +1,143 @@
1
- import { BreezeEnum } from './enum';
2
- /**
3
- MergeStrategy is an 'Enum' that determines how entities are merged into an EntityManager.
4
-
5
- @class MergeStrategy
6
- @static
7
- **/
8
- export declare 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 [[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: 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 [[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: 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: 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: MergeStrategy;
34
- }
35
- /**
36
- FetchStrategy is an 'Enum' that determines how and where entities are retrieved from as a result of a query.
37
- **/
38
- export declare class FetchStrategy extends BreezeEnum {
39
- /**
40
- FromServer is used to tell the query to execute the query against a remote data source on the server.
41
- **/
42
- static FromServer: FetchStrategy;
43
- /**
44
- FromLocalCache is used to tell the query to execute the query against a local EntityManager instead of going to a remote server.
45
- **/
46
- static FromLocalCache: FetchStrategy;
47
- }
48
- /** Configuration info to be passed to the [[QueryOptions]] constructor. */
49
- export interface QueryOptionsConfig {
50
- /** The [[FetchStrategy]] to use with any queries.*/
51
- fetchStrategy?: FetchStrategy;
52
- /** The [[MergeStrategy]] to use with any queries.*/
53
- mergeStrategy?: MergeStrategy;
54
- /** Whether to include cached deleted entities in a query result (false by default). __Read Only__ */
55
- includeDeleted?: boolean;
56
- }
57
- /**
58
- A QueryOptions instance is used to specify the 'options' under which a query will occur.
59
- **/
60
- export declare class QueryOptions {
61
- /** @hidden @internal */
62
- _$typeName: string;
63
- /** The [[FetchStrategy]] to use with any queries. __Read Only__ */
64
- fetchStrategy: FetchStrategy;
65
- /** The [[MergeStrategy]] to use with any queries. __Read Only__ */
66
- mergeStrategy: MergeStrategy;
67
- /** Whether to include cached deleted entities in a query result (false by default). __Read Only__ */
68
- includeDeleted: boolean;
69
- /**
70
- The default instance for use whenever QueryOptions are not specified.
71
- **/
72
- static defaultInstance: QueryOptions;
73
- /**
74
- QueryOptions constructor
75
- > var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });
76
- > // assume em1 is a preexisting EntityManager
77
- > em1.setProperties( { queryOptions: newQo });
78
- Any QueryOptions property that is not defined will be defaulted from any QueryOptions defined at a higher level in the breeze hierarchy, i.e.
79
- - from query.queryOptions
80
- - to entityManager.queryOptions
81
- - to QueryOptions.defaultInstance;
82
-
83
- @param config - A configuration object.
84
- **/
85
- constructor(config?: QueryOptionsConfig);
86
- static resolve(queryOptionsArray: any[]): QueryOptions;
87
- /**
88
- Returns a copy of this QueryOptions with the specified [[MergeStrategy]],
89
- [[FetchStrategy]], or 'includeDeleted' option applied.
90
- > // Given an EntityManager instance, em
91
- > var queryOptions = em.queryOptions.using(MergeStrategy.PreserveChanges);
92
-
93
- or
94
- > var queryOptions = em.queryOptions.using(FetchStrategy.FromLocalCache);
95
-
96
- or
97
- > var queryOptions = em.queryOptions.using({ mergeStrategy: MergeStrategy.OverwriteChanges });
98
-
99
- or
100
- > var queryOptions = em.queryOptions.using({
101
- > includeDeleted: true,
102
- > fetchStrategy: FetchStrategy.FromLocalCache
103
- > });
104
- @param config - A configuration object or a standalone [[MergeStrategy]] or [[FetchStrategy]]
105
- @return A new QueryOptions instance.
106
- **/
107
- using(qoConfig: QueryOptionsConfig | MergeStrategy | FetchStrategy): QueryOptions;
108
- /**
109
- Sets the 'defaultInstance' by creating a copy of the current 'defaultInstance' and then applying all of the properties of the current instance.
110
- The current instance is returned unchanged.
111
- > var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });
112
- > newQo.setAsDefault();
113
- **/
114
- setAsDefault(): any;
115
- toJSON(): Object;
116
- static fromJSON(json: any): QueryOptions;
117
- /** @hidden @internal */
118
- private static _updateWithConfig;
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>;