breeze-client 2.2.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +63 -94
  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,1193 @@
1
+ import { ErrorCallback } from '../core/core.js';
2
+ import { BreezeEvent } from '../core/event.js';
3
+ import { DataType } from './data-type.js';
4
+ import { Entity, StructuralObject } from '../entity/entity-aspect.js';
5
+ import { EntityKey } from '../entity/entity-key.js';
6
+ import { Validator } from '../validation/validate.js';
7
+ import { BreezeEnum } from '../core/enum.js';
8
+ import { DataService } from './data-service.js';
9
+ import { NamingConvention } from './naming-convention.js';
10
+ import { LocalQueryComparisonOptions } from './local-query-comparison-options.js';
11
+ /** A property of an {@link EntityType} or {@link ComplexType}: either a {@link DataProperty} or a
12
+ {@link NavigationProperty}. Returned by methods such as {@link EntityType.getProperty}; test
13
+ `isDataProperty` or `isNavigationProperty` to tell which. */
14
+ export type EntityProperty = DataProperty | NavigationProperty;
15
+ /** A type held by a {@link MetadataStore}: either an {@link EntityType} or a {@link ComplexType}.
16
+ Returned by {@link MetadataStore.getStructuralType}; test `isComplexType` to tell which. */
17
+ export type StructuralType = EntityType | ComplexType;
18
+ /** Configuration info to be passed to the {@link MetadataStore} constructor */
19
+ export interface MetadataStoreConfig {
20
+ /** The {@link NamingConvention} associated with this MetadataStore. */
21
+ namingConvention?: NamingConvention;
22
+ /** The {@link LocalQueryComparisonOptions} associated with this MetadataStore. */
23
+ localQueryComparisonOptions?: LocalQueryComparisonOptions;
24
+ /** Sets {@link MetadataStore.serializerFn}, the default serializer for every type in the store. */
25
+ serializerFn?: (prop: EntityProperty, val: any) => any;
26
+ /** Sets {@link MetadataStore.name}. */
27
+ name?: string;
28
+ }
29
+ /** The argument passed to subscribers of the {@link MetadataStore.metadataFetched} event. */
30
+ export interface MetadataFetchedEventArgs {
31
+ /** The MetadataStore into which the metadata was fetched. */
32
+ metadataStore: MetadataStore;
33
+ /** The {@link DataService} the metadata was fetched from. */
34
+ dataService: DataService | string;
35
+ /** The metadata as the server returned it, parsed from JSON. It has already been imported into
36
+ the store when the event fires. */
37
+ rawMetadata: any;
38
+ }
39
+ /**
40
+ An instance of the MetadataStore contains all of the metadata about a collection of {@link EntityType}'s.
41
+ MetadataStores may be shared across {@link EntityManager}'s. If an EntityManager is created without an
42
+ explicit MetadataStore, the MetadataStore from the MetadataStore.defaultInstance property will be used.
43
+ */
44
+ export declare class MetadataStore {
45
+ /** The version of any MetadataStores created by this class */
46
+ static metadataVersion: string;
47
+ /** An optional name for this MetadataStore, set with {@link MetadataStore.setProperties}.
48
+ {@link MetadataStore.exportMetadata} writes it, but {@link MetadataStore.importMetadata} does not
49
+ restore it. When {@link EntityManager.exportEntities} leaves out the metadata it records this name,
50
+ and {@link EntityManager.importEntities} passes it to {@link ImportConfig.metadataVersionFn}. */
51
+ name: string;
52
+ /** The {@link DataService}s this store has metadata for, one per service name. Entries are added by
53
+ {@link MetadataStore.fetchMetadata}, {@link MetadataStore.importMetadata} and
54
+ {@link MetadataStore.addDataService}. __Read Only__ */
55
+ dataServices: DataService[];
56
+ /** The {@link NamingConvention} associated with this MetadataStore. __Read Only__ */
57
+ namingConvention: NamingConvention;
58
+ /** The {@link LocalQueryComparisonOptions} associated with this MetadataStore. __Read Only__ */
59
+ localQueryComparisonOptions: LocalQueryComparisonOptions;
60
+ /** A function that customizes how data property values are serialized, both when entities are
61
+ sent to the server in a save and when {@link EntityManager.exportEntities} writes them. It is called
62
+ as `serializerFn(property, value)`; its return value is used in place of `value`, and returning
63
+ `undefined` leaves the property out. Applies to every type in the store that has no
64
+ `serializerFn` of its own (see {@link EntityType.serializerFn}). */
65
+ serializerFn?: (prop: EntityProperty, val: any) => any;
66
+ /**
67
+ An {@link BreezeEvent} that fires after a MetadataStore has completed fetching metadata from a remote service.
68
+
69
+ @eventArgs -
70
+ - metadataStore - The MetadataStore into which the metadata was fetched.
71
+ - dataService - The {@link DataService} that metadata was fetched from.
72
+ - rawMetadata - {Object} The raw metadata returned from the service. (It will have already been processed by this point).
73
+ ```ts
74
+ const ms = myEntityManager.metadataStore;
75
+ ms.metadataFetched.subscribe(args => {
76
+ const metadataStore = args.metadataStore;
77
+ const dataService = args.dataService;
78
+ });
79
+ ```
80
+ @event
81
+ */
82
+ metadataFetched: BreezeEvent<MetadataFetchedEventArgs>;
83
+ /**
84
+ Constructs a new MetadataStore.
85
+
86
+ ```ts
87
+ const ms = new MetadataStore();
88
+ ```
89
+
90
+ The store can then be associated with an EntityManager
91
+ ```ts
92
+ const entityManager = new EntityManager({
93
+ serviceName: "breeze/NorthwindIBModel",
94
+ metadataStore: ms
95
+ });
96
+ ```
97
+
98
+ or for an existing EntityManager
99
+ ```ts
100
+ // Assume em1 is an existing EntityManager
101
+ em1.setProperties({ metadataStore: ms });
102
+ ```
103
+
104
+ @param config - Configuration settings .
105
+ - namingConvention - (default=NamingConvention.defaultInstance) NamingConvention to be used in mapping property names
106
+ between client and server. Uses the NamingConvention.defaultInstance if not specified.
107
+ - localQueryComparisonOptions - (default=LocalQueryComparisonOptions.defaultInstance) The LocalQueryComparisonOptions to be
108
+ used when performing "local queries" in order to match the semantics of queries against a remote service. Options passed
109
+ here, or made the default with setAsDefault(), win over any that imported metadata names.
110
+ - serializerFn - A function that is used to mediate the serialization of instances of this type.
111
+ */
112
+ constructor(config?: MetadataStoreConfig);
113
+ /** __Dev Only__ - for use when writing a {@link DataServiceAdapter} or {@link JsonResultsAdapter}.
114
+ Converts a type name as a server sends it, such as the .NET `"Northwind.Models.Customer, Northwind"`,
115
+ into Breeze's qualified form, `"Customer:#Northwind.Models"`. Results are cached; a null or empty
116
+ name is returned unchanged. */
117
+ static normalizeTypeName: any;
118
+ /**
119
+ General purpose property set method
120
+
121
+ ```ts
122
+ // assume em1 is an EntityManager containing a number of existing entities.
123
+ em1.metadataStore.setProperties({
124
+ name: "Northwind v6.1.3",
125
+ serializerFn: (prop, value) => prop.isUnmapped ? undefined : value
126
+ });
127
+ ```
128
+ @param config - An object containing the selected properties and values to set.
129
+ */
130
+ setProperties(config: MetadataStoreConfig): void;
131
+ /**
132
+ Adds a DataService to this MetadataStore. If a DataService with the same serviceName is already
133
+ in the MetadataStore an exception will be thrown.
134
+ @param dataService - The {@link DataService} to add
135
+ @param shouldOverwrite - (default=false) Permit overwrite of existing DataService rather than throw exception
136
+ */
137
+ addDataService(dataService: DataService, shouldOverwrite?: boolean): void;
138
+ /**
139
+ Adds an EntityType or ComplexType to this MetadataStore. Properties can still be added to the
140
+ type afterwards, until the first entity of that type is attached to an EntityManager - after
141
+ that the type is frozen.
142
+ @param stype - The EntityType or ComplexType to add
143
+ */
144
+ addEntityType(stype: StructuralType | EntityTypeConfig | ComplexTypeConfig): void;
145
+ /**
146
+ Exports this MetadataStore to a serialized string appropriate for local storage. This operation is also called
147
+ internally when exporting an EntityManager.
148
+ ```ts
149
+ // assume ms is a previously created MetadataStore
150
+ const metadataAsString = ms.exportMetadata();
151
+ window.localStorage.setItem("metadata", metadataAsString);
152
+ // and later, usually in a different session imported
153
+ const metadataFromStorage = window.localStorage.getItem("metadata");
154
+ const newMetadataStore = new MetadataStore();
155
+ newMetadataStore.importMetadata(metadataFromStorage);
156
+ ```
157
+ @returns A serialized version of this MetadataStore that may be stored locally and later restored.
158
+ */
159
+ exportMetadata(): string;
160
+ /**
161
+ Imports a previously exported serialized MetadataStore into this MetadataStore.
162
+
163
+ ```ts
164
+ // assume ms is a previously created MetadataStore
165
+ const metadataAsString = ms.exportMetadata();
166
+ window.localStorage.setItem("metadata", metadataAsString);
167
+ // and later, usually in a different session
168
+ const metadataFromStorage = window.localStorage.getItem("metadata");
169
+ const newMetadataStore = new MetadataStore();
170
+ newMetadataStore.importMetadata(metadataFromStorage);
171
+ ```
172
+
173
+ A type that is already in this store is left as it is unless 'allowMerge' is set, so importing the same metadata
174
+ twice is harmless. A type that is not in the store is created, with or without 'allowMerge', and its metadata must
175
+ include 'dataProperties'. The 'localQueryComparisonOptions' the metadata names are adopted only by an empty store
176
+ whose own options were not chosen on the client (see the constructor).
177
+ @param exportedMetadata - A previously exported MetadataStore.
178
+ @param allowMerge - Allows custom metadata to be merged into existing metadata types.
179
+ @returns This MetadataStore.
180
+ @chainable
181
+ */
182
+ importMetadata(exportedMetadata: string | Object, allowMerge?: boolean): this;
183
+ /**
184
+ Creates a new MetadataStore from a previously exported serialized MetadataStore
185
+ ```ts
186
+ // assume ms is a previously created MetadataStore
187
+ const metadataAsString = ms.exportMetadata();
188
+ window.localStorage.setItem("metadata", metadataAsString);
189
+ // and later, usually in a different session
190
+ const metadataFromStorage = window.localStorage.getItem("metadata");
191
+ const newMetadataStore = MetadataStore.importMetadata(metadataFromStorage);
192
+ ```
193
+ @param exportedString - A previously exported MetadataStore.
194
+ @returns A new MetadataStore.
195
+ */
196
+ static importMetadata(exportedString: string): MetadataStore;
197
+ /**
198
+ Returns whether Metadata has been retrieved for a specified service name.
199
+ ```ts
200
+ // Assume em1 is an existing EntityManager.
201
+ if (!em1.metadataStore.hasMetadataFor("breeze/NorthwindIBModel")) {
202
+ // do something interesting
203
+ }
204
+ ```
205
+ @param serviceName - The service name.
206
+ @returns Whether metadata has already been retrieved for the specified service name.
207
+ */
208
+ hasMetadataFor(serviceName: string): boolean;
209
+ /**
210
+ Returns the DataService for a specified service name
211
+ ```ts
212
+ // Assume em1 is an existing EntityManager.
213
+ const ds = em1.metadataStore.getDataService("breeze/NorthwindIBModel");
214
+ const adapterName = ds.adapterName; // may be null
215
+ ```
216
+ @param serviceName - The service name.
217
+ @returns The DataService with the specified name.
218
+ */
219
+ getDataService(serviceName: string): DataService;
220
+ fetchMetadata(dataService: string | DataService): Promise<any>;
221
+ /** @deprecated Await the returned promise instead of passing callbacks. */
222
+ fetchMetadata(dataService: string | DataService, callback?: (schema: any) => void, errorCallback?: ErrorCallback): Promise<any>;
223
+ /**
224
+ Used to register a constructor for an EntityType that is not known via standard Metadata discovery;
225
+ i.e. an unmapped type.
226
+ @param entityCtor - The constructor function for the 'unmapped' type.
227
+ @param interceptor - An interceptor function
228
+ */
229
+ trackUnmappedType(entityCtor: any, interceptor: any): void;
230
+ /**
231
+ Provides a mechanism to register a 'custom' constructor to be used when creating new instances
232
+ of the specified entity type. If this call is not made, a default constructor is created for
233
+ the entity as needed.
234
+ This call may be made before or after the corresponding EntityType has been discovered via
235
+ Metadata discovery.
236
+ ```ts
237
+ class Customer {
238
+ miscData = "asdf"; // an unmapped property
239
+ doFoo() {
240
+ // ...
241
+ }
242
+ }
243
+ // assume em1 is a preexisting EntityManager;
244
+ em1.metadataStore.registerEntityTypeCtor("Customer", Customer);
245
+ // any queries or createEntity calls from this point on will call the Customer constructor
246
+ // registered above.
247
+ ```
248
+ @param structuralTypeName - The name of the EntityType or ComplexType.
249
+ @param aCtor - The constructor for this EntityType or ComplexType; may be null if all you want to do is set the next parameter.
250
+ @param initFn - A function or the name of a function on the entity that is to be executed immediately after the entity has been created
251
+ and populated with any initial values. Called with 'initFn(entity)'
252
+ @param noTrackingFn - A function that is executed immediately after a noTracking entity has been created and whose return
253
+ value will be used in place of the noTracking entity.
254
+ */
255
+ registerEntityTypeCtor(structuralTypeName: string, aCtor?: any, initFn?: Function | string, noTrackingFn?: Function): void;
256
+ /**
257
+ Returns whether this MetadataStore contains any metadata yet.
258
+ ```ts
259
+ // assume em1 is a preexisting EntityManager;
260
+ if (em1.metadataStore.isEmpty()) {
261
+ // do something interesting
262
+ }
263
+ ```
264
+ */
265
+ isEmpty(): boolean;
266
+ getAsEntityType(type: string | (new () => Entity), okIfNotFound?: false): EntityType;
267
+ getAsEntityType(type: string | (new () => Entity), okIfNotFound: boolean): EntityType | null;
268
+ /**
269
+ Returns an {@link EntityType} or null given its name.
270
+ ```ts
271
+ // assume em1 is a preexisting EntityManager
272
+ const locType = em1.metadataStore.getAsComplexType("Location");
273
+ ```
274
+
275
+ or to throw an error if the type is not found
276
+ ```ts
277
+ const badType = em1.metadataStore.getAsComplexType("Foo", false);
278
+ // badType will not get set and an exception will be thrown.
279
+ ```
280
+ @param typeName - Either the fully qualified name or a short name may be used. If a short name is specified and multiple types share
281
+ that same short name an exception will be thrown.
282
+ @param okIfNotFound - (default=false) Whether to throw an error if the specified EntityType is not found.
283
+ @returns The EntityType. ComplexType or 'null' if not not found.
284
+ */
285
+ getAsComplexType(typeName: string, okIfNotFound?: boolean): ComplexType | null;
286
+ /**
287
+ Returns an {@link EntityType} or a {@link ComplexType} given its name.
288
+ @deprecated Misleading name: it returns an EntityType *or* a ComplexType. Use
289
+ {@link MetadataStore.getAsEntityType} or {@link MetadataStore.getAsComplexType} when you know
290
+ which kind you expect, and {@link MetadataStore.getStructuralType} when either will do.
291
+ @param typeName - Either the fully qualified name or a short name may be used. If a short name is specified and multiple types share
292
+ that same short name an exception will be thrown.
293
+ @param okIfNotFound - (default=false) Whether to throw an error if the specified EntityType is not found.
294
+ @returns The EntityType. ComplexType or 'null' if not not found.
295
+ */
296
+ getEntityType(typeName: string, okIfNotFound?: boolean): StructuralType | null;
297
+ /**
298
+ Returns an {@link EntityType} or a {@link ComplexType} given its name.
299
+ ```ts
300
+ // assume em1 is a preexisting EntityManager
301
+ const odType = em1.metadataStore.getStructuralType("OrderDetail");
302
+ ```
303
+
304
+ or to throw an error if the type is not found
305
+ ```ts
306
+ const badType = em1.metadataStore.getStructuralType("Foo", false);
307
+ // badType will not get set and an exception will be thrown.
308
+ ```
309
+ Prefer {@link MetadataStore.getAsEntityType} or {@link MetadataStore.getAsComplexType} when you
310
+ know which kind you expect. This is the lookup for when you do not.
311
+ @param typeName - Either the fully qualified name or a short name may be used. If a short name is specified and multiple types share
312
+ that same short name an exception will be thrown.
313
+ @param okIfNotFound - (default=false) Whether to throw an error if the specified EntityType is not found.
314
+ @returns The EntityType. ComplexType or 'null' if not not found.
315
+ */
316
+ getStructuralType(typeName: string, okIfNotFound?: boolean): StructuralType | null;
317
+ /**
318
+ Returns an array containing all of the {@link EntityType}s or {@link ComplexType}s in this MetadataStore.
319
+ ```ts
320
+ // assume em1 is a preexisting EntityManager
321
+ const allTypes = em1.metadataStore.getEntityTypes();
322
+ ```
323
+ */
324
+ getEntityTypes(): StructuralType[];
325
+ /**
326
+ Returns the navigation properties whose target {@link EntityType} has not been added to this store
327
+ yet, as one array per missing type. An empty result means every navigation property has been
328
+ resolved; useful for checking metadata that is built by hand or imported in pieces.
329
+ */
330
+ getIncompleteNavigationProperties(): NavigationProperty[][];
331
+ /**
332
+ Returns a fully qualified entityTypeName for a specified resource name. The reverse of this operation
333
+ can be obtained via the {@link EntityType.defaultResourceName} property
334
+ */
335
+ getEntityTypeNameForResourceName(resourceName: string): string;
336
+ /**
337
+ Associates a resourceName with an entityType.
338
+
339
+ This method is only needed in those cases where multiple resources return the same
340
+ entityType. In this case Metadata discovery will only determine a single resource name for
341
+ each entityType.
342
+ @param resourceName - The resource name
343
+ @param entityTypeOrName - If passing a string either the fully qualified name or a short name may be used. If a short name is specified and multiple types share
344
+ that same short name an exception will be thrown. If the entityType has not yet been discovered then a fully qualified name must be used.
345
+ */
346
+ setEntityTypeForResourceName(resourceName: string, entityTypeOrName: EntityType | string): void;
347
+ /** __Dev Only__ - for use when creating a new MetadataParserAdapter */
348
+ static parseTypeName(entityTypeName: string): {
349
+ /** The unqualified name, such as `"Customer"`. */
350
+ shortTypeName: string;
351
+ /** The namespace, such as `"Northwind.Models"`; undefined if there is none. */
352
+ namespace: string | undefined;
353
+ /** The qualified name, such as `"Customer:#Northwind.Models"`. */
354
+ typeName: string;
355
+ };
356
+ /** __Dev Only__ - for use when creating a new MetadataParserAdapter */
357
+ static makeTypeHash(shortName: string, ns?: string): {
358
+ /** The unqualified name, such as `"Customer"`. */
359
+ shortTypeName: string;
360
+ /** The namespace, such as `"Northwind.Models"`; undefined if there is none. */
361
+ namespace: string | undefined;
362
+ /** The qualified name, such as `"Customer:#Northwind.Models"`. */
363
+ typeName: string;
364
+ };
365
+ }
366
+ /** Configuration info to be passed to the {@link EntityType} constructor */
367
+ export interface EntityTypeConfig {
368
+ /** The unqualified name of the type, such as `"Customer"`. Required, although the interface marks it optional. */
369
+ shortName?: string;
370
+ /** The namespace of the type. Defaults to `""`. The type's {@link EntityType.name} is `shortName:#namespace`. */
371
+ namespace?: string;
372
+ /** The name, short or qualified, of the base EntityType this type inherits from. The base type must
373
+ already be in the {@link MetadataStore} when this type is added to it. */
374
+ baseTypeName?: string;
375
+ /** Whether the type is abstract, i.e. only its subtypes have instances. An abstract type may be added to
376
+ a MetadataStore without key properties. Defaults to `false`. */
377
+ isAbstract?: boolean;
378
+ /** How keys of new entities are generated. Defaults to {@link AutoGeneratedKeyType.None}, in which case a
379
+ subtype takes its base type's setting. */
380
+ autoGeneratedKeyType?: AutoGeneratedKeyType;
381
+ /** The resource name used to query this type when no other is given; see
382
+ {@link EntityType.defaultResourceName}. If omitted, a subtype takes its base type's. */
383
+ defaultResourceName?: string;
384
+ /** The type's data properties: an object whose keys are property names and whose values are
385
+ {@link DataPropertyConfig} objects, or an array of {@link DataProperty} instances or of
386
+ DataPropertyConfig objects that each include a `name`. */
387
+ dataProperties?: DataProperty[] | DataPropertyConfig[] | Object;
388
+ /** The type's navigation properties: an object whose keys are property names and whose values are
389
+ {@link NavigationPropertyConfig} objects, or an array of {@link NavigationProperty} instances or of
390
+ NavigationPropertyConfig objects that each include a `name`. */
391
+ navigationProperties?: NavigationProperty[] | NavigationPropertyConfig[] | Object;
392
+ /** Sets {@link EntityType.serializerFn}. */
393
+ serializerFn?: (prop: EntityProperty, val: any) => any;
394
+ /** Sets {@link EntityType.custom}. */
395
+ custom?: any;
396
+ }
397
+ /** Configuration info to be passed to the {@link EntityType.setProperties} method */
398
+ export interface EntityTypeSetConfig {
399
+ /** Sets {@link EntityType.autoGeneratedKeyType}. */
400
+ autoGeneratedKeyType?: AutoGeneratedKeyType;
401
+ /** Sets {@link EntityType.defaultResourceName}. */
402
+ defaultResourceName?: string;
403
+ /** Sets {@link EntityType.serializerFn}. */
404
+ serializerFn?: (prop: EntityProperty, val: any) => any;
405
+ /** Sets {@link EntityType.custom}. */
406
+ custom?: any;
407
+ }
408
+ /** Container for all of the metadata about a specific type of Entity.
409
+ */
410
+ export declare class EntityType {
411
+ /** Always false for an EntityType. */
412
+ isComplexType: boolean;
413
+ /** The {@link MetadataStore} that contains this EntityType. __Read Only__ */
414
+ metadataStore: MetadataStore;
415
+ /** The DataProperties (see {@link DataProperty} associated with this EntityType. __Read Only__ */
416
+ dataProperties: DataProperty[];
417
+ /** The NavigationProperties (see {@link NavigationProperty} associated with this EntityType. __Read Only__ */
418
+ navigationProperties: NavigationProperty[];
419
+ /**
420
+ The DataProperties associated with this EntityType that make up it's {@link EntityKey}. __Read Only__ */
421
+ keyProperties: DataProperty[];
422
+ /** The DataProperties associated with this EntityType that are foreign key properties. __Read Only__ */
423
+ foreignKeyProperties: DataProperty[];
424
+ /** The foreign key DataProperties on *other* EntityTypes that refer to this EntityType. When an
425
+ entity's key changes, such as when a temporary key is replaced on save, Breeze uses these to update
426
+ the foreign keys of cached entities it cannot reach through a navigation property. __Read Only__ */
427
+ inverseForeignKeyProperties: DataProperty[];
428
+ /** The DataProperties associated with this EntityType that are concurrency properties. __Read Only__ */
429
+ concurrencyProperties: DataProperty[];
430
+ /** The DataProperties for this EntityType that contain instances of a {@link ComplexType}. __Read Only__ */
431
+ complexProperties: DataProperty[];
432
+ /** The DataProperties associated with this EntityType that are not mapped to any backend datastore. These are effectively free standing
433
+ properties. __Read Only__ */
434
+ unmappedProperties: DataProperty[];
435
+ /** The fully qualified name of this EntityType. __Read Only__ */
436
+ name: string;
437
+ /** The short, unqualified, name for this EntityType. __Read Only__ */
438
+ shortName: string;
439
+ /** The namespace for this EntityType. __Read Only__ */
440
+ namespace: string;
441
+ /** The name of this EntityType's base EntityType (if any) */
442
+ baseTypeName?: string;
443
+ /** The base EntityType (if any) for this EntityType. __Read Only__ */
444
+ baseEntityType: EntityType;
445
+ /** The EntityTypes that derive directly from this one. See {@link EntityType.getSelfAndSubtypes} for
446
+ the whole hierarchy. __Read Only__ */
447
+ subtypes: EntityType[];
448
+ /** Whether this EntityType is abstract. __Read Only__ */
449
+ isAbstract: boolean;
450
+ /** Whether this EntityType is anonymous. Anonymous types will never be communicated to or from the server. They are purely for
451
+ client side use and are given an automatically generated name. __Read Only__ */
452
+ isAnonymous: boolean;
453
+ /** Whether this EntityType has been 'frozen'. EntityTypes become frozen after the first instance
454
+ of that type has been created and attached to an EntityManager. */
455
+ isFrozen: boolean;
456
+ /** The {@link AutoGeneratedKeyType} for this EntityType. __Read Only__ */
457
+ autoGeneratedKeyType: AutoGeneratedKeyType;
458
+ /** The default resource name associated with this EntityType. An EntityType may be queried via a variety of 'resource names' but this one
459
+ is used as the default when no resource name is provided. This will occur when calling {@link EntityAspect.loadNavigationProperty}
460
+ or when executing any {@link EntityQuery} that was created via an {@link EntityKey}. __Read Only__ */
461
+ defaultResourceName: string;
462
+ /** A function that is used to customize the serialization of any EntityProperties of this type. */
463
+ serializerFn?: (prop: EntityProperty, val: any) => any;
464
+ /** A free form object that can be used to define any custom metadata for this EntityType. __Read Only__ */
465
+ custom?: any;
466
+ /** The entity level validators associated with this EntityType. Validators can be added and
467
+ removed from this collection. __Read Only__. */
468
+ validators: Validator[];
469
+ /** Not used by breeze-client 3: always an empty array. In 2.x the CSDL metadata parser recorded
470
+ data types it did not recognize here; v3 reports them with `console.warn` instead. */
471
+ warnings: any[];
472
+ /** The function, or the name of a method on the entity, that is called with each entity of this type
473
+ once it has been created and populated, whether by {@link EntityType.createEntity} or from query
474
+ results. A base type's `initFn` runs first. Set from the `initFn` argument of
475
+ {@link MetadataStore.registerEntityTypeCtor}; applications set it there rather than here. */
476
+ initFn?: Function | string;
477
+ /** The function that a query with {@link EntityQuery.noTracking} enabled calls for each result of this
478
+ type, as `noTrackingFn(node, entityType)`; its return value replaces the result. Set from the
479
+ `noTrackingFn` argument of {@link MetadataStore.registerEntityTypeCtor}; applications set it there
480
+ rather than here. */
481
+ noTrackingFn?: Function;
482
+ /**
483
+ @deprecated Use {@link EntityType.getCtor} instead.
484
+ */
485
+ getEntityCtor: (forceRefresh?: boolean) => {
486
+ new (): StructuralObject;
487
+ };
488
+ /** EntityType constructor
489
+ ```ts
490
+ const entityType = new EntityType({
491
+ shortName: "person",
492
+ namespace: "myAppNamespace"
493
+ });
494
+ ```
495
+ @param config - Configuration settings or a MetadataStore. If this parameter is just a MetadataStore
496
+ then what will be created is an 'anonymous' type that will never be communicated to or from the server. It is purely for
497
+ client side use and will be given an automatically generated name. Normally, however, you will use a configuration object.
498
+ */
499
+ constructor(config: MetadataStore | EntityTypeConfig);
500
+ /**
501
+ General purpose property set method
502
+ ```ts
503
+ // assume em1 is an EntityManager containing a number of existing entities.
504
+ const custType = em1.metadataStore.getAsEntityType("Customer");
505
+ custType.setProperties({
506
+ autoGeneratedKeyType: AutoGeneratedKeyType.Identity,
507
+ defaultResourceName: "CustomersAndIncludedOrders"
508
+ });
509
+ ```
510
+ @param config - a configuration object
511
+ */
512
+ setProperties(config: EntityTypeSetConfig): void;
513
+ /**
514
+ Returns whether this type is a subtype of a specified type.
515
+ */
516
+ isSubtypeOf(entityType: EntityType): boolean;
517
+ /**
518
+ Returns an array containing this type and any/all subtypes of this type down thru the hierarchy.
519
+ */
520
+ getSelfAndSubtypes(): this[];
521
+ /**
522
+ Returns the entity level validators that apply to this type: its own {@link EntityType.validators}
523
+ followed by those of each base type. Returns a new array, so changing it does not change the type.
524
+ */
525
+ getAllValidators(): Validator[];
526
+ /**
527
+ Adds a {@link DataProperty} or a {@link NavigationProperty} to this EntityType.
528
+ ```ts
529
+ // assume myEntityType is a newly constructed EntityType.
530
+ myEntityType.addProperty(dataProperty1);
531
+ myEntityType.addProperty(dataProperty2);
532
+ myEntityType.addProperty(navigationProperty1);
533
+ ```
534
+ */
535
+ addProperty(property: EntityProperty): void;
536
+ /**
537
+ Creates a new entity of this type, detached: add it to a manager with {@link EntityManager.addEntity},
538
+ or use {@link EntityManager.createEntity}, which does both.
539
+ ```ts
540
+ // assume em1 is an EntityManager containing a number of existing entities.
541
+ const custType = em1.metadataStore.getAsEntityType("Customer");
542
+ const cust1 = custType.createEntity<Customer>({ companyName: "Acme" }); // Customer
543
+ em1.addEntity(cust1);
544
+ ```
545
+
546
+ `T` is the type you expect back. Nothing checks it - an EntityType knows its metadata, not your
547
+ class - and it defaults to `any`.
548
+ ```ts
549
+ const order = custType.createEntity<Order>(); // compiles, but creates a Customer
550
+ ```
551
+ @param initialValues - Property values to set immediately after creation.
552
+ @returns The new entity.
553
+ */
554
+ createEntity<T = any>(initialValues?: any): T;
555
+ /**
556
+ Returns the constructor for this EntityType.
557
+ @param forceRefresh - Whether to ignore any cached version of this constructor. (default == false)
558
+ @returns The constructor for this EntityType.
559
+ */
560
+ getCtor(forceRefresh?: boolean): {
561
+ new (): StructuralObject;
562
+ };
563
+ /**
564
+ Adds either an entity or property level validator to this EntityType.
565
+ ```ts
566
+ // assume em1 is an EntityManager containing a number of existing entities.
567
+ const custType = em1.metadataStore.getAsEntityType("Customer");
568
+ const countryProp = custType.getProperty("country");
569
+ const valFn = (v: string | null) => v == null || v.startsWith("US");
570
+ const countryValidator = new Validator("countryIsUS", valFn,
571
+ { displayName: "Country", messageTemplate: "'%displayName%' must start with 'US'" });
572
+ custType.addValidator(countryValidator, countryProp);
573
+ ```
574
+
575
+ This is the same as adding an entity level validator via the 'validators' property of DataProperty or NavigationProperty
576
+ ```ts
577
+ countryProp.validators.push(countryValidator);
578
+ ```
579
+
580
+ Entity level validators can also be added by omitting the 'property' parameter.
581
+ ```ts
582
+ custType.addValidator(someEntityLevelValidator);
583
+ ```
584
+
585
+ or
586
+ ```ts
587
+ custType.validators.push(someEntityLevelValidator);
588
+ ```
589
+ @param validator - Validator to add.
590
+ @param property - Property to add this validator to. If omitted, the validator is assumed to be an
591
+ entity level validator and is added to the EntityType's 'validators'.
592
+ */
593
+ addValidator(validator: Validator, property?: EntityProperty | string): void;
594
+ /**
595
+ Returns all of the properties ( dataProperties and navigationProperties) for this EntityType.
596
+ ```ts
597
+ // assume em1 is an EntityManager containing a number of existing entities.
598
+ const custType = em1.metadataStore.getAsEntityType("Customer");
599
+ const arrayOfProps = custType.getProperties();
600
+ ```
601
+ @returns An array of Data and Navigation properties.
602
+ */
603
+ getProperties(): EntityProperty[];
604
+ /**
605
+ Returns all of the property names ( for both dataProperties and navigationProperties) for this EntityType.
606
+ ```ts
607
+ // assume em1 is an EntityManager containing a number of existing entities.
608
+ const custType = em1.metadataStore.getAsEntityType("Customer");
609
+ const arrayOfPropNames = custType.getPropertyNames();
610
+ ```
611
+ */
612
+ getPropertyNames(): any[];
613
+ /**
614
+ Returns a data property with the specified name or null.
615
+ ```ts
616
+ // assume em1 is an EntityManager containing a number of existing entities.
617
+ const custType = em1.metadataStore.getAsEntityType("Customer");
618
+ const companyNameDataProp = custType.getDataProperty("companyName");
619
+ ```
620
+ @returns A DataProperty or null if not found.
621
+ */
622
+ getDataProperty(propertyName: string): DataProperty;
623
+ /**
624
+ Returns a navigation property with the specified name or null.
625
+ ```ts
626
+ // assume em1 is an EntityManager containing a number of existing entities.
627
+ const custType = em1.metadataStore.getAsEntityType("Customer");
628
+ const customerOrdersNavProp = custType.getNavigationProperty("orders");
629
+ ```
630
+ @returns A NavigationProperty or null if not found.
631
+ */
632
+ getNavigationProperty(propertyName: string): NavigationProperty;
633
+ /**
634
+ Returns either a DataProperty or a NavigationProperty with the specified name or null.
635
+
636
+ This method also accepts a '.' delimited property path and will return the 'property' at the
637
+ end of the path.
638
+ ```ts
639
+ const custType = em1.metadataStore.getAsEntityType("Customer");
640
+ const companyNameProp = custType.getProperty("companyName");
641
+ ```
642
+
643
+ This method can also walk a property path to return a property
644
+ ```ts
645
+ const orderDetailType = em1.metadataStore.getAsEntityType("OrderDetail");
646
+ const companyNameProp2 = orderDetailType.getProperty("order.customer.companyName");
647
+ // companyNameProp === companyNameProp2
648
+ ```
649
+ @param [throwIfNotFound=false] {Boolean} Whether to throw an exception if not found.
650
+ @returns A DataProperty or NavigationProperty or null if not found.
651
+ */
652
+ getProperty(propertyPath: string, throwIfNotFound?: boolean): EntityProperty | null;
653
+ /** Translates a client-side property path into the names the server uses, applying this type's
654
+ {@link NamingConvention} to each segment: with the default camelCase convention,
655
+ `"company.companyName"` becomes `"Company.CompanyName"`. A {@link UriBuilderAdapter} uses it to
656
+ write a query the server can read.
657
+ @param propertyPath - a path of property names separated by `.`
658
+ @param delimiter - what to join the server names with. Defaults to `.`
659
+ @returns The same path in server terms. */
660
+ clientPropertyPathToServer(propertyPath: string, delimiter?: string): string;
661
+ /** Builds the {@link EntityKey} for an entity still in its raw server form, before it has been
662
+ materialized. A {@link DataServiceAdapter} or {@link JsonResultsAdapter} uses it to find out whether
663
+ the cache already holds the entity a node describes.
664
+ @param rawEntity - the untyped node as it arrived from the server
665
+ @param rawValueFn - reads one {@link DataProperty} off that node. It is given the node and the
666
+ property, and is what knows whether the node is keyed by client or by server names
667
+ @returns The key, with each value parsed into its property's {@link DataType}. */
668
+ getEntityKeyFromRawEntity(rawEntity: any, rawValueFn: Function): EntityKey;
669
+ /**
670
+ Returns a string representation of this EntityType.
671
+ */
672
+ toString(): string;
673
+ /**
674
+ Returns this type's metadata as a plain object in Breeze's native JSON metadata format, leaving out
675
+ default values and empty arrays. Only the properties this type declares are included, not those it
676
+ inherits from a base type. `JSON.stringify` calls it when {@link MetadataStore.exportMetadata}
677
+ serializes the store.
678
+ */
679
+ toJSON(): Object;
680
+ }
681
+ /** Configuration info to be passed to the {@link ComplexType} constructor, or to
682
+ {@link MetadataStore.addEntityType} to create a ComplexType there. */
683
+ export interface ComplexTypeConfig {
684
+ /** The unqualified name of the type, such as `"Location"`. Required, although the interface marks it optional. */
685
+ shortName?: string;
686
+ /** The namespace of the type. Defaults to `""`. The type's {@link ComplexType.name} is `shortName:#namespace`. */
687
+ namespace?: string;
688
+ /** The type's data properties: an object whose keys are property names and whose values are
689
+ {@link DataPropertyConfig} objects, or an array of {@link DataProperty} instances or of
690
+ DataPropertyConfig objects that each include a `name`. */
691
+ dataProperties?: DataProperty[] | DataPropertyConfig[] | Object;
692
+ /** Set to `true` when passing this config to {@link MetadataStore.addEntityType}, which otherwise creates
693
+ an EntityType. The ComplexType constructor does not need it. */
694
+ isComplexType?: boolean;
695
+ /** Sets {@link ComplexType.custom}. */
696
+ custom?: any;
697
+ }
698
+ /** Container for all of the metadata about a specific type of Complex object.
699
+ ```ts
700
+ const complexType = new ComplexType({
701
+ shortName: "address",
702
+ namespace: "myAppNamespace"
703
+ });
704
+ ```
705
+ @param config - Configuration settings
706
+ */
707
+ export declare class ComplexType {
708
+ /** For polymorphic purpose only - always true here */
709
+ isComplexType: boolean;
710
+ /** The {@link MetadataStore} containing this ComplexType. */
711
+ metadataStore: MetadataStore;
712
+ /** The fully qualifed name of this ComplexType. __Read Only__ */
713
+ name: string;
714
+ /** The short, unqualified, name for this ComplexType. __Read Only__ */
715
+ shortName: string;
716
+ /** The namespace for this ComplexType. __Read Only__ */
717
+ namespace: string;
718
+ /** The DataProperties (see {@link DataProperty} associated with this ComplexType. __Read Only__ */
719
+ dataProperties: DataProperty[];
720
+ /** The DataProperties for this ComplexType that contain instances of a {@link ComplexType}. __Read Only__ */
721
+ complexProperties: DataProperty[];
722
+ /**
723
+ The entity level validators associated with this ComplexType. Validators can be added and
724
+ removed from this collection. __Read Only__ */
725
+ validators: Validator[];
726
+ /** For polymorphic purpose only - always empty here */
727
+ concurrencyProperties: DataProperty[];
728
+ /** The DataProperties associated with this ComplexType that are not mapped to any backend datastore. These are effectively free standing
729
+ properties. __Read Only__ */
730
+ unmappedProperties: DataProperty[];
731
+ /** Always empty: a ComplexType has no navigation properties. Present so that code can treat an
732
+ EntityType and a ComplexType alike. __Read Only__ */
733
+ navigationProperties: DataProperty[];
734
+ /** Always empty: a ComplexType has no key. Present so that code can treat an EntityType and a
735
+ ComplexType alike. __Read Only__ */
736
+ keyProperties: DataProperty[];
737
+ /** Not used by breeze-client 3, and never set on a ComplexType. See {@link EntityType.warnings}. */
738
+ warnings: any[];
739
+ /** A function that customizes how this type's data properties are serialized when an entity holding
740
+ it is saved; see {@link MetadataStore.serializerFn}, which is used when this is not set. The
741
+ constructor does not accept it: assign it directly. */
742
+ serializerFn?: (prop: EntityProperty, val: any) => any;
743
+ /** A free form object that can be used to define any custom metadata for this ComplexType. */
744
+ custom?: any;
745
+ /** See {@link EntityType.getCtor} */
746
+ getCtor: (forceRefresh?: boolean) => {
747
+ new (): StructuralObject;
748
+ };
749
+ /** Creates a new instance of this ComplexType, optionally setting the property values given in
750
+ `initialValues`; the ComplexType counterpart of {@link EntityType.createEntity}.
751
+ ```ts
752
+ const locType = em1.metadataStore.getAsComplexType("Location");
753
+ const loc = locType.createInstance<Location>({ city: "Boston" }); // Location, unchecked
754
+ ```
755
+ */
756
+ createInstance: <T = any>(initialValues?: any) => T;
757
+ /** See [EntityType.addValidator] */
758
+ addValidator: (validator: Validator, property?: EntityProperty | string) => void;
759
+ /** Returns the {@link DataProperty} with the specified name, or null. Also accepts a `.` delimited
760
+ path through nested complex properties. See {@link EntityType.getProperty}. */
761
+ getProperty: (propertyPath: string, throwIfNotFound?: boolean) => EntityProperty | null;
762
+ /** Returns the properties along a `.` delimited property path, one per segment, or null if a segment
763
+ is not found (unless `throwIfNotFound` is true, which throws instead). `useServerName` matches
764
+ segments against `nameOnServer` when true, `name` when false, and either when null. Used by Breeze
765
+ internally; applications normally use {@link ComplexType.getProperty}. */
766
+ getPropertiesOnPath: (propertyPath: string, useServerName: boolean | null, throwIfNotFound?: boolean) => EntityProperty[] | null;
767
+ /** Returns the names of all of this type's data properties. */
768
+ getPropertyNames: () => any[];
769
+ /** Creates a ComplexType from a {@link ComplexTypeConfig}. Add it to a {@link MetadataStore}
770
+ with {@link MetadataStore.addEntityType} before using it. */
771
+ constructor(config: ComplexTypeConfig);
772
+ /**
773
+ General purpose property set method
774
+ ```ts
775
+ // assume em1 is an EntityManager
776
+ const locType = em1.metadataStore.getAsComplexType("Location");
777
+ locType.setProperties({
778
+ custom: { foo: 7, bar: "test" }
779
+ });
780
+ ```
781
+ @param config - Custom config object
782
+ @param config.custom - {Object}
783
+ */
784
+ setProperties(config: {
785
+ custom?: any;
786
+ }): void;
787
+ /** Returns the type level validators for this ComplexType: its own {@link ComplexType.validators}
788
+ array itself, not a copy, since ComplexTypes have no base types. */
789
+ getAllValidators(): Validator[];
790
+ /** Adds a {@link DataProperty} to this ComplexType.
791
+ ```ts
792
+ // assume addressType is a newly constructed ComplexType.
793
+ addressType.addProperty(new DataProperty({ name: "city", dataType: DataType.String }));
794
+ ```
795
+ */
796
+ addProperty(dataProperty: DataProperty): void;
797
+ /** Returns all of the properties of this ComplexType: its {@link ComplexType.dataProperties} array
798
+ itself, not a copy. */
799
+ getProperties(): EntityProperty[];
800
+ /** Returns this type's metadata as a plain object in Breeze's native JSON metadata format, leaving
801
+ out default values and empty arrays. `JSON.stringify` calls it when
802
+ {@link MetadataStore.exportMetadata} serializes the store. */
803
+ toJSON(): Object;
804
+ }
805
+ /** Configuration info to be passed to the {@link DataProperty} constructor. Either `name` or
806
+ `nameOnServer` is required. */
807
+ export interface DataPropertyConfig {
808
+ /** The client-side name of the property. If omitted, it is derived from `nameOnServer` by the
809
+ store's {@link NamingConvention} when the property's type is added to a {@link MetadataStore}. */
810
+ name?: string;
811
+ /** The name of the property on the server. If omitted, it is derived from `name` by the store's
812
+ {@link NamingConvention}. */
813
+ nameOnServer?: string;
814
+ /** The {@link DataType} of the property, or its name. Defaults to {@link DataType.String}. For a
815
+ property that holds a complex object, set `complexTypeName` instead. */
816
+ dataType?: DataType | string | ComplexType;
817
+ /** The name, short or qualified, of the {@link ComplexType} this property holds. Setting it makes the
818
+ property a complex property; it is linked to the ComplexType once both are in the same MetadataStore. */
819
+ complexTypeName?: string;
820
+ /** Whether the property may be null. Defaults to `true`. Breeze does not create a `required`
821
+ validator from it; that comes with the server's metadata. */
822
+ isNullable?: boolean;
823
+ /** Whether the property holds a single value. Defaults to `true`; set it to `false` for a property
824
+ that holds an array of values or complex objects. */
825
+ isScalar?: boolean;
826
+ /** The value a new entity gets for this property. Defaults to `null` for a nullable property and to
827
+ the {@link DataType}'s default value otherwise. A numeric default given as a string is parsed. */
828
+ defaultValue?: any;
829
+ /** Whether the property is part of its EntityType's key. Defaults to `false`. */
830
+ isPartOfKey?: boolean;
831
+ /** Whether the property exists only on the client, with no counterpart on the server. Defaults to
832
+ `false`. Breeze marks the properties it discovers on a registered constructor as unmapped itself. */
833
+ isUnmapped?: boolean;
834
+ /** Whether the property can be written. Defaults to `true`. Breeze does not set a property that is
835
+ not settable when it populates an entity from query results. */
836
+ isSettable?: boolean;
837
+ /** How the property takes part in optimistic concurrency checking; see
838
+ {@link DataProperty.concurrencyMode}. Any value other than `"None"` makes it a concurrency property. */
839
+ concurrencyMode?: string;
840
+ /** The maximum length of a string value. Breeze does not create a `maxLength` validator from it;
841
+ that comes with the server's metadata. */
842
+ maxLength?: number;
843
+ /** The {@link Validator}s for this property. Defaults to an empty array. */
844
+ validators?: Validator[];
845
+ /** The name used for this property in validation messages. Defaults to the property name. */
846
+ displayName?: string;
847
+ /** The full name of the server-side enum type, for a property whose values are enum members. */
848
+ enumType?: string;
849
+ /** The server's name for the property's type, when the client has no matching {@link DataType} and
850
+ `dataType` is {@link DataType.Undefined}. */
851
+ rawTypeName?: string;
852
+ /** Sets {@link DataProperty.custom}. */
853
+ custom?: any;
854
+ }
855
+ /**
856
+ A DataProperty describes the metadata for a single property of an {@link EntityType} that contains simple data.
857
+
858
+ Instances of the DataProperty class are constructed automatically during Metadata retrieval. However it is also possible to construct them
859
+ directly via the constructor.
860
+ */
861
+ export declare class DataProperty {
862
+ /** Is this a DataProperty? - always true here. Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
863
+ isDataProperty: boolean;
864
+ /** Is this a NavigationProperty? - always false here. Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
865
+ isNavigationProperty: boolean;
866
+ /** The name of this property. __Read Only__ */
867
+ name: string;
868
+ /** The name of this property on the server. __Read Only__ */
869
+ nameOnServer: string;
870
+ /** The {@link DataType} of this property. __Read Only__ */
871
+ dataType: DataType | ComplexType;
872
+ /** The name of the {@link ComplexType} associated with this property; may be null. __Read Only__ */
873
+ complexTypeName: string;
874
+ /** The {@link ComplexType} associated with this property; may be undefined. __Read Only__ */
875
+ complexType?: ComplexType;
876
+ /** Whether the contents of this property is an instance of a {@link ComplexType}. __Read Only__ */
877
+ isComplexProperty: boolean;
878
+ /** Whether this property is nullable. __Read Only__ */
879
+ isNullable: boolean;
880
+ /** Whether this property is scalar (i.e., returns a single value as opposed to an array). __Read Only__ */
881
+ isScalar: boolean;
882
+ /** The default value for this property. __Read Only__ */
883
+ defaultValue: any;
884
+ /** Whether this property is a 'key' property. __Read Only__ */
885
+ isPartOfKey: boolean;
886
+ /** Whether this property is an 'unmapped' property. __Read Only__ */
887
+ isUnmapped: boolean;
888
+ /** Whether this property is 'settable'. __Read Only__ */
889
+ isSettable: boolean;
890
+ /** How this property takes part in optimistic concurrency checking, as the server reported it.
891
+ Any value other than `"None"` puts the property into {@link EntityType.concurrencyProperties}, whose
892
+ values Breeze sends with a save so the server can detect that someone else changed the row first.
893
+ A Breeze .NET server reports `"Fixed"` for a rowversion or `[ConcurrencyCheck]` property. __Read Only__ */
894
+ concurrencyMode: string;
895
+ /** The maximum length for the value of this property. Only meaningful for strings. __Read Only__ */
896
+ maxLength?: number;
897
+ /** The {@link Validator} instances that are associated with this property. Validators can be added and
898
+ removed from this collection. __Read Only__ */
899
+ validators: Validator[];
900
+ /** The display name of this property. __Read Only__ */
901
+ displayName: string;
902
+ /** The full name of the enum type */
903
+ enumType?: string;
904
+ /** The raw type name of this property. will only be defined for properties with a DataType of 'Undefined' */
905
+ rawTypeName?: string;
906
+ /** A free form object that can be used to define any custom metadata for this DataProperty. __Read Only__ */
907
+ custom?: any;
908
+ /** For a foreign key in a *unidirectional* relationship, the navigation property on the other type
909
+ that points back at this one. It is set only when the type holding the foreign key has no navigation
910
+ property of its own for it: `Territory.regionId` has no `Territory.region`, so its
911
+ `inverseNavigationProperty` is `Region.territories`, and setting the foreign key still maintains that
912
+ collection. Where both sides do have a navigation property, {@link DataProperty.relatedNavigationProperty}
913
+ is set instead. __Read Only__ */
914
+ inverseNavigationProperty?: NavigationProperty;
915
+ /**
916
+ The navigation property related to this property. Will only be set if this is a foreign key property. __Read Only__ */
917
+ relatedNavigationProperty?: NavigationProperty;
918
+ /** The parent type that this property belongs to - will be either a {@link EntityType} or a {@link ComplexType}. __Read Only__ */
919
+ parentType: StructuralType;
920
+ /** Property on the base type that this property is inherited from. Will be null if the property is not on the base type. __Read Only__ */
921
+ baseProperty?: DataProperty;
922
+ /** DataProperty constructor
923
+ ```ts
924
+ const lastNameProp = new DataProperty({
925
+ name: "lastName",
926
+ dataType: DataType.String,
927
+ isNullable: true,
928
+ maxLength: 20
929
+ });
930
+ // assuming personEntityType is a newly constructed EntityType
931
+ personEntityType.addProperty(lastNameProp);
932
+ ```
933
+ @param config - A configuration Object or a DataProperty
934
+ */
935
+ constructor(config: DataPropertyConfig | DataProperty);
936
+ /**
937
+ Reads a property's value from a raw entity whose keys are server property names, such as a node
938
+ in query results. Returns the property's `defaultValue` when the node has no value for it; for an
939
+ unmapped property it reads `nameOnServer`, falling back to `name`, and applies no default. Pass it as
940
+ the `rawValueFn` of {@link EntityType.getEntityKeyFromRawEntity} when writing an adapter;
941
+ applications do not normally need it.
942
+ */
943
+ static getRawValueFromServer(rawEntity: Object & Record<string, any>, dp: DataProperty): any;
944
+ /**
945
+ Reads a property's value from a raw entity whose keys are client property names, such as an entity
946
+ in the output of {@link EntityManager.exportEntities}. Returns the property's `defaultValue` when the
947
+ raw entity has no value for it. The client-name counterpart of
948
+ {@link DataProperty.getRawValueFromServer}; applications do not normally need it.
949
+ */
950
+ static getRawValueFromClient(rawEntity: Object & Record<string, any>, dp: DataProperty): any;
951
+ /**
952
+ Returns the value of the named field of this property, such as `"displayName"`. If it is null or
953
+ undefined here, the value is taken from the property this one inherits from on a base type (see
954
+ {@link DataProperty.baseProperty}), and so on up the hierarchy. Validation uses it to find a
955
+ property's display name.
956
+ */
957
+ resolveProperty(propName: string): any;
958
+ /** Returns a name that identifies this property across the store: the qualified name of its parent
959
+ type and the property name, joined by `--`. Breeze uses it in error messages and to generate
960
+ association names; applications do not normally need it. */
961
+ formatName(): string;
962
+ /**
963
+ General purpose property set method
964
+ ```ts
965
+ // assume myEntityType is an EntityType
966
+ const prop = myEntityType.getProperty("myProperty");
967
+ prop.setProperties({
968
+ custom: { foo: 7, bar: "test" }
969
+ });
970
+ ```
971
+ @param config - A configuration object.
972
+ */
973
+ setProperties(config: {
974
+ displayName?: string;
975
+ custom?: Object;
976
+ }): void;
977
+ /** Returns the validators that apply to this property: its own {@link DataProperty.validators}
978
+ followed by those of the properties it inherits from on base types. Returns a new array. */
979
+ getAllValidators(): Validator[];
980
+ /** Returns this property's metadata as a plain object in Breeze's native JSON metadata format,
981
+ leaving out default values; a complex property is described by its `complexTypeName`. Used when
982
+ {@link MetadataStore.exportMetadata} serializes the store. */
983
+ toJSON(): Object;
984
+ /** Creates a DataProperty from the JSON form that {@link DataProperty.toJSON} produces. Used by
985
+ {@link MetadataStore.importMetadata}. A `dataType` name the client does not know becomes
986
+ {@link DataType.Undefined}, with the name kept in `rawTypeName` and a console warning. Modifies the
987
+ object passed in. */
988
+ static fromJSON(json: any): DataProperty;
989
+ }
990
+ /** Configuration info to be passed to the {@link NavigationProperty} constructor. `entityTypeName`
991
+ and either `name` or `nameOnServer` are required. */
992
+ export interface NavigationPropertyConfig {
993
+ /** The client-side name of the property. If omitted, it is derived from `nameOnServer` by the
994
+ store's {@link NamingConvention}. */
995
+ name?: string;
996
+ /** The name of the property on the server. If omitted, it is derived from `name` by the store's
997
+ {@link NamingConvention}. */
998
+ nameOnServer?: string;
999
+ /** The name of the {@link EntityType} the property returns. Required. A name without a namespace
1000
+ (no `:#`) is taken to be in the namespace of the type the property is added to. */
1001
+ entityTypeName?: string;
1002
+ /** Whether the property returns a single entity. Defaults to `true`; set it to `false` for a
1003
+ property that returns an array of entities. */
1004
+ isScalar?: boolean;
1005
+ /** The name of the relationship. Two navigation properties, one on each type, with the same
1006
+ association name are each other's {@link NavigationProperty.inverse}. */
1007
+ associationName?: string;
1008
+ /** The names of the foreign key DataProperties, on the type that holds this property, that refer to
1009
+ the entity it returns. Defaults to an empty array. Set on the dependent side of a relationship,
1010
+ e.g. `["customerId"]` for `Order.customer`. */
1011
+ foreignKeyNames?: string[];
1012
+ /** The server-side names of the `foreignKeyNames`; either list may be given and the other is
1013
+ derived. Defaults to an empty array. */
1014
+ foreignKeyNamesOnServer?: string[];
1015
+ /** The names of the foreign key DataProperties, on the type the property returns, that refer back to
1016
+ the type that holds it. Defaults to an empty array. Set on the principal side of a relationship,
1017
+ e.g. `["customerId"]` for `Customer.orders`. */
1018
+ invForeignKeyNames?: string[];
1019
+ /** The server-side names of the `invForeignKeyNames`; either list may be given and the other is
1020
+ derived. Defaults to an empty array. */
1021
+ invForeignKeyNamesOnServer?: string[];
1022
+ /** The {@link Validator}s for this property. Defaults to an empty array. */
1023
+ validators?: Validator[];
1024
+ /** The name used for this property in validation messages. Defaults to the property name. */
1025
+ displayName?: string;
1026
+ /** Sets {@link NavigationProperty.custom}. */
1027
+ custom?: any;
1028
+ }
1029
+ /** A NavigationProperty describes the metadata for a single property of an {@link EntityType} that return instances of other EntityTypes.
1030
+
1031
+ Instances of the NavigationProperty class are constructed automatically during Metadata retrieval. However it is also possible to construct them
1032
+ directly via the constructor.
1033
+ */
1034
+ export declare class NavigationProperty {
1035
+ /** Is this a DataProperty? - always false here
1036
+ Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
1037
+ isDataProperty: boolean;
1038
+ /** Is this a NavigationProperty? - always true here
1039
+ Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
1040
+ isNavigationProperty: boolean;
1041
+ /** Returns the qualified name of the parent type and the property name, joined by `--`. See
1042
+ {@link DataProperty.formatName}; applications do not normally need it. */
1043
+ formatName: () => string;
1044
+ /** Returns the validators that apply to this property, including those inherited from base types.
1045
+ See {@link DataProperty.getAllValidators}. */
1046
+ getAllValidators: () => Validator[];
1047
+ /** Returns the value of the named field of this property, falling back to the property it inherits
1048
+ from on a base type. See {@link DataProperty.resolveProperty}. */
1049
+ resolveProperty: (propName: string) => any;
1050
+ /** The {@link EntityType} returned by this property. __Read Only__ */
1051
+ entityType: EntityType;
1052
+ /** The name of the {@link EntityType} returned by this property. __Read Only__ */
1053
+ entityTypeName: string;
1054
+ /** The {@link EntityType} that this property belongs to. ( same as entityType). __Read Only__ */
1055
+ parentType: EntityType;
1056
+ /** The {@link EntityType} that this property belongs to. ( same as entityType). __Read Only__ */
1057
+ parentEntityType: EntityType;
1058
+ /** Property on the base type that this property is inherited from. Will be null if the property is not on the base type. __Read Only__ */
1059
+ baseProperty?: NavigationProperty;
1060
+ /** The inverse of this NavigationProperty. The NavigationProperty that represents a navigation in the opposite direction
1061
+ to this NavigationProperty. May be undefined for a undirectional NavigationProperty. __Read Only__ */
1062
+ private _inverse?;
1063
+ /** The name of this property. __Read Only__ */
1064
+ name: string;
1065
+ /** The name of this property on the server. __Read Only__ */
1066
+ nameOnServer: string;
1067
+ /**
1068
+ Whether this property returns a single entity as opposed to an array of entities. __Read Only__ */
1069
+ isScalar: boolean;
1070
+ /** The name of the association to which that this property belongs. This associationName will be shared with this
1071
+ properties 'inverse'. __Read Only__ */
1072
+ associationName: string;
1073
+ /** The names of the foreign key DataProperties associated with this NavigationProperty. There will usually only be a single DataProperty associated
1074
+ with a Navigation property except in the case of entities with multipart keys. __Read Only__ */
1075
+ foreignKeyNames: string[];
1076
+ /** The server side names of the foreign key DataProperties associated with this NavigationProperty. There will usually only be a single DataProperty associated
1077
+ with a Navigation property except in the case of entities with multipart keys. __Read Only__ */
1078
+ foreignKeyNamesOnServer: string[];
1079
+ /** The names of the foreign key DataProperties at the other end of the relationship. __Read Only__ */
1080
+ invForeignKeyNames: string[];
1081
+ /** The server side names of the foreign key DataProperties at the other end of the relationship. __Read Only__ */
1082
+ invForeignKeyNamesOnServer: string[];
1083
+ /** The 'foreign key' DataProperties associated with this NavigationProperty. There will usually only be a single DataProperty associated
1084
+ with a Navigation property except in the case of entities with multipart keys. __Read Only__ */
1085
+ relatedDataProperties: DataProperty[];
1086
+ /** The {@link Validator} instances that are associated with this property. Validators can be added and
1087
+ removed from this collection. __Read Only__ */
1088
+ validators: Validator[];
1089
+ /** The display name of this property. __Read Only__ */
1090
+ displayName: string;
1091
+ /** Always undefined: a NavigationProperty cannot be unmapped. Declared so that `isUnmapped` can be
1092
+ read from any {@link EntityProperty}. __Read Only__ */
1093
+ isUnmapped: boolean;
1094
+ /** A free form object that can be used to define any custom metadata for this NavigationProperty. */
1095
+ custom: any;
1096
+ /** NavigationProperty constructor
1097
+ ```ts
1098
+ const homeAddressProp = new NavigationProperty({
1099
+ name: "homeAddress",
1100
+ entityTypeName: "Address:#myNamespace",
1101
+ isScalar: true,
1102
+ associationName: "address_person",
1103
+ foreignKeyNames: ["homeAddressId"]
1104
+ });
1105
+ const homeAddressIdProp = new DataProperty({
1106
+ name: "homeAddressId",
1107
+ dataType: DataType.Int32
1108
+ });
1109
+ // assuming personEntityType is a newly constructed EntityType
1110
+ personEntityType.addProperty(homeAddressProp);
1111
+ personEntityType.addProperty(homeAddressIdProp);
1112
+ ```
1113
+ @param config - A configuration object.
1114
+ */
1115
+ constructor(config: NavigationPropertyConfig);
1116
+ /**
1117
+ General purpose property set method
1118
+ ```ts
1119
+ // assume myEntityType is an EntityType
1120
+ const prop = myEntityType.getProperty("myProperty");
1121
+ prop.setProperties({
1122
+ custom: { foo: 7, bar: "test" }
1123
+ });
1124
+ ```
1125
+ @param config - A config object
1126
+ */
1127
+ setProperties(config: {
1128
+ displayName?: string;
1129
+ foreignKeyNames?: string[];
1130
+ invForeignKeyNames?: string[];
1131
+ inverse?: NavigationProperty | string;
1132
+ custom?: any;
1133
+ }): void;
1134
+ /** The inverse of this NavigationProperty. The NavigationProperty that represents a navigation in the opposite direction
1135
+ to this NavigationProperty. May be undefined for a undirectional NavigationProperty. __Read Only__ */
1136
+ get inverse(): NavigationProperty | undefined;
1137
+ /**
1138
+ Makes the specified navigation property, on the type this property returns, the inverse of this one.
1139
+ Both get the same {@link NavigationProperty.associationName}: this property's if it has one, otherwise
1140
+ the other's, otherwise a generated one. For metadata built by hand; metadata from the server already
1141
+ pairs inverses by association name. Also available as the `inverse` option of
1142
+ {@link NavigationProperty.setProperties}. Both types must already be in the same MetadataStore.
1143
+ @param inverseNp - The inverse NavigationProperty, or its name on the type this property returns.
1144
+ Throws if it is not found, does not point back at this property's parent type, or either property
1145
+ already has an inverse.
1146
+ */
1147
+ setInverse(inverseNp: NavigationProperty | string): void;
1148
+ /** Returns this property's metadata as a plain object in Breeze's native JSON metadata format,
1149
+ leaving out default values. Only client-side names are written. Used when
1150
+ {@link MetadataStore.exportMetadata} serializes the store. */
1151
+ toJSON(): Object;
1152
+ /** Creates a NavigationProperty from the JSON form that {@link NavigationProperty.toJSON} produces.
1153
+ Used by {@link MetadataStore.importMetadata}. Modifies the object passed in. */
1154
+ static fromJSON(json: any): NavigationProperty;
1155
+ }
1156
+ /**
1157
+ AutoGeneratedKeyType is an 'Enum' containing all of the valid states for an automatically generated key.
1158
+ */
1159
+ export declare class AutoGeneratedKeyType extends BreezeEnum {
1160
+ /**
1161
+ This entity does not have an autogenerated key.
1162
+ The client must set the key before adding the entity to the EntityManager
1163
+ */
1164
+ static None: AutoGeneratedKeyType;
1165
+ /**
1166
+ This entity's key is an Identity column and is set by the backend database.
1167
+ Keys for new entities will be temporary until the entities are saved at which point the keys will
1168
+ be converted to their 'real' versions.
1169
+ */
1170
+ static Identity: AutoGeneratedKeyType;
1171
+ /**
1172
+ This entity's key is generated by a KeyGenerator and is set by the backend database.
1173
+ Keys for new entities will be temporary until the entities are saved at which point the keys will
1174
+ be converted to their 'real' versions.
1175
+ */
1176
+ static KeyGenerator: AutoGeneratedKeyType;
1177
+ }
1178
+ export declare function qualifyTypeName(shortName: string, ns?: string): string;
1179
+ /**
1180
+ The {@link EntityType} a constructor stands for.
1181
+
1182
+ {@link MetadataStore.registerEntityTypeCtor} puts the type on the class's prototype, and that is
1183
+ what the constructor-taking overloads of `EntityQuery.from`, `EntityManager.createEntity` and the
1184
+ rest read. A class that was never registered has nothing to read, so this throws rather than
1185
+ letting the caller build a query against `undefined`.
1186
+
1187
+ ```ts
1188
+ em.metadataStore.registerEntityTypeCtor('Customer', Customer);
1189
+ entityTypeForCtor(Customer).defaultResourceName; // 'Customers'
1190
+ ```
1191
+ @param entityCtor - A constructor registered with a MetadataStore.
1192
+ */
1193
+ export declare function entityTypeForCtor(entityCtor: Function): EntityType;