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