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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-aspect.js","sourceRoot":"","sources":["../../src/entity/entity-aspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAG,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAiE,MAAM,gCAAgC,CAAC;AAC3H,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAiFpD;;;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AC;YAC7D,YAAY,GAAG,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC;QAC/C,CAAC;QACD,OAAO,YAAY,IAAI,IAAI,YAAY,EAAE,CAAC;IAC5C,CAAC;IAED,yBAAyB;IACzB,mGAAmG;IACnG,eAAe,CAAC,QAAgB;QAC9B,IAAI,MAAM,GAAQ,IAAI,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,IAAI,MAAM,GAAG,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,YAAY,CAAC;QACzD,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,cAAe,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC,CAAC;IAC5E,CAAC;CAEF;AAED,SAAS,mBAAmB,CAAC,MAAW;IACtC,IAAI,MAAM,GAAG,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,aAAa,CAAC;IACzD,MAAM,CAAC,cAAc,GAAG,EAAE,CAAC;IAC3B,IAAI,KAAK,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,WAAW,CAAC;IACpD,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,UAAU,EAAO;QAC/C,IAAI,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC;YAChB,mBAAmB,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,eAAe,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YACnC,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { core } from '../core/core.js';\nimport { config } from '../config/config.js';\nimport { BreezeEvent } from '../core/event.js';\nimport { assertParam, paramError } from '../core/assert-param.js';\nimport { EntityState } from './entity-state.js';\nimport { EntityAction } from './entity-action.js';\nimport { EntityType, ComplexType, DataProperty, NavigationProperty, EntityProperty } from '../metadata/entity-metadata.js';\nimport { observableArray } from './observable-array.js';\nimport { EntityKey } from './entity-key.js';\nimport { EntityGroup } from './entity-group.js';\nimport { EntityManager, QueryResult, QueryErrorCallback, QuerySuccessCallback, ValidationErrorsChangedEventArgs } from '../manager/entity-manager.js';\nimport { Validator, ValidationError } from '../validation/validate.js';\nimport { EntityQuery } from '../query/entity-query.js';\nimport type { DataKeys, OriginalValues } from '../query/property-path.js';\nimport { DataType } from '../metadata/data-type.js';\n\n/** An instance of an {@link EntityType}: an object with a key, tracked by an {@link EntityManager}\nonce attached. Breeze gives every entity these members, whether its class declares them or not. */\nexport interface Entity {\n /** The {@link EntityAspect} that holds this entity's Breeze state: its {@link EntityState}, key,\n original values, validation errors and manager. */\n entityAspect: EntityAspect;\n /** The {@link EntityType} that describes this entity. */\n entityType: EntityType;\n /** Get the property with the given name */\n getProperty(prop: string): any;\n /** Set the property with the given name, exactly as assigning it would.\n\n With the backing-store model library it returns the object itself, so calls can be chained.\n The return type is `any` rather than `this` so that a class declaring `setProperty` as returning\n `void` still implements this interface.\n\n A name that is not a property of the type is not an error: like an assignment, it creates an\n ordinary property, which Breeze does not track. */\n setProperty(prop: any, value: any): any;\n /** @hidden @internal */\n prototype?: { _$typeName: string };\n /** @hidden @internal */\n _$entityType?: EntityType;\n}\n\n/** An instance of a {@link ComplexType}: a value with no key of its own, held in a complex property\nof an entity or of another complex object. */\nexport interface ComplexObject {\n /** The {@link ComplexAspect} that holds this object's parent, parent property and original values. */\n complexAspect: ComplexAspect;\n /** The {@link ComplexType} that describes this object. */\n complexType: ComplexType;\n /** Get the property with the given name */\n getProperty(prop: string): any;\n /** Set the property with the given name, exactly as assigning it would. Returns the object\n itself with the backing-store model library - see {@link Entity.setProperty}. */\n setProperty(prop: any, value: any): any;\n /** @hidden @internal */\n prototype?: { _$typeName: string };\n}\n\n/** An entity or a complex object - either kind of object Breeze tracks the properties of. Used where\neither is accepted, such as {@link ComplexAspect.parent}. */\nexport type StructuralObject = Entity | ComplexObject;\n\n/**\n * The type of the results of a query built from entities you already have, such as\n * {@link EntityQuery.fromEntities} or {@link RelationArray.load}: the entities' own class when it\n * is known - `QueriedAs<Customer>` is `Customer` - and `any` when all that is known is\n * {@link Entity}, so that `results[0].companyName` compiles without a cast.\n */\n// `any` rather than `Entity` for the plain case: that is what these results were before the type\n// parameters existed, and narrowing it would break every existing caller.\nexport type QueriedAs<U> = Entity extends U ? any : U;\n\n/** The argument to an entity's {@link EntityAspect.propertyChanged} event. It is also the `args` of\nan {@link EntityChangedEventArgs} for {@link EntityAction.PropertyChange}. */\nexport interface PropertyChangedEventArgs {\n /** The entity that changed. For a property of a complex object, the entity that holds it. */\n entity: Entity;\n /** The name of the property that changed. For a property of a complex object it is a path from\n the entity, such as `\"location.city\"`, with no index for an element of a complex array.\n\n `null` when any number of properties may have changed at once - when a query or save merges\n values into the entity, or its changes are rejected. The other members are then not set. */\n propertyName: string | null;\n /** The object whose property was set: the entity itself, or the complex object that owns the\n property. */\n parent?: StructuralObject;\n /** The {@link DataProperty} or {@link NavigationProperty} that changed. It belongs to the type of\n `parent`, which is not the entity's type when `parent` is a complex object. */\n property?: EntityProperty;\n /** The value before the change. */\n oldValue?: any;\n /** The value after the change, converted to the property's data type where Breeze can. */\n newValue?: any;\n}\n\n\n/**\nAn EntityAspect instance is associated with every attached entity and is accessed via the entity's 'entityAspect' property.\n\nThe EntityAspect itself provides properties to determine and modify the EntityState of the entity and has methods\nthat provide a variety of services including validation and change tracking.\n\nAn EntityAspect will almost never need to be constructed directly. You will usually get an EntityAspect by accessing\nan entities 'entityAspect' property. This property will be automatically attached when an entity is created via either\na query, import or {@link EntityManager.createEntity} call.\n```ts\n// assume order is an order entity attached to an EntityManager.\nvar aspect = order.entityAspect;\nvar currentState = aspect.entityState;\n```\n\n*/\nexport class EntityAspect {\n /** The Entity that this aspect is associated with. __Read Only__ */\n entity?: Entity;\n /** The {@link EntityManager} that contains this entity. __Read Only__ */\n entityManager?: EntityManager;\n /** @hidden @internal */\n entityGroup?: EntityGroup;\n /** @hidden @internal */\n _entityState!: EntityState;\n // An accessor rather than a plain field because the entity's group keeps the set of its\n // entities that are not Unchanged, and this is the one place every state change passes through\n // - setEntityState, _detach, the attach and merge paths, and anything an application or plugin\n // assigns. Working the set out by scanning instead is what made hasChanges cost the size of the\n // cache, once per state change. See \"Cache lookups that were scans\" in CHANGES-DEV.md.\n /** The {@link EntityState} of this entity. __Read Only__ */\n get entityState(): EntityState {\n return this._entityState;\n }\n set entityState(entityState: EntityState) {\n this._entityState = entityState;\n const group = this.entityGroup;\n if (group === undefined) return; // detached: nothing is tracking it\n if (entityState === EntityState.Unchanged || entityState === EntityState.Detached) {\n group._changedEntities.delete(this.entity!);\n } else {\n group._changedEntities.add(this.entity!);\n }\n }\n /** Whether this entity is in the process of being saved. __Read Only__ */\n isBeingSaved: boolean;\n /** The 'original values' of this entity where they are different from the 'current values'.\n This is a map where the key is a property name and the value is the 'original value' of the property. */\n originalValues: Record<string, any>;\n /** Whether this entity has any validation errors. __Read Only__ */\n hasValidationErrors: boolean;\n /** Whether this entity has a temporary {@link EntityKey}. */\n hasTempKey?: boolean;\n /** Whether this entity was created by being loaded from the database */\n wasLoaded?: boolean;\n /** Extra metadata about this entity such as the entity's etag.\n You may extend this object with your own metadata information.\n Breeze (de)serializes this object when importing/exporting the entity. */\n extraMetadata?: any;\n /**\n A {@link BreezeEvent} that fires whenever any of the validation errors on this entity change.\n Note that this might be the removal of an error when some data on the entity is fixed.\n @eventArgs - \n - entity - The entity on which the validation errors are being added or removed.\n - added - An array containing any newly added {@link ValidationError}s\n - removed - An array containing any newly removed {@link ValidationError}s. This is those\n errors that have been 'fixed'.\n\n```ts\n// assume order is an order entity attached to an EntityManager.\norder.entityAspect.validationErrorsChanged.subscribe(\nfunction (validationChangeArgs) {\n // this code will be executed anytime a property value changes on the 'order' entity.\n var entity == validationChangeArgs.entity; // Note: entity === order\n var errorsAdded = validationChangeArgs.added;\n var errorsCleared = validationChangeArgs.removed;\n});\n```\n @event\n */\n validationErrorsChanged: BreezeEvent<ValidationErrorsChangedEventArgs>;\n /**\n A {@link BreezeEvent} that fires whenever a value of one of this entity's properties change.\n @eventArgs -\n - entity - The entity whose property has changed.\n - property - The {@link DataProperty} that changed.\n - propertyName - The name of the property that changed. This value will be 'null' for operations that replace the entire entity. This includes\n 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\"\n for any properties of a complex type.\n - oldValue - The old value of this property before the change.\n - newValue - The new value of this property after the change.\n - parent - The immediate parent object for the changed property. This will be a ComplexType instance as opposed to an Entity \n for any complex type or nested complex type properties.\n\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.propertyChanged.subscribe(\n function (propertyChangedArgs) {\n // this code will be executed anytime a property value changes on the 'order' entity.\n var entity = propertyChangedArgs.entity; // Note: entity === order\n var propertyNameChanged = propertyChangedArgs.propertyName;\n var oldValue = propertyChangedArgs.oldValue;\n var newValue = propertyChangedArgs.newValue;\n });\n ```\n @event\n */\n propertyChanged: BreezeEvent<PropertyChangedEventArgs>;\n\n /** @hidden @internal */\n _validationErrors: { [index: string]: ValidationError };\n /** @hidden @internal */\n _pendingValidationResult: any;\n /**\n The async validator runs in flight, by the key of the error each would add or remove: one run\n per check, so that a newer run replaces an older one rather than racing it. Created on first use.\n @hidden @internal\n */\n declare _asyncChecks?: Map<string, AsyncCheckRun>;\n\n /** Whether an async validator is still running for this entity - see\n {@link EntityAspect.validateEntityAsync}. __Read Only__ */\n get isValidating(): boolean {\n return !!this._asyncChecks && this._asyncChecks.size > 0;\n }\n /** @hidden @internal */\n _entityKey: EntityKey;\n /** @hidden @internal */\n _loadedNps: any[];\n /** @hidden @internal */\n _initialized?: boolean;\n /** @hidden @internal */\n _inProcess: any[]; // used in defaultPropertyInterceptor for temp storage.\n /** @hidden @internal */\n _inProcessEntity?: Entity; // used in EntityManager\n /** @hidden @internal */\n constructor(entity?: Entity) {\n\n // if called without new\n // if (!(this instanceof EntityAspect)) {\n // return new EntityAspect(entity);\n // }\n\n this.entity = entity;\n // TODO: keep public or not?\n this.entityGroup = undefined;\n this.entityManager = undefined;\n this.entityState = EntityState.Detached;\n this.isBeingSaved = false;\n this.originalValues = {};\n this.hasValidationErrors = false;\n this._validationErrors = {};\n\n // Uncomment when we implement entityAspect.isNavigationPropertyLoaded method\n // this._loadedNavPropMap = {};\n\n this.validationErrorsChanged = new BreezeEvent(\"validationErrorsChanged\", this);\n this.propertyChanged = new BreezeEvent(\"propertyChanged\", this);\n // in case this is the NULL entityAspect. - used with ComplexAspects that have no parent.\n\n if (entity != null) {\n // remove properties that should be on prototype but placed on instance by Babel\n if (entity.hasOwnProperty('entityType')) {\n // throw new Error(\"Entity instance has entityType property; should only be on prototype\");\n delete (entity as any).entityType;\n }\n entity.entityAspect = this;\n\n // entityType should already be on the entity from 'watch'\n let entityType = entity.entityType || entity._$entityType;\n if (!entityType) {\n let typeName = entity.prototype!._$typeName;\n if (!typeName) {\n throw new Error(\"This entity is not registered as a valid EntityType\");\n } else {\n throw new Error(\"Metadata for this entityType has not yet been resolved: \" + typeName);\n }\n }\n let entityCtor = entityType.getCtor();\n config.interfaceRegistry.modelLibrary.getDefaultInstance().startTracking(entity, entityCtor.prototype);\n }\n }\n\n /** @hidden */\n // type-guard\n static isEntity(obj: StructuralObject): obj is Entity {\n return (obj as any).entityAspect != null;\n }\n\n // TODO: refactor this and the instance getPropertyValue method.\n /**\n Returns the value of a specified 'property path' for a specified entity.\n\n The propertyPath can be either a string delimited with '.' or a string array. \n */\n // used by EntityQuery and Predicate\n static getPropertyPathValue(obj: Entity, propertyPath: string | string[]) {\n let properties = Array.isArray(propertyPath) ? propertyPath : propertyPath.split(\".\");\n if (properties.length === 1) {\n // properties[0], not propertyPath. Given a single-element array this used to pass the array\n // itself to getProperty, and reached the right property only because a property lookup\n // coerces ['freight'] to 'freight'. Correct by accident, and slower than the real thing.\n return obj.getProperty(properties[0]);\n } else {\n let nextValue = obj;\n // hack use of some to perform mapFirst operation.\n properties.some((prop) => {\n nextValue = nextValue.getProperty(prop);\n return nextValue == null;\n });\n return nextValue;\n }\n }\n\n /**\n Returns the {@link EntityKey} for this Entity.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var entityKey = order.entityAspect.getKey();\n ```\n @param forceRefresh - (boolean=false) Forces the recalculation of the key. This should normally be unnecessary.\n @returns The {@link EntityKey} associated with this Entity.\n */\n getKey(forceRefresh: boolean = false) {\n // Inline, not assertParam: getKey runs several times per entity created and again on\n // every attach, merge and foreign key lookup. Same wording.\n if (forceRefresh != null && typeof forceRefresh !== 'boolean') {\n throw paramError('forceRefresh', \"is optional or it must be a 'boolean'\");\n }\n if (forceRefresh || !this._entityKey) {\n let entityType = this.entity!.entityType;\n let keyProps = entityType.keyProperties;\n let values = keyProps.map(function (p) {\n return this.entity.getProperty(p.name);\n }, this);\n this._entityKey = new EntityKey(entityType, values);\n }\n return this._entityKey;\n }\n\n /**\n Returns the entity to an {@link EntityState} of 'Unchanged' by committing all changes made since the entity was last queried\n had 'acceptChanges' called on it.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.acceptChanges();\n // The 'order' entity will now be in an 'Unchanged' state with any changes committed.\n ```\n */\n acceptChanges() {\n if (!this.entity) return;\n this._checkOperation(\"acceptChanges\");\n let em = this.entityManager!;\n if (this.entityState.isDeleted()) {\n em.detachEntity(this.entity);\n } else {\n this.setUnchanged();\n }\n em.entityChanged.publish({ entityAction: EntityAction.AcceptChanges, entity: this.entity });\n }\n\n /**\n Returns the entity to an {@link EntityState} of 'Unchanged' by rejecting all changes made to it since the entity was last queried\n had 'rejectChanges' called on it.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.rejectChanges();\n // The 'order' entity will now be in an 'Unchanged' state with any changes rejected.\n ```\n */\n rejectChanges() {\n this._checkOperation(\"rejectChanges\");\n let entity = this.entity!;\n let entityManager = this.entityManager!;\n // we do not want PropertyChange or EntityChange events to occur here\n core.using(entityManager, \"isRejectingChanges\", true, function () {\n rejectChangesCore(entity);\n });\n if (this.entityState.isAdded()) {\n // next line is needed because the following line will cause this.entityManager -> null;\n entityManager.detachEntity(entity);\n // need to tell em that an entity that needed to be saved no longer does.\n entityManager._notifyStateChange(entity, false);\n } else {\n if (this.entityState.isDeleted()) {\n entityManager._linkRelatedEntities(entity);\n }\n this.setUnchanged();\n // propertyChanged propertyName is not specified because more than one property may have changed.\n this.propertyChanged.publish({ entity: entity, propertyName: null });\n entityManager.entityChanged.publish({ entityAction: EntityAction.RejectChanges, entity: entity });\n }\n }\n\n /** @hidden @internal */\n // TODO: rename - and use '_'; used on both EntityAspect and ComplexAspect for polymorphic reasons.\n getPropertyPath(propName: string) {\n return propName;\n }\n\n /**\n Sets the entity to an EntityState of 'Added'. This is NOT the equivalent of calling {@link EntityManager.addEntity}\n because no key generation will occur for autogenerated keys as a result of this operation. As a result this operation can be problematic\n unless you are certain that the entity being marked 'Added' does not already exist in the database and does not have an autogenerated key.\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setAdded();\n // The 'order' entity will now be in an 'Added' state.\n ```\n */\n setAdded() {\n return this.setEntityState(EntityState.Added);\n }\n\n /**\n Sets the entity to an EntityState of 'Unchanged'. This is also the equivalent of calling {@link EntityAspect.acceptChanges}.\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setUnchanged();\n // The 'order' entity will now be in an 'Unchanged' state with any changes committed.\n ```\n */\n setUnchanged = function () {\n return this.setEntityState(EntityState.Unchanged);\n };\n\n\n /**\n Sets the entity to an EntityState of 'Modified'. This can also be achieved by changing the value of any property on an 'Unchanged' entity.\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setModified();\n // The 'order' entity will now be in a 'Modified' state.\n ```\n */\n setModified = function () {\n return this.setEntityState(EntityState.Modified);\n };\n\n /**\n Sets the entity to an EntityState of 'Deleted'. This both marks the entity as being scheduled for deletion during the next 'Save' call\n but also removes the entity from all of its related entities. If the current entityState is 'Added', then `setDeleted()` will mark it 'Detached'\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setDeleted();\n // The 'order' entity will now be in a 'Deleted' state and it will no longer have any 'related' entities.\n ```\n */\n setDeleted = function () {\n return this.setEntityState(EntityState.Deleted);\n };\n\n /**\n 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.\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setDetached();\n // The 'order' entity will now be in a 'Detached' state and it will no longer have any 'related' entities.\n ```\n */\n setDetached = function () {\n return this.setEntityState(EntityState.Detached);\n };\n\n /**\n Sets the entity to the specified EntityState. See also 'setUnchanged', 'setModified', 'setDetached', etc.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setEntityState(EntityState.Unchanged);\n // The 'order' entity will now be in a 'Unchanged' state.\n ```\n */\n setEntityState(entityState: EntityState) {\n if (this.entityState === entityState) return false;\n this._checkOperation(\"setEntityState\");\n if (this.entityState.isDetached()) {\n throw new Error(\"You cannot set the 'entityState' of an entity when it is detached - except by first attaching it to an EntityManager\");\n }\n let entity = this.entity!;\n let em = this.entityManager!;\n let needsSave = true;\n if (entityState === EntityState.Unchanged) {\n clearOriginalValues(entity);\n this.hasTempKey = undefined; // not delete: every entity that becomes Unchanged runs this\n needsSave = false;\n } else if (entityState === EntityState.Added) {\n clearOriginalValues(entity);\n // TODO: more to do here... like regenerating key ???\n } else if (entityState === EntityState.Deleted) {\n if (this.entityState.isAdded()) {\n // turn it into a detach and exit early\n this.setEntityState(EntityState.Detached);\n return true;\n } else {\n // TODO: think about cascade deletes\n // entityState needs to be set it early in this one case to insure that fk's are not cleared.\n this.entityState = EntityState.Deleted;\n removeFromRelations(entity, EntityState.Deleted);\n }\n } else if (entityState === EntityState.Modified) {\n // nothing extra needed\n } else if (entityState === EntityState.Detached) {\n let group = this.entityGroup;\n // no group === already detached.\n if (!group) return false;\n group.detachEntity(entity);\n // An entity whose foreign keys named parents that are not in the cache is parked in the\n // unattached-children map, waiting for them. Detaching it has to take it back out, or the\n // manager holds it for good: clear() replaces the whole map, but detachEntity does not.\n em._unattachedChildrenMap.removeChild(entity);\n // needs to occur early here - so this IS deliberately redundent with the same code later in this method.\n this.entityState = entityState;\n removeFromRelations(entity, EntityState.Detached);\n this._detach();\n em.entityChanged.publish({ entityAction: EntityAction.Detach, entity: entity });\n needsSave = false;\n }\n this.entityState = entityState;\n em._notifyStateChange(entity, needsSave);\n return true;\n }\n\n loadNavigationProperty(navigationProperty: string): Promise<QueryResult>;\n loadNavigationProperty(navigationProperty: NavigationProperty): Promise<QueryResult>;\n /** @deprecated Await the returned promise instead of passing callbacks. */\n loadNavigationProperty(navigationProperty: string, callback?: QuerySuccessCallback, errorCallback?: QueryErrorCallback): Promise<QueryResult>;\n /** @deprecated Await the returned promise instead of passing callbacks. */\n loadNavigationProperty(navigationProperty: NavigationProperty, callback?: QuerySuccessCallback, errorCallback?: QueryErrorCallback): Promise<QueryResult>;\n /**\n Performs a query for the value of a specified {@link NavigationProperty}. __Async__\n ```ts\n emp.entityAspect.loadNavigationProperty(\"Orders\").then(function (data) {\n var orders = data.results;\n }).catch(function (exception) {\n // handle exception here;\n });\n ```\n @param navigationProperty - The NavigationProperty or the name of the NavigationProperty to 'load'.\n @param callback - Deprecated. Function to call on success.\n @param errorCallback - Deprecated. Function to call on failure.\n @returns Promise with shape\n - results {Array of Entity}\n - query {EntityQuery} The original query\n - httpResponse {httpResponse} The HttpResponse returned from the server.\n */\n loadNavigationProperty(navigationProperty: NavigationProperty | string, callback?: QuerySuccessCallback, errorCallback?: QueryErrorCallback): Promise<QueryResult> {\n let entity = this.entity!;\n let navProperty = entity.entityType._checkNavProperty(navigationProperty);\n let query = EntityQuery.fromEntityNavigation(entity, navProperty);\n // return entity.entityAspect.entityManager.executeQuery(query, callback, errorCallback);\n let promise = entity.entityAspect.entityManager!.executeQuery(query);\n\n return promise.then((data) => {\n this._markAsLoaded(navProperty.name);\n if (callback) callback(data);\n return Promise.resolve(data);\n }, (error) => {\n if (errorCallback) errorCallback(error);\n return Promise.reject(error);\n });\n\n }\n\n /**\n Marks this navigationProperty on this entity as already having been loaded.\n ```ts\n emp.entityAspect.markNavigationPropertyAsLoaded(\"Orders\");\n ```\n @param navigationProperty - The NavigationProperty or name of NavigationProperty to 'load'.\n */\n markNavigationPropertyAsLoaded(navigationProperty: NavigationProperty | string) {\n if (!this.entity) return;\n let navProperty = this.entity.entityType._checkNavProperty(navigationProperty);\n this._markAsLoaded(navProperty.name);\n }\n\n isNavigationPropertyLoaded(navigationProperty: string): boolean;\n isNavigationPropertyLoaded(navigationProperty: NavigationProperty): boolean;\n /**\n Determines whether a navigationProperty on this entity has already been loaded.\n\n A navigation property is considered loaded when any of the following three conditions applies:\n\n 1. It was fetched from the backend server.\n <br/> This can be the result of an expand query or a call to the {@link EntityAspect.loadNavigationProperty} method.\n <br/> Note that even if the fetch returns nothing the property is still marked as loaded in this case.\n 1. The property is scalar and has been set to a nonnull value.\n 1. The {@link EntityAspect.markNavigationPropertyAsLoaded} was called.\n \n ```ts\n var wasLoaded = emp.entityAspect.isNavigationPropertyLoaded(\"Orders\");\n ```\n @param navigationProperty - The NavigationProperty or name of NavigationProperty to 'load'.\n */\n isNavigationPropertyLoaded(navigationProperty: NavigationProperty | string): boolean {\n // Both returns below used to hand back `undefined` - a bare `return`, and `this._loadedNps &&`\n // when nothing has been marked yet - while the overload signatures above promise `boolean`.\n // TypeScript does not check an implementation signature against its own overloads, so callers\n // were told `boolean` and could be given `undefined`.\n if (!this.entity) return false;\n let navProperty = this.entity.entityType._checkNavProperty(navigationProperty);\n if (navProperty.isScalar && this.entity.getProperty(navProperty.name) != null) {\n return true;\n }\n return !!this._loadedNps && this._loadedNps.indexOf(navProperty.name) >= 0;\n }\n\n /** @hidden @internal */\n _markAsLoaded(navPropName: string) {\n this._loadedNps = this._loadedNps || [];\n core.arrayAddItemUnique(this._loadedNps, navPropName);\n }\n\n\n /**\n Performs validation on the entity, any errors encountered during the validation are available via the\n {@link EntityAspect.getValidationErrors} method. Validating an entity means executing\n all of the validators on both the entity itself as well as those on each of its properties.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var isOk = order.entityAspect.validateEntity();\n // isOk will be 'true' if there are no errors on the entity.\n if (!isOk) {\n var errors = order.entityAspect.getValidationErrors();\n }\n ```\n @returns Whether the entity can be saved: every validator passes, and no error added with\n {@link EntityAspect.addValidationError} remains. Errors from the server are not counted - a save\n clears them before validating, and the server checks again. This is the check `saveChanges`\n makes, so the two always agree.\n */\n validateEntity() {\n let ok = true;\n this._processValidationOpAndPublish(function (that: any) {\n ok = validateTarget(that.entity);\n });\n // validateTarget re-runs the validators, so on its own it answers only for the errors\n // validators make. An error added with addValidationError is still an error, and the entity is\n // not valid while it stands - it used to be ignored here, and so saveChanges, which asks this,\n // sent the entity anyway. The server's errors are the exception: every save clears them before\n // validating, because the server checks again, and counting them here would make this answer\n // differ from the one a save gets.\n return ok && !this._hasBlockingErrors();\n }\n\n validateProperty(property: string, context?: any): boolean;\n validateProperty(property: DataProperty, context?: any): boolean;\n validateProperty(property: NavigationProperty, context?: any): boolean;\n /**\n Performs validation on a specific property of this entity, any errors encountered during the validation are available via the\n {@link EntityAspect.getValidationErrors} method. Validating a property means executing\n all of the validators on the specified property. This call is also made automatically anytime a property\n of an entity is changed.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var isOk = order.entityAspect.validateProperty(\"Order\");\n ```\n\n or\n ```ts\n var orderDateProperty = order.entityType.getProperty(\"OrderDate\");\n var isOk = order.entityAspect.validateProperty(OrderDateProperty);\n ```\n @param property - The {@link DataProperty} or {@link NavigationProperty} to validate or a string \n with the name of the property or a property path with the path to a property of a complex object.\n @param context - A context object used to pass additional information to each {@link Validator}.\n @returns Whether the property can be saved: its validators pass, and no error added with\n {@link EntityAspect.addValidationError} about it remains. As with {@link EntityAspect.validateEntity},\n errors from the server are not counted.\n */\n validateProperty(property: EntityProperty | string, context: any) {\n let value = this.getPropertyValue(property); // performs validations\n // As validateEntity: an error added with addValidationError for this property counts too.\n const propertyName = typeof property === \"string\" ? property : property.name;\n if (value && value.complexAspect) {\n return validateTarget(value) && !this._hasBlockingErrors(propertyName);\n }\n context = context || {};\n context.entity = this.entity;\n if (typeof property === \"string\") {\n context.property = this.entity!.entityType.getProperty(property, true);\n context.propertyName = property;\n } else {\n context.property = property;\n context.propertyName = property.name;\n }\n\n return this._validateProperty(value, context) && !this._hasBlockingErrors(context.propertyName);\n }\n\n /**\n Validates the entity as {@link EntityAspect.validateEntity} does, and also runs its async\n validators - see {@link Validator.isAsync} - resolving when they have all answered. This is the\n check `saveChanges` makes when any of the entities it saves has an async validator.\n ```ts\n if (!await order.entityAspect.validateEntityAsync()) {\n const errors = order.entityAspect.getValidationErrors();\n }\n ```\n While it runs, {@link EntityAspect.isValidating} is true. If a property changes while one of its\n checks runs, the check is run again on the new value.\n @returns Whether the entity can be saved, as {@link EntityAspect.validateEntity} answers, once the\n async validators' answers are in.\n */\n async validateEntityAsync(): Promise<boolean> {\n this.validateEntity();\n await runAsyncChecks(this, collectAsyncChecks(this.entity));\n return !this._hasBlockingErrors();\n }\n\n /**\n Validates one property as {@link EntityAspect.validateProperty} does, and also runs its async\n validators, resolving when they have all answered.\n ```ts\n const isOk = await customer.entityAspect.validatePropertyAsync(\"companyName\");\n ```\n @param property - The property, by {@link DataProperty}, {@link NavigationProperty}, name, or path\n to a property of a complex object.\n @param context - Additional context for each {@link Validator}.\n @returns Whether the property can be saved, once the async validators' answers are in.\n */\n async validatePropertyAsync(property: EntityProperty | string, context?: any): Promise<boolean> {\n this.validateProperty(property as any, context && { ...context });\n await runAsyncChecks(this, collectAsyncPropertyChecks(this, property, context));\n return !this._hasBlockingErrors(typeof property === \"string\" ? property : property.name);\n }\n\n getValidationErrors(): ValidationError[];\n getValidationErrors(property: string): ValidationError[];\n getValidationErrors(property: EntityProperty): ValidationError[];\n /**\n Returns the validation errors associated with either the entire entity or any specified property.\n \n This method can return all of the errors for an Entity\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var valErrors = order.entityAspect.getValidationErrors();\n ```\n\n as well as those for just a specific property.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var orderDateErrors = order.entityAspect.getValidationErrors(\"OrderDate\");\n ```\n\n which can also be expressed as\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var orderDateProperty = order.entityType.getProperty(\"OrderDate\");\n var orderDateErrors = order.entityAspect.getValidationErrors(orderDateProperty);\n ```\n @param property - The property for which validation errors should be retrieved.\n If omitted, all of the validation errors for this entity will be returned.\n @returns A array of validation errors.\n */\n getValidationErrors(property?: DataProperty | NavigationProperty | string) {\n assertParam(property, \"property\").isOptional().isEntityProperty().or().isString().check();\n let result = core.getOwnPropertyValues(this._validationErrors);\n if (property) {\n let propertyName = typeof (property) === 'string' ? property : property.name;\n // By propertyName as well as by the property object: an error added with only a\n // propertyName in its context - as the validation guide shows - has no property object, and\n // was missing from this list while validateProperty reported the property invalid because\n // of it. A form asking \"why is this field wrong?\" got an empty answer.\n result = result.filter(function (ve: ValidationError) {\n return (ve.property && ve.property.name === propertyName) || ve.propertyName === propertyName;\n });\n }\n return result;\n }\n\n /**\n The value a property had before the entity's pending changes: its original value if it has been\n edited since the entity was last saved or accepted, and its current value if not. So it answers\n \"what was this?\" without first asking whether it changed.\n ```ts\n order.freight = 99;\n order.entityAspect.getOriginalValue('freight'); // the freight before the edit\n order.entityAspect.getOriginalValue('shipCity'); // unchanged, so its current value\n ```\n Also takes a path into a complex property, such as `'location.city'`.\n @param propertyName - A data property of this entity, or a path to one in a complex property.\n */\n getOriginalValue(propertyName: string): any {\n let target: any = this.entity;\n let name = propertyName;\n const dot = name.lastIndexOf('.');\n if (dot >= 0) {\n target = this.getPropertyValue(name.slice(0, dot));\n name = name.slice(dot + 1);\n }\n const originals = (target.entityAspect || target.complexAspect).originalValues;\n return Object.prototype.hasOwnProperty.call(originals, name) ? originals[name] : target.getProperty(name);\n }\n\n /**\n The data properties whose value now differs from the one the entity was last saved or accepted\n with - as paths, such as `'location.city'`, for those of a complex property, and by name for an\n array property whose contents changed. A property edited and then set back is not included,\n although it stays in {@link EntityAspect.originalValues}. Dates are compared by time.\n ```ts\n order.freight = 99;\n order.shipCity = order.shipCity; // set, but to the same value\n order.entityAspect.getChangedProperties(); // ['freight']\n ```\n Always empty for an `Added` entity, which has no original values to differ from.\n */\n getChangedProperties(): string[] {\n return this.entity ? changedPropertyPaths(this.entity, this.originalValues, '') : [];\n }\n\n /**\n Adds a validation error.\n\n An error added here stops the entity being saved - `validateEntity` returns false and\n `saveChanges` rejects - until it is removed with {@link EntityAspect.removeValidationError} or\n {@link EntityAspect.clearValidationErrors}. Editing the property does not remove it: Breeze\n cannot re-check a rule it did not run. Give the error a key, and a failed save names it by that\n key in `errorName`.\n */\n addValidationError(validationError: ValidationError) {\n assertParam(validationError, \"validationError\").isInstanceOf(ValidationError).check();\n this._processValidationOpAndPublish(function (that: any) {\n that._addValidationError(validationError);\n });\n }\n\n removeValidationError(validationError: ValidationError): void;\n removeValidationError(validationKey: string): void;\n removeValidationError(validator: Validator): void;\n /**\n Removes a validation error.\n @param validationErrorOrKey - A ValidationError, a ValidationError 'key' value, or a Validator -\n in which case every error that validator produced on this entity is removed.\n */\n removeValidationError(validationErrorOrKey: ValidationError | string | Validator) {\n assertParam(validationErrorOrKey, \"validationErrorOrKey\").isString().or().isInstanceOf(ValidationError).or().isInstanceOf(Validator).check();\n\n let keys: string[];\n if (typeof (validationErrorOrKey) === \"string\") {\n keys = [validationErrorOrKey];\n } else if (validationErrorOrKey instanceof Validator) {\n // A Validator has no key of its own - reading one used to remove nothing, silently.\n const errors = this._validationErrors as Record<string, ValidationError>;\n keys = Object.keys(errors).filter(k => errors[k]?.validator === validationErrorOrKey);\n } else {\n keys = [validationErrorOrKey.key];\n }\n this._processValidationOpAndPublish(function (that: any) {\n keys.forEach(key => that._removeValidationError(key));\n });\n }\n\n /**\n Removes all of the validation errors for a specified entity\n */\n clearValidationErrors() {\n this._processValidationOpAndPublish(function (that: any) {\n core.objectForEach(that._validationErrors, function (key: string, valError: ValidationError) {\n if (valError) {\n delete that._validationErrors[key];\n that._pendingValidationResult.removed.push(valError);\n }\n });\n that.hasValidationErrors = !core.isEmpty(that._validationErrors);\n });\n }\n\n /**\n Returns an {@link EntityKey} for the entity pointed to by the specified scalar NavigationProperty.\n This only returns an EntityKey if the current entity is a 'child' entity along the specified NavigationProperty. \n i.e. has a single parent.\n\n @param navigationProperty - The {@link NavigationProperty} ( pointing to a parent). \n @returns Either a parent EntityKey if this is a 'child' entity or null; \n */\n getParentKey(navigationProperty: NavigationProperty) {\n if (!this.entity) return null;\n let fkNames = navigationProperty.foreignKeyNames;\n if (fkNames.length === 0) return null;\n let that = this;\n let fkValues = fkNames.map(function (fkn) {\n return that.entity!.getProperty(fkn);\n });\n return new EntityKey(navigationProperty.entityType, fkValues);\n }\n\n // TODO: refactor this and the static getPropertyPathValue.\n /**\n Returns the value of a specified DataProperty or NavigationProperty or 'property path'. \n */\n getPropertyValue(property: string | DataProperty | NavigationProperty) {\n assertParam(property, \"property\").isString().or().isEntityProperty().check();\n let value: any;\n if (typeof (property) === 'string') {\n let propNames = property.trim().split(\".\");\n let propName = propNames.shift();\n value = this.entity;\n value = value.getProperty(propName);\n while (propNames.length > 0) {\n propName = propNames.shift();\n value = value.getProperty(propName);\n }\n } else {\n if (!(property.parentType instanceof EntityType)) {\n throw new Error(\"The validateProperty method does not accept a 'property' parameter whose parentType is a ComplexType; \" +\n \"Pass a 'property path' string as the 'property' parameter instead \");\n }\n value = this.entity!.getProperty(property.name);\n }\n return value;\n }\n\n // internal methods\n /** @hidden @internal */\n _checkOperation(operationName: string) {\n if (this.isBeingSaved) {\n throw new Error(\"Cannot perform a '\" + operationName + \"' on an entity that is in the process of being saved\");\n }\n // allows chaining\n return this;\n }\n\n /** @hidden @internal */\n _detach() {\n this.entityGroup = undefined;\n this.entityManager = undefined;\n this.entityState = EntityState.Detached;\n this.originalValues = {};\n this._validationErrors = {};\n this.hasValidationErrors = false;\n this.validationErrorsChanged.clear();\n this.propertyChanged.clear();\n if (this._asyncChecks) {\n this._asyncChecks.forEach(run => run.controller.abort());\n this._asyncChecks = undefined;\n }\n }\n\n\n // called from defaultInterceptor.\n /** @hidden @internal */\n _validateProperty(value: any, context: any) {\n let ok = true;\n this._processValidationOpAndPublish(function (that: any) {\n context.property.getAllValidators().forEach(function (validator: Validator) {\n ok = validate(that, validator, value, context) && ok;\n });\n });\n return ok;\n }\n\n /** @hidden @internal */\n _processValidationOpAndPublish(validationFn: any) {\n if (this._pendingValidationResult) {\n // only top level processValidations call publishes\n validationFn(this);\n } else {\n try {\n this._pendingValidationResult = { entity: this.entity, added: [], removed: [] };\n validationFn(this);\n if (this._pendingValidationResult.added.length > 0 || this._pendingValidationResult.removed.length > 0) {\n this.validationErrorsChanged.publish(this._pendingValidationResult);\n // this might be a detached entity hence the guard below.\n this.entityManager && this.entityManager.validationErrorsChanged.publish(this._pendingValidationResult);\n\n }\n } finally {\n this._pendingValidationResult = undefined;\n }\n }\n }\n\n /** @hidden @internal */\n // Whether an error stands that should stop this entity being saved - every error except the\n // server's, which a save clears before validating. With a property name, only errors about that\n // property, or about a property inside it when it is a complex property.\n _hasBlockingErrors(propertyName?: string) {\n if (!this.hasValidationErrors) return false;\n const errors = this._validationErrors;\n for (const key in errors) {\n const ve = errors[key];\n if (!ve || ve.isServerError) continue;\n if (propertyName == null || isAbout(ve, propertyName)) return true;\n }\n return false;\n }\n\n /** @hidden @internal */\n // Drops the errors about a property that its edit has made stale: the server's, and those of\n // async validators, which cannot run again until the next save or validateEntityAsync. Both were\n // about a value the entity no longer has. Runs on every edit that is not part of a load, so the\n // entity with no errors - nearly all of them - pays one flag check.\n _clearStaleErrors(propertyName: string) {\n if (!this.hasValidationErrors) return;\n const keys: string[] = [];\n const errors = this._validationErrors;\n for (const key in errors) {\n const ve = errors[key];\n if (ve && (ve.isServerError || ve.validator?.isAsync) && isAbout(ve, propertyName)) keys.push(key);\n }\n if (keys.length === 0) return;\n this._processValidationOpAndPublish(function (that: EntityAspect) {\n keys.forEach(key => that._removeValidationError(key));\n });\n }\n\n /** @hidden @internal */\n _addValidationError(validationError: ValidationError) {\n this._validationErrors[validationError.key] = validationError;\n this.hasValidationErrors = true;\n this._pendingValidationResult.added.push(validationError);\n }\n\n /** @hidden @internal */\n _removeValidationError(key: string) {\n let valError = this._validationErrors[key];\n if (valError) {\n delete this._validationErrors[key];\n this.hasValidationErrors = !core.isEmpty(this._validationErrors);\n this._pendingValidationResult.removed.push(valError);\n }\n }\n\n}\n\nBreezeEvent.bubbleEvent(EntityAspect.prototype, function () {\n return this.entityManager;\n});\n\nfunction rejectChangesCore(target: any) {\n let aspect = target.entityAspect || target.complexAspect;\n let stype = target.entityType || target.complexType;\n let originalValues = aspect.originalValues;\n for (let propName in originalValues) {\n target.setProperty(propName, originalValues[propName]);\n }\n stype.complexProperties.forEach(function (cp: any) {\n let cos = target.getProperty(cp.name);\n if (cp.isScalar) {\n rejectChangesCore(cos);\n } else {\n observableArray.rejectChanges(cos);\n cos.forEach(rejectChangesCore);\n }\n });\n}\n\n/**\n * The value of a property as stored, without creating anything. A collection navigation is built\n * on first read, so code that only wants to look at *existing* related entities - attaching,\n * deleting - asks with this. Falls back to getProperty for a model library that cannot peek,\n * which just means the collection is created as it was before.\n * @hidden @internal\n */\nexport function peekProperty(entity: StructuralObject, propertyName: string): any {\n const modelLibrary = config.interfaceRegistry.modelLibrary.getDefaultInstance() as any;\n return modelLibrary.peekProperty\n ? modelLibrary.peekProperty(entity, propertyName)\n : (entity as any).getProperty(propertyName);\n}\n\nfunction removeFromRelations(entity: Entity, entityState: EntityState) {\n // remove this entity from any collections.\n // mark the entity deleted or detached\n\n let isDeleted = entityState.isDeleted();\n if (isDeleted) {\n removeFromRelationsCore(entity);\n } else {\n core.using(entity.entityAspect.entityManager!, \"isLoading\", true, function () {\n removeFromRelationsCore(entity);\n });\n }\n}\n\nfunction removeFromRelationsCore(entity: Entity) {\n entity.entityType.navigationProperties.forEach(function (np) {\n let inverseNp = np.inverse;\n // A collection that has never been read holds no related entities, and reading it here would\n // create an array only to empty it.\n let npValue = np.isScalar ? entity.getProperty(np.name) : peekProperty(entity, np.name);\n if (np.isScalar) {\n if (npValue) {\n if (inverseNp) {\n if (inverseNp.isScalar) {\n npValue.setProperty(inverseNp.name, null);\n } else {\n let collection = npValue.getProperty(inverseNp.name);\n if (collection.length) {\n core.arrayRemoveItem(collection, entity);\n }\n }\n }\n entity.setProperty(np.name, null);\n }\n } else {\n if (npValue == null) return;\n // Empty it in one go rather than letting each child splice itself out, which is O(n) per\n // child and one event per child. clearAll nulls each child's reference to this entity\n // first - so the child still gets its navigation property and foreign key cleared - then\n // truncates and publishes a single arrayChanged. A many-to-many inverse has nothing to\n // null on the other side, so it is emptied with no per-child step. (TODO: many to many.)\n const clearChild = inverseNp != null && inverseNp.isScalar\n ? (v: any) => v.setProperty(inverseNp!.name, null)\n : undefined;\n observableArray.clearAll(npValue, clearChild);\n }\n });\n\n}\n\n// note entityAspect only - ( no complex aspect allowed on the call).\n/** Whether a validation error concerns a property: that property, or one inside it by path. */\nfunction isAbout(ve: ValidationError, propertyName: string) {\n const name = ve.propertyName;\n return name === propertyName || (name != null && name.startsWith(propertyName + '.'));\n}\n\nfunction validate(entityAspect: EntityAspect, validator: Validator, value: any, context?: any) {\n // Nothing here can wait for an async validator's answer, so it is not asked; its last settled\n // answer stands. It runs from validateEntityAsync, and when the entity is saved.\n if (validator.isAsync) return true;\n let ve = validator.validate(value, context);\n if (ve) {\n entityAspect._addValidationError(ve);\n return false;\n } else {\n let key = ValidationError.getKey(validator, context ? context.propertyName : null);\n entityAspect._removeValidationError(key);\n return true;\n }\n}\n\n/** One async validator to run: the value to check, the context it gets, and how to read the value\nagain - to tell whether it changed while it was being checked. */\ninterface AsyncCheck {\n validator: Validator;\n value: any;\n context?: any;\n read: () => any;\n}\n\n/** @hidden @internal */\nexport interface AsyncCheckRun {\n controller: AbortController;\n done: Promise<void>;\n}\n\n/** How many times a check is run again because its value keeps changing while it is checked. */\nconst MAX_ASYNC_ROUNDS = 3;\n\n/** The async validators of an entity or complex object, walked as validateTarget walks the sync ones. */\nfunction collectAsyncChecks(target: any, coIndex?: number): AsyncCheck[] {\n const checks: AsyncCheck[] = [];\n const stype = target.entityType || target.complexType;\n const aspect = target.entityAspect || target.complexAspect;\n const entityAspect = target.entityAspect || target.complexAspect.getEntityAspect();\n\n stype.getProperties().forEach((p: any) => {\n const read = () => p.isNavigationProperty && !p.isScalar ? peekProperty(target, p.name) : target.getProperty(p.name);\n const value = read();\n const asyncValidators = p.getAllValidators().filter((v: Validator) => v.isAsync);\n if (asyncValidators.length > 0) {\n // A context of its own for each property: validateTarget reuses one, which an async check,\n // still reading it later, would see changed underneath it.\n const context: any = { entity: entityAspect.entity, property: p, propertyName: aspect.getPropertyPath(p.name) };\n if (coIndex !== undefined) context.index = coIndex;\n asyncValidators.forEach((validator: Validator) => checks.push({ validator, value, context, read }));\n }\n if (p.isComplexProperty) {\n if (p.isScalar) {\n checks.push(...collectAsyncChecks(value));\n } else {\n value.forEach((co: any, ix: number) => checks.push(...collectAsyncChecks(co, ix)));\n }\n }\n });\n\n stype.getAllValidators().filter((v: Validator) => v.isAsync).forEach((validator: Validator) => {\n checks.push({ validator, value: target, read: () => target });\n });\n return checks;\n}\n\n/** The async validators of one property, found as validateProperty finds the sync ones. */\nfunction collectAsyncPropertyChecks(aspect: EntityAspect, property: EntityProperty | string, context?: any): AsyncCheck[] {\n const read = () => aspect.getPropertyValue(property);\n const value = read();\n if (value && value.complexAspect) return collectAsyncChecks(value);\n const prop = typeof property === \"string\" ? aspect.entity!.entityType.getProperty(property, true)! : property; // throws if not found\n const propertyName = typeof property === \"string\" ? property : property.name;\n const checkContext = { ...context, entity: aspect.entity, property: prop, propertyName };\n return prop.getAllValidators().filter((v: Validator) => v.isAsync)\n .map((validator: Validator) => ({ validator, value, context: checkContext, read }));\n}\n\nfunction runAsyncChecks(aspect: EntityAspect, checks: AsyncCheck[]) {\n return Promise.all(checks.map(check => runAsyncCheck(aspect, check, 1)));\n}\n\n/**\nRuns one async check and applies its answer, unless the answer is no longer wanted: a newer run of\nthe same check has started - whose answer is then the one waited for - or the entity was detached.\nIf the value changed while it was checked, the check runs again on the new value.\n*/\nfunction runAsyncCheck(aspect: EntityAspect, check: AsyncCheck, round: number): Promise<void> {\n const key = ValidationError.getKey(check.validator, check.context && check.context.propertyName);\n const runs = aspect._asyncChecks || (aspect._asyncChecks = new Map());\n runs.get(key)?.controller.abort();\n const controller = new AbortController();\n const run = { controller } as AsyncCheckRun;\n runs.set(key, run);\n\n run.done = check.validator.validateAsync(check.value, { ...check.context, signal: controller.signal }).then(ve => {\n const current = aspect._asyncChecks?.get(key);\n if (current !== run) return current?.done; // replaced, or detached\n aspect._asyncChecks!.delete(key);\n const valueNow = check.read();\n if (valueNow !== check.value) {\n return round < MAX_ASYNC_ROUNDS ? runAsyncCheck(aspect, { ...check, value: valueNow }, round + 1) : undefined;\n }\n aspect._processValidationOpAndPublish((that: EntityAspect) => {\n if (ve) {\n that._addValidationError(ve);\n } else {\n that._removeValidationError(key);\n }\n });\n });\n return run.done;\n}\n\n/** The paths of target's data properties whose value differs from its original one. */\nfunction changedPropertyPaths(target: any, originalValues: Record<string, any>, prefix: string): string[] {\n const stype = target.entityType || target.complexType;\n const paths: string[] = [];\n stype.dataProperties.forEach((dp: DataProperty) => {\n const path = prefix + dp.name;\n if (dp.isComplexProperty) {\n const value = target.getProperty(dp.name);\n if (dp.isScalar) {\n if (value) paths.push(...changedPropertyPaths(value, value.complexAspect.originalValues, path + '.'));\n } else if (arrayContentsChanged(value) ||\n (value || []).some((co: any) => changedPropertyPaths(co, co.complexAspect.originalValues, '').length > 0)) {\n paths.push(path);\n }\n } else if (!dp.isScalar) {\n if (arrayContentsChanged(target.getProperty(dp.name))) paths.push(path);\n } else if (Object.prototype.hasOwnProperty.call(originalValues, dp.name)) {\n const comparable = DataType.getComparableFn(dp.dataType as DataType);\n if (comparable(originalValues[dp.name]) !== comparable(target.getProperty(dp.name))) paths.push(path);\n }\n });\n return paths;\n}\n\n/** Whether an array property's contents differ from those it had before its entity was changed. */\nfunction arrayContentsChanged(arr: any): boolean {\n const original = observableArray.originalContents(arr);\n if (!original) return false;\n return original.length !== arr.length || original.some((item: any, ix: number) => item !== arr[ix]);\n}\n\n// coIndex is only used where target is a complex object that is part of an array of complex objects\n// in which case ctIndex is the index of the target within the array.\nfunction validateTarget(target: any, coIndex?: number) {\n let ok = true;\n let stype = target.entityType || target.complexType;\n let aspect = target.entityAspect || target.complexAspect;\n let entityAspect = target.entityAspect || target.complexAspect.getEntityAspect();\n let context = <any>{ entity: entityAspect.entity };\n if (coIndex !== undefined) {\n context.index = coIndex;\n }\n\n stype.getProperties().forEach(function (p: any) {\n let value = p.isNavigationProperty && !p.isScalar\n ? peekProperty(target, p.name)\n : target.getProperty(p.name);\n let validators = p.getAllValidators();\n if (validators.length > 0) {\n context.property = p;\n context.propertyName = aspect.getPropertyPath(p.name);\n ok = entityAspect._validateProperty(value, context) && ok;\n }\n if (p.isComplexProperty) {\n if (p.isScalar) {\n ok = validateTarget(value) && ok;\n } else {\n ok = value.reduce(function (pv: any, cv: any, ix: number) {\n return validateTarget(cv, ix) && pv;\n }, ok);\n }\n }\n });\n\n\n // then target level\n stype.getAllValidators().forEach(function (validator: Validator) {\n ok = validate(entityAspect, validator, target) && ok;\n });\n return ok;\n}\n\n/**\nAn ComplexAspect instance is associated with every complex object instance and is accessed via the complex object's 'complexAspect' property.\n\nThe ComplexAspect itself provides properties to determine the parent object, parent property and original values for the complex object.\n\nA ComplexAspect will almost never need to be constructed directly. You will usually get an ComplexAspect by accessing\nan entities 'complexAspect' property. This property will be automatically attached when an complex object is created as part of an\nentity via either a query, import or EntityManager.createEntity call.\n```ts\n// assume address is a complex property on the 'Customer' type\nvar aspect = aCustomer.address.complexAspect;\n// aCustomer === aspect.parent;\n```\n*/\nexport class ComplexAspect {\n\n /** The complex object that this aspect is associated with. __Read Only__ */\n complexObject: ComplexObject;\n /** The 'original values' of this complex object where they are different from the 'current values'.\n This is a map where the key is a property name and the value is the 'original value' of the property.\n __Read Only__ */\n originalValues: Record<string, any>;\n /** The parent object that to which this aspect belongs; this will either be an entity or another complex object. __Read Only__ */\n parent?: StructuralObject;\n /** The {@link DataProperty} on the 'parent' that contains this complex object. __Read Only__ */\n parentProperty?: DataProperty;\n /** Unlike {@link EntityAspect.extraMetadata}, Breeze does not fill this in and does not export it.\n An application may use it to hold its own data about the complex object. */\n extraMetadata?: any;\n\n /** You will rarely, if ever, create a ComplexAspect directly. */\n constructor(complexObject: ComplexObject, parent: StructuralObject, parentProperty: DataProperty) {\n if (!complexObject) {\n throw new Error(\"The ComplexAspect ctor requires an entity as its only argument.\");\n }\n if (complexObject.complexAspect) {\n return complexObject.complexAspect;\n }\n // if called without new\n if (!(this instanceof ComplexAspect)) {\n return new ComplexAspect(complexObject, parent, parentProperty);\n }\n\n // entityType should already be on the entity from 'watch'\n this.complexObject = complexObject;\n complexObject.complexAspect = this;\n\n // TODO: keep public or not?\n this.originalValues = {};\n\n // if a standalone complexObject\n if (parent != null) {\n this.parent = parent;\n this.parentProperty = parentProperty;\n }\n\n let complexType = complexObject.complexType;\n if (!complexType) {\n let typeName = complexObject.prototype!._$typeName;\n if (!typeName) {\n throw new Error(\"This entity is not registered as a valid ComplexType\");\n } else {\n throw new Error(\"Metadata for this complexType has not yet been resolved: \" + typeName);\n }\n }\n let complexCtor = complexType.getCtor();\n config.interfaceRegistry.modelLibrary.getDefaultInstance().startTracking(complexObject, complexCtor.prototype);\n\n }\n\n\n /**\n Returns the EntityAspect for the top level entity that contains this complex object.\n */\n getEntityAspect() {\n let parent = <any>this.parent;\n if (!parent) return new EntityAspect();\n let entityAspect = parent.entityAspect;\n while (parent && !entityAspect) {\n parent = parent.complexAspect && parent.complexAspect.parent;\n entityAspect = parent && parent.entityAspect;\n }\n return entityAspect || new EntityAspect();\n }\n\n /** @hidden @internal */\n // TODO: rename - and use '_'; used on both EntityAspect and ComplexAspect for polymorphic reasons.\n getPropertyPath(propName: string) {\n let parent = <any>this.parent;\n if (!parent) return null;\n let aspect = parent.complexAspect || parent.entityAspect;\n return aspect.getPropertyPath(this.parentProperty!.name + \".\" + propName);\n }\n\n}\n\nfunction clearOriginalValues(target: any) {\n let aspect = target.entityAspect || target.complexAspect;\n aspect.originalValues = {};\n let stype = target.entityType || target.complexType;\n stype.complexProperties.forEach(function (cp: any) {\n let cos = target.getProperty(cp.name);\n if (cp.isScalar) {\n clearOriginalValues(cos);\n } else {\n observableArray.acceptChanges(cos);\n cos.forEach(clearOriginalValues);\n }\n });\n}\n\n\n\n/**\nAn {@link EntityAspect} that knows its entity's class, `T`: the type a generated entity class gives\nits `entityAspect`, as `EntityAspectOf<this>`. It is the same object; only the types are narrower -\nproperty names are checked, and values have their properties' types:\n```ts\norder.freight = 99;\norder.entityAspect.originalValues.freight; // number | undefined\norder.entityAspect.getOriginalValue('freight'); // number\norder.entityAspect.getOriginalValue('frieght'); // error: not a property of Order\norder.entityAspect.getChangedProperties(); // ('freight' | 'shipCity' | …)[]\n```\nAn interface extending the class, rather than a type parameter on it, so that it is an\n`EntityAspect` by declaration: a generic `EntityAspect<T>` whose members read `keyof T` would not be\none, and every generated class needs its aspect to be. And typed only by `T`'s own data properties:\nto reach through a navigation property, the types would have to ask whether the entity at the other\nend is an `Entity` - which asks about its aspect, and so about this one.\n*/\nexport interface EntityAspectOf<T> extends EntityAspect {\n /** {@link EntityAspect.originalValues}, keyed and typed by `T`'s data properties. */\n originalValues: OriginalValues<T>;\n /** {@link EntityAspect.getOriginalValue}, with the name checked against `T` and the value typed. */\n getOriginalValue<K extends DataKeys<T>>(propertyName: K): T[K];\n /** {@link EntityAspect.getOriginalValue} for a path into a complex property, such as `'location.city'`: untyped. */\n getOriginalValue(propertyPath: `${string}.${string}`): any;\n /** {@link EntityAspect.getChangedProperties}: `T`'s data properties, and paths into its complex ones. */\n getChangedProperties(): (DataKeys<T> | `${string}.${string}`)[];\n}\n\n/**\nA {@link ComplexAspect} that knows its complex object's class, `T`: the type a generated complex type\nclass gives its `complexAspect`, as `ComplexAspectOf<this>`. See {@link EntityAspectOf}.\n*/\nexport interface ComplexAspectOf<T> extends ComplexAspect {\n /** {@link ComplexAspect.originalValues}, keyed and typed by `T`'s data properties. */\n originalValues: OriginalValues<T>;\n}\n"]}
@@ -0,0 +1,55 @@
1
+ import type { ComplexObject, Entity, EntityAspectOf, ComplexAspectOf } from './entity-aspect.js';
2
+ import type { ComplexType, EntityType } from '../metadata/entity-metadata.js';
3
+ /**
4
+ A base class for entity classes: it declares the members Breeze supplies, so that a class
5
+ extending it declares only its own properties. The classes `breeze-gen-entities` writes extend it.
6
+ ```ts
7
+ export class Customer extends EntityBase {
8
+ declare customerID: string;
9
+ declare companyName: string;
10
+ }
11
+ ```
12
+ Extend it with a class of your own to give every entity the same behaviour:
13
+ ```ts
14
+ export abstract class AppEntityBase extends EntityBase {
15
+ get isNew() { return this.entityAspect.entityState.isAdded(); }
16
+ }
17
+ ```
18
+ It has no runtime behaviour - Breeze does not require it. A class can instead implement
19
+ {@link Entity} and declare these members itself.
20
+ */
21
+ export declare abstract class EntityBase implements Entity {
22
+ /** Called by the constructor of the class that extends it. It does nothing. */
23
+ constructor();
24
+ /** The {@link EntityAspect} Breeze attaches to the entity. Of `this`, so that `originalValues`
25
+ and `getOriginalValue` know the class's properties. */
26
+ entityAspect: EntityAspectOf<this>;
27
+ /** The {@link EntityType} the entity's class is registered for. */
28
+ entityType: EntityType;
29
+ /** Returns the value of a property by name. Installed by the model library adapter. */
30
+ getProperty: (prop: string) => any;
31
+ /** Sets the value of a property by name. Installed by the model library adapter. */
32
+ setProperty: (prop: any, value: any) => any;
33
+ }
34
+ /**
35
+ The complex-type counterpart of {@link EntityBase}: a base class for complex object classes, which
36
+ declares the members Breeze supplies.
37
+ ```ts
38
+ export class Location extends ComplexObjectBase {
39
+ declare address: string;
40
+ declare city: string;
41
+ }
42
+ ```
43
+ */
44
+ export declare abstract class ComplexObjectBase implements ComplexObject {
45
+ /** Called by the constructor of the class that extends it. It does nothing. */
46
+ constructor();
47
+ /** The {@link ComplexAspect} Breeze attaches to the complex object. */
48
+ complexAspect: ComplexAspectOf<this>;
49
+ /** The {@link ComplexType} the object's class is registered for. */
50
+ complexType: ComplexType;
51
+ /** Returns the value of a property by name. Installed by the model library adapter. */
52
+ getProperty: (prop: string) => any;
53
+ /** Sets the value of a property by name. Installed by the model library adapter. */
54
+ setProperty: (prop: any, value: any) => any;
55
+ }
@@ -0,0 +1,41 @@
1
+ // Every member is `declare`, so these classes compile to empty ones. With ES2022 class fields a
2
+ // plain field would become a real own property set to undefined, hiding the accessors Breeze
3
+ // installs on the prototype. Breeze never registers or writes to these classes themselves - only
4
+ // to the classes that extend them - so one copy is safely shared by every model.
5
+ /**
6
+ A base class for entity classes: it declares the members Breeze supplies, so that a class
7
+ extending it declares only its own properties. The classes `breeze-gen-entities` writes extend it.
8
+ ```ts
9
+ export class Customer extends EntityBase {
10
+ declare customerID: string;
11
+ declare companyName: string;
12
+ }
13
+ ```
14
+ Extend it with a class of your own to give every entity the same behaviour:
15
+ ```ts
16
+ export abstract class AppEntityBase extends EntityBase {
17
+ get isNew() { return this.entityAspect.entityState.isAdded(); }
18
+ }
19
+ ```
20
+ It has no runtime behaviour - Breeze does not require it. A class can instead implement
21
+ {@link Entity} and declare these members itself.
22
+ */
23
+ export class EntityBase {
24
+ /** Called by the constructor of the class that extends it. It does nothing. */
25
+ constructor() { }
26
+ }
27
+ /**
28
+ The complex-type counterpart of {@link EntityBase}: a base class for complex object classes, which
29
+ declares the members Breeze supplies.
30
+ ```ts
31
+ export class Location extends ComplexObjectBase {
32
+ declare address: string;
33
+ declare city: string;
34
+ }
35
+ ```
36
+ */
37
+ export class ComplexObjectBase {
38
+ /** Called by the constructor of the class that extends it. It does nothing. */
39
+ constructor() { }
40
+ }
41
+ //# sourceMappingURL=entity-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-base.js","sourceRoot":"","sources":["../../src/entity/entity-base.ts"],"names":[],"mappings":"AAGA,gGAAgG;AAChG,6FAA6F;AAC7F,iGAAiG;AACjG,iFAAiF;AAEjF;;;;;;;;;;;;;;;;;EAiBE;AACF,MAAM,OAAgB,UAAU;IAC9B,+EAA+E;IAC/E,gBAAe,CAAC;CAWjB;AAED;;;;;;;;;EASE;AACF,MAAM,OAAgB,iBAAiB;IACrC,+EAA+E;IAC/E,gBAAe,CAAC;CAUjB","sourcesContent":["import type { ComplexObject, Entity, EntityAspectOf, ComplexAspectOf } from './entity-aspect.js';\r\nimport type { ComplexType, EntityType } from '../metadata/entity-metadata.js';\r\n\r\n// Every member is `declare`, so these classes compile to empty ones. With ES2022 class fields a\r\n// plain field would become a real own property set to undefined, hiding the accessors Breeze\r\n// installs on the prototype. Breeze never registers or writes to these classes themselves - only\r\n// to the classes that extend them - so one copy is safely shared by every model.\r\n\r\n/**\r\nA base class for entity classes: it declares the members Breeze supplies, so that a class\r\nextending it declares only its own properties. The classes `breeze-gen-entities` writes extend it.\r\n```ts\r\nexport class Customer extends EntityBase {\r\n declare customerID: string;\r\n declare companyName: string;\r\n}\r\n```\r\nExtend it with a class of your own to give every entity the same behaviour:\r\n```ts\r\nexport abstract class AppEntityBase extends EntityBase {\r\n get isNew() { return this.entityAspect.entityState.isAdded(); }\r\n}\r\n```\r\nIt has no runtime behaviour - Breeze does not require it. A class can instead implement\r\n{@link Entity} and declare these members itself.\r\n*/\r\nexport abstract class EntityBase implements Entity {\r\n /** Called by the constructor of the class that extends it. It does nothing. */\r\n constructor() {}\r\n\r\n /** The {@link EntityAspect} Breeze attaches to the entity. Of `this`, so that `originalValues`\r\n and `getOriginalValue` know the class's properties. */\r\n declare entityAspect: EntityAspectOf<this>;\r\n /** The {@link EntityType} the entity's class is registered for. */\r\n declare entityType: EntityType;\r\n /** Returns the value of a property by name. Installed by the model library adapter. */\r\n declare getProperty: (prop: string) => any;\r\n /** Sets the value of a property by name. Installed by the model library adapter. */\r\n declare setProperty: (prop: any, value: any) => any;\r\n}\r\n\r\n/**\r\nThe complex-type counterpart of {@link EntityBase}: a base class for complex object classes, which\r\ndeclares the members Breeze supplies.\r\n```ts\r\nexport class Location extends ComplexObjectBase {\r\n declare address: string;\r\n declare city: string;\r\n}\r\n```\r\n*/\r\nexport abstract class ComplexObjectBase implements ComplexObject {\r\n /** Called by the constructor of the class that extends it. It does nothing. */\r\n constructor() {}\r\n\r\n /** The {@link ComplexAspect} Breeze attaches to the complex object. */\r\n declare complexAspect: ComplexAspectOf<this>;\r\n /** The {@link ComplexType} the object's class is registered for. */\r\n declare complexType: ComplexType;\r\n /** Returns the value of a property by name. Installed by the model library adapter. */\r\n declare getProperty: (prop: string) => any;\r\n /** Sets the value of a property by name. Installed by the model library adapter. */\r\n declare setProperty: (prop: any, value: any) => any;\r\n}\r\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,224 @@
1
+ import { DataProperty } from '../metadata/entity-metadata.js';
2
+ import { EntityKey } from './entity-key.js';
3
+ import { EntityState } from './entity-state.js';
4
+ import { MergeStrategy } from '../query/query-options.js';
5
+ /** @hidden @internal */
6
+ export class EntityGroup {
7
+ entityManager;
8
+ entityType;
9
+ /**
10
+ * Key string -> index into `_entities`. A `Map` and not an object literal: an object inherits
11
+ * `Object.prototype`, so an entity whose string key happened to be `__proto__` was attached but
12
+ * could never be found again - the assignment ran the inherited setter and stored nothing.
13
+ * Keys here are always strings (`EntityKey.createKeyString` joins the values), which an object
14
+ * did for us by coercion and a `Map` does not - see `_fixupKey`.
15
+ */
16
+ _indexMap;
17
+ _entities;
18
+ _emptyIndexes;
19
+ /**
20
+ * The entities in this group whose state is not Unchanged, maintained by `EntityAspect`'s
21
+ * `entityState` setter. `hasChanges` is then a size check rather than a scan of the group,
22
+ * which is what made detaching, accepting or rejecting n changed entities quadratic.
23
+ */
24
+ _changedEntities;
25
+ constructor(entityManager, entityType) {
26
+ this.entityManager = entityManager;
27
+ this.entityType = entityType;
28
+ // freeze the entityType after the first instance of this type is either created or queried.
29
+ this.entityType.isFrozen = true;
30
+ this._indexMap = new Map();
31
+ this._entities = [];
32
+ this._emptyIndexes = [];
33
+ this._changedEntities = new Set();
34
+ }
35
+ attachEntity(entity, entityState, mergeStrategy) {
36
+ // entity should already have an aspect.
37
+ let aspect = entity.entityAspect;
38
+ if (!aspect._initialized) {
39
+ this.entityType._initializeInstance(entity);
40
+ }
41
+ // Assigned, not deleted. Deleting an own property changes the object shape, and this runs
42
+ // for every entity attached - see "delete on a hot path" in CHANGES-DEV.md.
43
+ aspect._initialized = undefined;
44
+ let keyInGroup = aspect.getKey()._keyInGroup;
45
+ let ix = this._indexMap.get(keyInGroup);
46
+ if (ix !== undefined) {
47
+ // safecast because key was found not ix will not return a null
48
+ let targetEntity = this._entities[ix];
49
+ let targetEntityState = targetEntity.entityAspect.entityState;
50
+ let wasUnchanged = targetEntityState.isUnchanged();
51
+ if (targetEntity === entity) {
52
+ aspect.entityState = entityState;
53
+ }
54
+ else if (mergeStrategy === MergeStrategy.Disallowed) {
55
+ throw new Error("A MergeStrategy of 'Disallowed' does not allow you to attach an entity when an entity with the same key is already attached: " + aspect.getKey());
56
+ }
57
+ else if (mergeStrategy === MergeStrategy.OverwriteChanges || (mergeStrategy === MergeStrategy.PreserveChanges && wasUnchanged)) {
58
+ // unwrapInstance returns an entity with server side property names - so we need to use DataProperty.getRawValueFromServer these when we apply
59
+ // the property values back to the target.
60
+ let rawServerEntity = this.entityManager.helper.unwrapInstance(entity);
61
+ this.entityType._updateTargetFromRaw(targetEntity, rawServerEntity, DataProperty.getRawValueFromServer);
62
+ targetEntity.entityAspect.setEntityState(entityState);
63
+ }
64
+ return targetEntity;
65
+ }
66
+ else {
67
+ if (this._emptyIndexes.length === 0) {
68
+ ix = this._entities.push(entity) - 1;
69
+ }
70
+ else {
71
+ ix = this._emptyIndexes.pop();
72
+ this._entities[ix] = entity;
73
+ }
74
+ this._indexMap.set(keyInGroup, ix);
75
+ // The group has to be in place before the state is: the `entityState` setter is what puts
76
+ // this entity into `_changedEntities`, and it needs to know which group to put it in.
77
+ aspect.entityGroup = this;
78
+ aspect.entityManager = this.entityManager;
79
+ aspect.entityState = entityState;
80
+ if (aspect.hasTempKey)
81
+ reserveTempKeyValue(this.entityManager, entity.entityType, aspect.getKey().values[0]);
82
+ return entity;
83
+ }
84
+ }
85
+ detachEntity(entity) {
86
+ // by this point we have already determined that this entity
87
+ // belongs to this group.
88
+ let aspect = entity.entityAspect;
89
+ let keyInGroup = aspect.getKey()._keyInGroup;
90
+ let ix = this._indexMap.get(keyInGroup);
91
+ if (ix === undefined) {
92
+ // shouldn't happen.
93
+ throw new Error("internal error - entity cannot be found in group");
94
+ }
95
+ this._indexMap.delete(keyInGroup);
96
+ this._changedEntities.delete(entity);
97
+ this._emptyIndexes.push(ix);
98
+ this._entities[ix] = null;
99
+ if (aspect.hasTempKey)
100
+ releaseTempKeyValue(this.entityManager, entity.entityType, aspect.getKey().values[0]);
101
+ return entity;
102
+ }
103
+ // returns entity based on an entity key defined either as an array of key values or an EntityKey
104
+ findEntityByKey(entityKey) {
105
+ let keyInGroup;
106
+ if (entityKey instanceof EntityKey) {
107
+ keyInGroup = entityKey._keyInGroup;
108
+ }
109
+ else {
110
+ keyInGroup = EntityKey.createKeyString(entityKey);
111
+ }
112
+ let ix = this._indexMap.get(keyInGroup);
113
+ // can't use just (ix) below because 0 is valid
114
+ let r = (ix !== undefined) ? this._entities[ix] : undefined;
115
+ // coerce null to undefined
116
+ return r == null ? undefined : r;
117
+ }
118
+ hasChanges() {
119
+ return this._changedEntities.size > 0;
120
+ }
121
+ getChanges() {
122
+ // Deliberately still a scan of `_entities` rather than a copy of `_changedEntities`: this is
123
+ // what fixes the order changed entities are saved in, and `_entities` order is attach order
124
+ // where a Set's is the order each entity first became dirty.
125
+ let entities = this._entities;
126
+ let unchanged = EntityState.Unchanged;
127
+ let changes = [];
128
+ for (let i = 0, len = entities.length; i < len; i++) {
129
+ let e = entities[i];
130
+ if (e && e.entityAspect.entityState !== unchanged) {
131
+ changes.push(e);
132
+ }
133
+ }
134
+ return changes;
135
+ }
136
+ getEntities(entityStates) {
137
+ let filter = getFilter(entityStates);
138
+ return this._entities.filter(filter);
139
+ }
140
+ _checkOperation(operationName) {
141
+ this._entities.forEach(function (entity) {
142
+ entity && entity.entityAspect._checkOperation(operationName);
143
+ });
144
+ // for chaining;
145
+ return this;
146
+ }
147
+ // do not expose this method. It is doing a special purpose INCOMPLETE fast detach operation
148
+ // just for the entityManager clear method - the entityGroup will be in an inconsistent state
149
+ // after this op, which is ok because it will be thrown away.
150
+ // TODO: rename this to be clear that it is UNSAFE...
151
+ _clear() {
152
+ this._entities.forEach(function (entity) {
153
+ if (entity != null) {
154
+ entity.entityAspect._detach();
155
+ }
156
+ });
157
+ this._entities = null;
158
+ this._indexMap = null;
159
+ this._emptyIndexes = null;
160
+ this._changedEntities = null;
161
+ }
162
+ _updateFkVal(fkProp, oldValue, newValue) {
163
+ let fkPropName = fkProp.name;
164
+ this._entities.forEach(function (entity) {
165
+ if (entity != null) {
166
+ if (entity.getProperty(fkPropName) === oldValue) {
167
+ entity.setProperty(fkPropName, newValue);
168
+ }
169
+ }
170
+ });
171
+ }
172
+ _fixupKey(tempValue, realValue) {
173
+ // Single part keys appear directly in the map. Both values arrive from the server's
174
+ // keyMappings and are usually numbers, where the map is keyed by string - the object literal
175
+ // this used to be coerced them on the way in and a `Map` does not.
176
+ let tempKey = String(tempValue);
177
+ let ix = this._indexMap.get(tempKey);
178
+ if (ix === undefined) {
179
+ throw new Error("Internal Error in key fixup - unable to locate entity");
180
+ }
181
+ let entity = this._entities[ix];
182
+ let keyPropName = entity.entityType.keyProperties[0].name;
183
+ // fks on related entities will automatically get updated by this as well
184
+ entity.setProperty(keyPropName, realValue);
185
+ entity.entityAspect.hasTempKey = undefined; // not delete; see attachEntity above
186
+ releaseTempKeyValue(this.entityManager, entity.entityType, tempValue);
187
+ this._indexMap.delete(tempKey);
188
+ this._indexMap.set(String(realValue), ix);
189
+ }
190
+ _replaceKey(oldKey, newKey) {
191
+ let ix = this._indexMap.get(oldKey._keyInGroup);
192
+ this._indexMap.delete(oldKey._keyInGroup);
193
+ this._indexMap.set(newKey._keyInGroup, ix);
194
+ }
195
+ }
196
+ function getFilter(entityStates) {
197
+ if (entityStates.length === 0) {
198
+ return function (e) {
199
+ return !!e;
200
+ };
201
+ }
202
+ else if (entityStates.length === 1) {
203
+ let entityState = entityStates[0];
204
+ return function (e) {
205
+ return !!e && e.entityAspect.entityState === entityState;
206
+ };
207
+ }
208
+ else {
209
+ return function (e) {
210
+ return !!e && -1 !== entityStates.indexOf(e.entityAspect.entityState);
211
+ };
212
+ }
213
+ }
214
+ // do not expose EntityGroup - internal only
215
+ // Keep the manager's KeyGenerator's record of temporary key values in step with the entities that
216
+ // hold them: see KeyGenerator._releaseTempKeyValue and _reserveTempKeyValue. A generator passed as
217
+ // `keyGeneratorCtor` need not extend KeyGenerator, hence the optional calls.
218
+ function releaseTempKeyValue(em, entityType, value) {
219
+ em.keyGenerator?._releaseTempKeyValue?.(entityType, value);
220
+ }
221
+ function reserveTempKeyValue(em, entityType, value) {
222
+ em.keyGenerator?._reserveTempKeyValue?.(entityType, value);
223
+ }
224
+ //# sourceMappingURL=entity-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-group.js","sourceRoot":"","sources":["../../src/entity/entity-group.ts"],"names":[],"mappings":"AACA,OAA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AEF;AAED,SAAS,SAAS,CAAC,YAA2B;IAC5C,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAS;YACxB,OAAO,CAAC,CAAC,CAAC,CAAC;QACb,CAAC,CAAC;IACJ,CAAC;SAAM,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,IAAI,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAClC,OAAO,UAAU,CAAS;YACxB,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,WAAW,KAAK,WAAW,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,UAAU,CAAS;YACxB,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QACxE,CAAC,CAAC;IACJ,CAAC;AACH,CAAC;AAGD,4CAA4C;AAI5C,kGAAkG;AAClG,mGAAmG;AACnG,6EAA6E;AAE7E,SAAS,mBAAmB,CAAC,EAAiB,EAAE,UAAsB,EAAE,KAAU;IAC/E,EAAE,CAAC,YAAoB,EAAE,oBAAoB,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,mBAAmB,CAAC,EAAiB,EAAE,UAAsB,EAAE,KAAU;IAC/E,EAAE,CAAC,YAAoB,EAAE,oBAAoB,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACtE,CAAC","sourcesContent":["import { Entity } from './entity-aspect.js';\r\nimport { EntityType, DataProperty } from '../metadata/entity-metadata.js';\r\nimport { EntityKey } from './entity-key.js';\r\nimport { EntityState } from './entity-state.js';\r\nimport { EntityManager } from '../manager/entity-manager.js';\r\nimport { MergeStrategy } from '../query/query-options.js';\r\n\r\n/** @hidden @internal */\r\nexport class EntityGroup {\r\n entityManager: EntityManager;\r\n entityType: EntityType;\r\n /**\r\n * Key string -> index into `_entities`. A `Map` and not an object literal: an object inherits\r\n * `Object.prototype`, so an entity whose string key happened to be `__proto__` was attached but\r\n * could never be found again - the assignment ran the inherited setter and stored nothing.\r\n * Keys here are always strings (`EntityKey.createKeyString` joins the values), which an object\r\n * did for us by coercion and a `Map` does not - see `_fixupKey`.\r\n */\r\n _indexMap: Map<string, number>;\r\n _entities: (Entity | null)[];\r\n _emptyIndexes: number[];\r\n /**\r\n * The entities in this group whose state is not Unchanged, maintained by `EntityAspect`'s\r\n * `entityState` setter. `hasChanges` is then a size check rather than a scan of the group,\r\n * which is what made detaching, accepting or rejecting n changed entities quadratic.\r\n */\r\n _changedEntities: Set<Entity>;\r\n\r\n constructor(entityManager: EntityManager, entityType: EntityType) {\r\n this.entityManager = entityManager;\r\n this.entityType = entityType;\r\n // freeze the entityType after the first instance of this type is either created or queried.\r\n this.entityType.isFrozen = true;\r\n this._indexMap = new Map();\r\n this._entities = [];\r\n this._emptyIndexes = [];\r\n this._changedEntities = new Set();\r\n }\r\n\r\n\r\n attachEntity(entity: Entity, entityState: EntityState, mergeStrategy?: MergeStrategy) {\r\n // entity should already have an aspect.\r\n let aspect = entity.entityAspect;\r\n\r\n if (!aspect._initialized) {\r\n this.entityType._initializeInstance(entity);\r\n }\r\n // Assigned, not deleted. Deleting an own property changes the object shape, and this runs\r\n // for every entity attached - see \"delete on a hot path\" in CHANGES-DEV.md.\r\n aspect._initialized = undefined;\r\n\r\n let keyInGroup = aspect.getKey()._keyInGroup;\r\n let ix = this._indexMap.get(keyInGroup);\r\n if (ix !== undefined) {\r\n // safecast because key was found not ix will not return a null\r\n let targetEntity = this._entities[ix] as Entity;\r\n let targetEntityState = targetEntity.entityAspect.entityState;\r\n let wasUnchanged = targetEntityState.isUnchanged();\r\n if (targetEntity === entity) {\r\n aspect.entityState = entityState;\r\n } else if (mergeStrategy === MergeStrategy.Disallowed) {\r\n throw new Error(\"A MergeStrategy of 'Disallowed' does not allow you to attach an entity when an entity with the same key is already attached: \" + aspect.getKey());\r\n } else if (mergeStrategy === MergeStrategy.OverwriteChanges || (mergeStrategy === MergeStrategy.PreserveChanges && wasUnchanged)) {\r\n // unwrapInstance returns an entity with server side property names - so we need to use DataProperty.getRawValueFromServer these when we apply\r\n // the property values back to the target.\r\n let rawServerEntity = this.entityManager.helper.unwrapInstance(entity);\r\n this.entityType._updateTargetFromRaw(targetEntity, rawServerEntity, DataProperty.getRawValueFromServer);\r\n targetEntity.entityAspect.setEntityState(entityState);\r\n }\r\n return targetEntity;\r\n } else {\r\n if (this._emptyIndexes.length === 0) {\r\n ix = this._entities.push(entity) - 1;\r\n } else {\r\n ix = this._emptyIndexes.pop()!;\r\n this._entities[ix] = entity;\r\n }\r\n this._indexMap.set(keyInGroup, ix);\r\n // The group has to be in place before the state is: the `entityState` setter is what puts\r\n // this entity into `_changedEntities`, and it needs to know which group to put it in.\r\n aspect.entityGroup = this;\r\n aspect.entityManager = this.entityManager;\r\n aspect.entityState = entityState;\r\n if (aspect.hasTempKey) reserveTempKeyValue(this.entityManager, entity.entityType, aspect.getKey().values[0]);\r\n return entity;\r\n }\r\n }\r\n\r\n detachEntity(entity: Entity) {\r\n // by this point we have already determined that this entity\r\n // belongs to this group.\r\n let aspect = entity.entityAspect;\r\n let keyInGroup = aspect.getKey()._keyInGroup;\r\n let ix = this._indexMap.get(keyInGroup);\r\n if (ix === undefined) {\r\n // shouldn't happen.\r\n throw new Error(\"internal error - entity cannot be found in group\");\r\n }\r\n this._indexMap.delete(keyInGroup);\r\n this._changedEntities.delete(entity);\r\n this._emptyIndexes.push(ix);\r\n this._entities[ix] = null;\r\n if (aspect.hasTempKey) releaseTempKeyValue(this.entityManager, entity.entityType, aspect.getKey().values[0]);\r\n return entity;\r\n }\r\n\r\n\r\n // returns entity based on an entity key defined either as an array of key values or an EntityKey\r\n findEntityByKey(entityKey: EntityKey) {\r\n let keyInGroup: string;\r\n if (entityKey instanceof EntityKey) {\r\n keyInGroup = entityKey._keyInGroup;\r\n } else {\r\n keyInGroup = EntityKey.createKeyString(entityKey);\r\n }\r\n let ix = this._indexMap.get(keyInGroup);\r\n // can't use just (ix) below because 0 is valid\r\n let r = (ix !== undefined) ? this._entities[ix] : undefined;\r\n // coerce null to undefined\r\n return r == null ? undefined : r;\r\n }\r\n\r\n hasChanges() {\r\n return this._changedEntities.size > 0;\r\n }\r\n\r\n getChanges() {\r\n // Deliberately still a scan of `_entities` rather than a copy of `_changedEntities`: this is\r\n // what fixes the order changed entities are saved in, and `_entities` order is attach order\r\n // where a Set's is the order each entity first became dirty.\r\n let entities = this._entities;\r\n let unchanged = EntityState.Unchanged;\r\n let changes: Entity[] = [];\r\n for (let i = 0, len = entities.length; i < len; i++) {\r\n let e = entities[i];\r\n if (e && e.entityAspect.entityState !== unchanged) {\r\n changes.push(e);\r\n }\r\n }\r\n return changes;\r\n }\r\n\r\n getEntities(entityStates: EntityState[]) {\r\n let filter = getFilter(entityStates);\r\n return this._entities.filter(filter) as Entity[];\r\n }\r\n\r\n _checkOperation(operationName: string) {\r\n this._entities.forEach(function (entity) {\r\n entity && entity.entityAspect._checkOperation(operationName);\r\n });\r\n // for chaining;\r\n return this;\r\n }\r\n\r\n // do not expose this method. It is doing a special purpose INCOMPLETE fast detach operation\r\n // just for the entityManager clear method - the entityGroup will be in an inconsistent state\r\n // after this op, which is ok because it will be thrown away.\r\n // TODO: rename this to be clear that it is UNSAFE...\r\n _clear() {\r\n this._entities.forEach(function (entity) {\r\n if (entity != null) {\r\n entity.entityAspect._detach();\r\n }\r\n });\r\n (this as any)._entities = null;\r\n (this as any)._indexMap = null;\r\n (this as any)._emptyIndexes = null;\r\n (this as any)._changedEntities = null;\r\n }\r\n\r\n _updateFkVal(fkProp: DataProperty, oldValue: any, newValue: any) {\r\n let fkPropName = fkProp.name;\r\n this._entities.forEach(function (entity) {\r\n if (entity != null) {\r\n if (entity.getProperty(fkPropName) === oldValue) {\r\n entity.setProperty(fkPropName, newValue);\r\n }\r\n }\r\n });\r\n }\r\n\r\n _fixupKey(tempValue: any, realValue: any) {\r\n // Single part keys appear directly in the map. Both values arrive from the server's\r\n // keyMappings and are usually numbers, where the map is keyed by string - the object literal\r\n // this used to be coerced them on the way in and a `Map` does not.\r\n let tempKey = String(tempValue);\r\n let ix = this._indexMap.get(tempKey);\r\n if (ix === undefined) {\r\n throw new Error(\"Internal Error in key fixup - unable to locate entity\");\r\n }\r\n let entity = this._entities[ix] as Entity;\r\n let keyPropName = entity.entityType.keyProperties[0].name;\r\n // fks on related entities will automatically get updated by this as well\r\n entity.setProperty(keyPropName, realValue);\r\n entity.entityAspect.hasTempKey = undefined; // not delete; see attachEntity above\r\n releaseTempKeyValue(this.entityManager, entity.entityType, tempValue);\r\n this._indexMap.delete(tempKey);\r\n this._indexMap.set(String(realValue), ix);\r\n }\r\n\r\n _replaceKey(oldKey: EntityKey, newKey: EntityKey) {\r\n let ix = this._indexMap.get(oldKey._keyInGroup)!;\r\n this._indexMap.delete(oldKey._keyInGroup);\r\n this._indexMap.set(newKey._keyInGroup, ix);\r\n }\r\n\r\n}\r\n\r\nfunction getFilter(entityStates: EntityState[]) {\r\n if (entityStates.length === 0) {\r\n return function (e: Entity) {\r\n return !!e;\r\n };\r\n } else if (entityStates.length === 1) {\r\n let entityState = entityStates[0];\r\n return function (e: Entity) {\r\n return !!e && e.entityAspect.entityState === entityState;\r\n };\r\n } else {\r\n return function (e: Entity) {\r\n return !!e && -1 !== entityStates.indexOf(e.entityAspect.entityState);\r\n };\r\n }\r\n}\r\n\r\n\r\n// do not expose EntityGroup - internal only\r\n\r\n\r\n\r\n// Keep the manager's KeyGenerator's record of temporary key values in step with the entities that\r\n// hold them: see KeyGenerator._releaseTempKeyValue and _reserveTempKeyValue. A generator passed as\r\n// `keyGeneratorCtor` need not extend KeyGenerator, hence the optional calls.\r\n\r\nfunction releaseTempKeyValue(em: EntityManager, entityType: EntityType, value: any) {\r\n (em.keyGenerator as any)?._releaseTempKeyValue?.(entityType, value);\r\n}\r\n\r\nfunction reserveTempKeyValue(em: EntityManager, entityType: EntityType, value: any) {\r\n (em.keyGenerator as any)?._reserveTempKeyValue?.(entityType, value);\r\n}\r\n"]}