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,392 @@
1
+ import { core } from '../core/core.js';
2
+ import { assertParam, assertConfig } from '../core/assert-param.js';
3
+ import { BreezeEvent } from '../core/event.js';
4
+ export class InterfaceDef {
5
+ name;
6
+ defaultInstance;
7
+ /** @hidden @internal */
8
+ _implMap;
9
+ constructor(name) {
10
+ this.name = name;
11
+ this.defaultInstance = undefined;
12
+ this._implMap = new Map();
13
+ }
14
+ /** Define an implementation of the given adaptername */
15
+ registerCtor(adapterName, ctor) {
16
+ this._implMap.set(adapterName.toLowerCase(), { ctor: ctor, defaultInstance: undefined });
17
+ }
18
+ /** Return the definition for the given adapterName */
19
+ getImpl(adapterName) {
20
+ return this._implMap.get(adapterName.toLowerCase());
21
+ }
22
+ /** Return the first implementation for this InterfaceDef */
23
+ getFirstImpl() {
24
+ // Map preserves insertion order, so 'first' is well defined here.
25
+ const first = this._implMap.values().next();
26
+ return first.done ? null : first.value;
27
+ }
28
+ getDefaultInstance() {
29
+ return this.defaultInstance;
30
+ }
31
+ }
32
+ /** Registers adapters used by Breeze */
33
+ export class InterfaceRegistry {
34
+ /** Creates a registry with no adapters in it. {@link config} holds the one Breeze uses;
35
+ applications do not create their own. */
36
+ constructor() { }
37
+ /** The registered {@link AjaxAdapter}s, and the default one if any. Deprecated: Breeze 3 sends requests through `config.fetch` and needs no ajax adapter. */
38
+ ajax = new InterfaceDef("ajax");
39
+ /** The registered {@link ModelLibraryAdapter}s, and the default one. */
40
+ modelLibrary = new InterfaceDef("modelLibrary");
41
+ /** The registered {@link DataServiceAdapter}s, and the default one. */
42
+ dataService = new InterfaceDef("dataService");
43
+ /** The registered {@link UriBuilderAdapter}s, and the default one. */
44
+ uriBuilder = new InterfaceDef("uriBuilder");
45
+ }
46
+ // The data service adapter resolves the ajax adapter when it initializes, so ajax has to
47
+ // come first. Same order as configureBreeze.
48
+ const initOrder = ['modelLibrary', 'uriBuilder', 'ajax', 'dataService'];
49
+ const defaultAdapters = {};
50
+ /**
51
+ Sets the adapters Breeze falls back to when none has been registered for an interface.
52
+ Called once, by default-adapters.ts; applies to every BreezeConfig.
53
+ @hidden @internal
54
+ */
55
+ export function setDefaultAdapters(defaults) {
56
+ Object.assign(defaultAdapters, defaults);
57
+ }
58
+ /**
59
+ Breeze's global configuration: the adapter registry, the `fetch` transport, and registries Breeze
60
+ uses to find functions and objects by name when it deserializes metadata. The single instance is
61
+ {@link config}.
62
+
63
+ To configure Breeze, use {@link configureBreeze}. The adapter methods here (`registerAdapter`,
64
+ `initializeAdapterInstance`, `getAdapterInstance` and the rest) are the 2.x API. They still
65
+ work, and adapters' own static `register()` methods use them, but an application does not
66
+ normally need to call them.
67
+ */
68
+ export class BreezeConfig {
69
+ /**
70
+ Functions registered by name with {@link BreezeConfig.registerFunction}. Breeze looks up
71
+ validator factories here, under `"Validator." + name`, when it imports metadata. Applications do
72
+ not normally need it; use {@link Validator.register} and {@link Validator.registerFactory}.
73
+ */
74
+ functionRegistry = {};
75
+ /**
76
+ Constructors registered by name with {@link BreezeConfig.registerType}. Nothing in Breeze 3
77
+ reads it; applications do not normally need it.
78
+ */
79
+ typeRegistry = {};
80
+ /**
81
+ Named instances Breeze can find again by name, keyed `"<TypeName>.<name>"`: every
82
+ {@link JsonResultsAdapter}, {@link NamingConvention} and {@link LocalQueryComparisonOptions}
83
+ registers itself here when created. Breeze uses it to resolve the names in exported metadata and
84
+ exported entities. Applications do not normally need it.
85
+ */
86
+ objectRegistry = {};
87
+ /**
88
+ Published each time an adapter is initialized, with the interface name, the adapter instance
89
+ and whether it became the default for its interface. Breeze uses it to let adapters that depend
90
+ on each other recompose (see {@link BaseAdapter.checkForRecomposition}); applications do not
91
+ normally need it.
92
+ */
93
+ interfaceInitialized;
94
+ /**
95
+ * Adapter instances already subscribed to `interfaceInitialized` for recomposition, so that
96
+ * re-initializing one does not subscribe it twice. Weak because the entry is only ever looked
97
+ * up for an instance in hand, and one outliving its adapter would be its own small leak.
98
+ * @hidden @internal
99
+ */
100
+ _recomposers = new WeakSet();
101
+ /**
102
+ The indentation Breeze passes to `JSON.stringify` when it serializes exported entities
103
+ (`EntityManager.exportEntities`) and exported metadata (`MetadataStore.exportMetadata`).
104
+ The default, `''`, produces compact JSON; set it to, say, `' '` for readable output.
105
+ */
106
+ stringifyPad = '';
107
+ /**
108
+ * The function Breeze makes HTTP requests with, unless a (deprecated) ajax adapter is
109
+ * registered. Set it with `configureBreeze({ fetch })`. When unset, `globalThis.fetch`.
110
+ */
111
+ fetch;
112
+ /** @hidden @internal */
113
+ _interfaceRegistry; // set below, on the global config. Untyped: getInterfaceDef looks interfaces up by name.
114
+ /** Creates a configuration with nothing registered. Breeze creates the one instance there is,
115
+ {@link config}; applications do not create their own. */
116
+ constructor() {
117
+ this.interfaceInitialized = new BreezeEvent("interfaceInitialized", this);
118
+ }
119
+ /**
120
+ Method use to register implementations of standard breeze interfaces. Calls to this method are usually
121
+ made as the last step within an adapter implementation.
122
+ @param interfaceName {String} - one of the following interface names: "ajax", "dataService", "modelLibrary", "uriBuilder"
123
+ @param adapterCtor {Function} - an ctor function that returns an instance of the specified interface.
124
+
125
+ @deprecated For configuring an application, use `configureBreeze({ ajax: MyAdapter, ... })`
126
+ instead: the adapter classes are passed directly, so a misspelled name is a compile error
127
+ rather than a runtime one. An adapter's own static `register()` still calls this - that is
128
+ how an adapter registers itself, and is not deprecated. Not scheduled for removal.
129
+ */
130
+ registerAdapter(interfaceName, adapterCtor) {
131
+ assertParam(interfaceName, "interfaceName").isNonEmptyString().check();
132
+ assertParam(adapterCtor, "adapterCtor").isFunction().check();
133
+ // this impl will be thrown away after the name is retrieved.
134
+ let impl = new adapterCtor();
135
+ let implName = impl.name;
136
+ if (!implName) {
137
+ throw new Error("Unable to locate a 'name' property on the constructor passed into the 'registerAdapter' call.");
138
+ }
139
+ let idef = this.getInterfaceDef(interfaceName);
140
+ idef.registerCtor(implName, adapterCtor);
141
+ }
142
+ /**
143
+ Returns the ctor function used to implement a specific interface with a specific adapter name.
144
+ @param interfaceName {String} One of the following interface names: "ajax", "dataService", "modelLibrary", "uriBuilder"
145
+ @param [adapterName] {String} The name of any previously registered adapter. If this parameter is omitted then
146
+ this method returns the "default" adapter for this interface. If there is no default adapter, then a null is returned.
147
+ @returns {Function|null} Returns either a ctor function or null.
148
+ */
149
+ getAdapter(interfaceName, adapterName) {
150
+ let idef = this.getInterfaceDef(interfaceName);
151
+ if (adapterName) {
152
+ let impl = idef.getImpl(adapterName);
153
+ return impl ? impl.ctor : null;
154
+ }
155
+ else {
156
+ return idef.defaultInstance ? idef.defaultInstance._$impl.ctor : null;
157
+ }
158
+ }
159
+ /**
160
+ Initializes a single adapter implementation. Initialization means either newing a instance of the
161
+ specified interface and then calling "initialize" on it or simply calling "initialize" on the instance
162
+ if it already exists.
163
+ @param interfaceName {String} The name of the interface to which the adapter to initialize belongs.
164
+ @param adapterName {String} - The name of a previously registered adapter to initialize.
165
+ @param [isDefault=true] {Boolean} - Whether to make this the default "adapter" for this interface.
166
+ @returns {an instance of the specified adapter}
167
+
168
+ @deprecated For configuring an application, use `configureBreeze({ ajax: MyAdapter, ... })`
169
+ instead: the adapter classes are passed directly, so a misspelled name is a compile error
170
+ rather than a runtime one. An adapter's own static `register()` still calls this - that is
171
+ how an adapter registers itself, and is not deprecated. Not scheduled for removal.
172
+ */
173
+ initializeAdapterInstance(interfaceName, adapterName, isDefault = true) {
174
+ isDefault = isDefault === undefined ? true : isDefault;
175
+ assertParam(interfaceName, "interfaceName").isNonEmptyString().check();
176
+ assertParam(adapterName, "adapterName").isNonEmptyString().check();
177
+ assertParam(isDefault, "isDefault").isBoolean().check();
178
+ let idef = this.getInterfaceDef(interfaceName);
179
+ let impl = idef.getImpl(adapterName) || this._registerDefaultAdapter(idef, interfaceName, adapterName);
180
+ if (!impl) {
181
+ throw new Error("Unregistered adapter. Interface: " + interfaceName + " AdapterName: " + adapterName);
182
+ }
183
+ return this._initializeAdapterInstanceCore(idef, impl, isDefault);
184
+ }
185
+ /**
186
+ Returns the adapter instance corresponding to the specified interface and adapter names.
187
+ @param interfaceName {String} The name of the interface.
188
+ @param [adapterName] {String} - The name of a previously registered adapter. If this parameter is
189
+ omitted then the default implementation of the specified interface is returned. If there is
190
+ no defaultInstance of this interface, then the first registered instance of this interface is returned.
191
+ @returns {an instance of the specified adapter}
192
+ */
193
+ getAdapterInstance(interfaceName, adapterName) {
194
+ let idef = this.getInterfaceDef(interfaceName);
195
+ let impl;
196
+ let isDefault = adapterName == null || adapterName === "";
197
+ if (isDefault) {
198
+ if (idef.defaultInstance)
199
+ return idef.defaultInstance;
200
+ impl = idef.getFirstImpl();
201
+ }
202
+ else {
203
+ impl = idef.getImpl(adapterName);
204
+ }
205
+ if (!impl)
206
+ impl = this._registerDefaultAdapter(idef, interfaceName, isDefault ? undefined : adapterName);
207
+ if (!impl)
208
+ return undefined;
209
+ if (impl.defaultInstance) {
210
+ return impl.defaultInstance;
211
+ }
212
+ else {
213
+ return this._initializeAdapterInstanceCore(idef, impl, isDefault);
214
+ }
215
+ }
216
+ /** this is needed for reflection purposes when deserializing an object that needs a fn or ctor.
217
+ Used to register validators. */
218
+ registerFunction(fn, fnName) {
219
+ assertParam(fn, "fn").isFunction().check();
220
+ assertParam(fnName, "fnName").isString().check();
221
+ if (fn.prototype) {
222
+ fn.prototype._$fnName = fnName;
223
+ }
224
+ this.functionRegistry[fnName] = fn;
225
+ }
226
+ /**
227
+ Registers a constructor under a type name: stamps the name on its prototype as `_$typeName` and
228
+ adds it to {@link BreezeConfig.typeRegistry}. Breeze registers `KeyGenerator` this way;
229
+ applications do not normally need it.
230
+ @param ctor - The constructor to register.
231
+ @param typeName - The name to register it under.
232
+ */
233
+ registerType(ctor, typeName) {
234
+ assertParam(ctor, "ctor").isFunction().check();
235
+ assertParam(typeName, "typeName").isString().check();
236
+ if (ctor.prototype) {
237
+ ctor.prototype._$typeName = typeName;
238
+ }
239
+ this.typeRegistry[typeName] = ctor;
240
+ }
241
+ /**
242
+ Returns the function registered under the given name with {@link BreezeConfig.registerFunction},
243
+ or `undefined` if there is none. Validators are registered as `"Validator." + name`, so
244
+ `config.getRegisteredFunction('Validator.maxLength')` returns the `maxLength` factory.
245
+ @param fnName - The name the function was registered under.
246
+ */
247
+ getRegisteredFunction(fnName) {
248
+ return this.functionRegistry[fnName];
249
+ }
250
+ /**
251
+ Returns the registry entry for one adapter interface, which holds its registered adapters and
252
+ its default instance. The name is matched without regard to case.
253
+ Used by the adapter registration methods; applications do not normally need it.
254
+ @param interfaceName - `'ajax'`, `'dataService'`, `'modelLibrary'` or `'uriBuilder'`.
255
+ @throws if there is no interface with that name.
256
+ */
257
+ getInterfaceDef(interfaceName) {
258
+ let lcName = interfaceName.toLowerCase();
259
+ // source may be null
260
+ let kv = core.objectFirst(this._interfaceRegistry || {}, function (k, v) {
261
+ return k.toLowerCase() === lcName;
262
+ });
263
+ if (!kv) {
264
+ throw new Error("Unknown interface name: " + interfaceName);
265
+ }
266
+ return kv.value;
267
+ }
268
+ /** @deprecated @internal no-op kept for backward compatibility */
269
+ setQ(q) {
270
+ console && console.warn("setQ does nothing; ES6 Promise support is required - use a shim if necessary.");
271
+ }
272
+ /** @hidden @internal */
273
+ _storeObject(obj, type, name) {
274
+ // uncomment this if we make this public.
275
+ //assertParam(obj, "obj").isObject().check();
276
+ //assertParam(name, "objName").isString().check();
277
+ let key = (typeof (type) === "string" ? type : type.prototype._$typeName) + "." + name;
278
+ this.objectRegistry[key] = obj;
279
+ }
280
+ /** @hidden @internal */
281
+ _fetchObject(type, name) {
282
+ if (!name)
283
+ return undefined;
284
+ let key = (typeof (type) === "string" ? type : type.prototype._$typeName) + "." + name;
285
+ let result = this.objectRegistry[key];
286
+ if (!result) {
287
+ throw new Error("Unable to locate a registered object by the name: " + key);
288
+ }
289
+ return result;
290
+ }
291
+ /**
292
+ Registers the default adapter for an interface that has none, so that Breeze works with no
293
+ configuration at all (see default-adapters.ts). It runs only when the interface is first
294
+ asked for and nothing has been registered for it, so importing Breeze still registers
295
+ nothing, and anything an application registers wins. A named lookup falls back only when
296
+ the name is the default adapter's own.
297
+ @hidden @internal
298
+ */
299
+ _registerDefaultAdapter(idef, interfaceName, adapterName) {
300
+ const fallback = defaultAdapters[interfaceName];
301
+ if (!fallback)
302
+ return undefined;
303
+ if (!adapterName && fallback.namedOnly)
304
+ return undefined;
305
+ const name = new fallback.ctor().name;
306
+ if (adapterName && adapterName.toLowerCase() !== name.toLowerCase())
307
+ return undefined;
308
+ this.registerAdapter(interfaceName, fallback.ctor);
309
+ return idef.getImpl(name);
310
+ }
311
+ /** @hidden @internal */
312
+ _initializeAdapterInstanceCore(interfaceDef, impl, isDefault) {
313
+ let instance;
314
+ let inst = impl.defaultInstance;
315
+ if (!inst) {
316
+ instance = new (impl.ctor)();
317
+ impl.defaultInstance = instance;
318
+ instance._$impl = impl;
319
+ }
320
+ else {
321
+ instance = inst;
322
+ }
323
+ instance.initialize();
324
+ if (isDefault) {
325
+ // next line needs to occur before any recomposition
326
+ interfaceDef.defaultInstance = instance;
327
+ }
328
+ // recomposition of other impls will occur here.
329
+ this.interfaceInitialized.publish({ interfaceName: interfaceDef.name, instance: instance, isDefault: isDefault });
330
+ // Once per instance, not once per call. An adapter instance is cached on its impl, so
331
+ // re-initializing the same one - which configureBreeze does, and a test suite does over
332
+ // and over - used to add a second subscription for the same object: the subscriber list
333
+ // grew without bound, each duplicate holding the adapter, and checkForRecomposition ran
334
+ // once per duplicate on every later initialization. See the retention tier.
335
+ if (instance.checkForRecomposition != null && !this._recomposers.has(instance)) {
336
+ this._recomposers.add(instance);
337
+ // now register for own dependencies.
338
+ this.interfaceInitialized.subscribe((interfaceInitializedArgs) => {
339
+ // The `!` is needed because narrowing does not reach inside the callback:
340
+ // `instance` is a mutable binding, so TypeScript has to assume the property
341
+ // could have been cleared before the subscription fires. Reading it off
342
+ // `instance` here rather than capturing it in a const is deliberate - that is
343
+ // what gives the adapter its `this`.
344
+ instance.checkForRecomposition(interfaceInitializedArgs);
345
+ });
346
+ }
347
+ return instance;
348
+ }
349
+ }
350
+ /**
351
+ The global {@link BreezeConfig}, used by every `EntityManager`, `MetadataStore` and `DataService`.
352
+
353
+ To configure Breeze, use {@link configureBreeze}, which sets this object's adapters and `fetch`.
354
+ The 2.x calls on it, such as `config.registerAdapter(...)` and
355
+ `config.initializeAdapterInstance(...)`, still work and are not scheduled for removal.
356
+ */
357
+ export const config = new BreezeConfig();
358
+ // The adapter interfaces. They are set here rather than in interface-registry.ts because every
359
+ // adapter lookup needs them, and under "sideEffects": false a bundler drops a module that nothing
360
+ // uses a value from - such as interface-registry.ts, which only the barrel imports. See
361
+ // CHANGES-DEV.md.
362
+ config.interfaceRegistry = new InterfaceRegistry();
363
+ config._interfaceRegistry = config.interfaceRegistry;
364
+ config.interfaceRegistry.modelLibrary.getDefaultInstance = function () {
365
+ // Falls back to the default model library (backingStore) when none is registered.
366
+ const instance = this.defaultInstance || config.getAdapterInstance("modelLibrary");
367
+ if (!instance) {
368
+ throw new Error("Unable to locate the default implementation of the '" + this.name +
369
+ "' interface. Register one with configureBreeze({ modelLibrary: ... }).");
370
+ }
371
+ return instance;
372
+ };
373
+ /** @deprecated Use `configureBreeze({ ... })` instead. Still works; not scheduled for removal. */
374
+ config.initializeAdapterInstances = function (irConfig) {
375
+ // Validate only - rejects unknown keys. This used to apply irConfig onto the global
376
+ // config and then walk every property of *config*, passing things like functionRegistry
377
+ // to initializeAdapterInstance as adapter names, so it always threw. Nothing tested it.
378
+ assertConfig(irConfig)
379
+ .whereParam("dataService").isOptional()
380
+ .whereParam("modelLibrary").isOptional()
381
+ .whereParam("ajax").isOptional()
382
+ .whereParam("uriBuilder").isOptional()
383
+ .applyAll(irConfig, true);
384
+ initOrder.forEach(name => {
385
+ const adapterName = irConfig[name];
386
+ if (adapterName)
387
+ this.initializeAdapterInstance(name, adapterName, true);
388
+ });
389
+ };
390
+ // legacy
391
+ core.config = config;
392
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAc/C,MAAM,OAAO,YAAY;IAErB,IAAI,CAAS;IACb,eAAe,CAAK;IACpB,wBAAwB;IACxB,QAAQ,CAAuB;IAE/B,YAAY,IAAY;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED,wDAAwD;IACxD,YAAY,CAAC,WAAmB,EAAE,IAAoB;QAClD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7F,CAAC;IAED,sDAAsD;IACtD,OAAO,CAAC,WAAmB;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,C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iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;AACnD,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC;AACrD,MAAM,CAAC,iBAAiB,CAAC,YAAY,CAAC,kBAAkB,GAAG;IACvD,kFAAkF;IAClF,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,IAAI,MAAM,CAAC,kBAAkB,CAAsB,cAAc,CAAC,CAAC;IACxG,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,sDAAsD,GAAG,IAAI,CAAC,IAAI;YAC9E,wEAAwE,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAEF,kGAAkG;AAClG,MAAM,CAAC,0BAA0B,GAAG,UAAU,QAAiC;IAC3E,oFAAoF;IACpF,wFAAwF;IACxF,wFAAwF;IACxF,YAAY,CAAC,QAAQ,CAAC;SACjB,UAAU,CAAC,aAAa,CAAC,CAAC,UAAU,EAAE;SACtC,UAAU,CAAC,cAAc,CAAC,CAAC,UAAU,EAAE;SACvC,UAAU,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE;SAC/B,UAAU,CAAC,YAAY,CAAC,CAAC,UAAU,EAAE;SACrC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC9B,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACrB,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,WAAW;YAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,SAAS;AACR,IAAY,CAAC,MAAM,GAAG,MAAM,CAAC","sourcesContent":["import type { AjaxAdapter, BreezeFetch, DataServiceAdapter, InterfaceRegistryConfig, ModelLibraryAdapter, UriBuilderAdapter } from './interface-registry.js';\r\nimport { core } from '../core/core.js';\r\nimport { assertParam, assertConfig } from '../core/assert-param.js';\r\nimport { BreezeEvent } from '../core/event.js';\r\n\r\n/** @hidden */\r\nexport interface AdapterCtor<T extends BaseAdapter> { new (...args: any[]): T; }\r\n/** @hidden */\r\nexport interface IDef<T extends BaseAdapter> { ctor: AdapterCtor<T>; defaultInstance?: T; }\r\n\r\n/**\r\nThe names of the adapter interfaces, as passed to the 2.x-style methods on {@link BreezeConfig}\r\nsuch as `registerAdapter` and `initializeAdapterInstance`. With {@link configureBreeze} you pass\r\nthe adapter classes instead and never need these names.\r\n*/\r\nexport type AdapterType = 'dataService'|'modelLibrary'|'ajax'|'uriBuilder';\r\n\r\nexport class InterfaceDef<T extends BaseAdapter> {\r\n\r\n name: string;\r\n defaultInstance?: T;\r\n /** @hidden @internal */\r\n _implMap: Map<string, IDef<T>>;\r\n\r\n constructor(name: string) {\r\n this.name = name;\r\n this.defaultInstance = undefined;\r\n this._implMap = new Map();\r\n }\r\n\r\n /** Define an implementation of the given adaptername */\r\n registerCtor(adapterName: string, ctor: AdapterCtor<T>): void {\r\n this._implMap.set(adapterName.toLowerCase(), { ctor: ctor, defaultInstance: undefined });\r\n }\r\n\r\n /** Return the definition for the given adapterName */\r\n getImpl(adapterName: string): IDef<T> {\r\n return this._implMap.get(adapterName.toLowerCase()) as IDef<T>;\r\n }\r\n\r\n /** Return the first implementation for this InterfaceDef */\r\n getFirstImpl(): IDef<T> {\r\n // Map preserves insertion order, so 'first' is well defined here.\r\n const first = this._implMap.values().next();\r\n return first.done ? null as any : first.value;\r\n }\r\n\r\n getDefaultInstance() {\r\n return this.defaultInstance as T;\r\n }\r\n}\r\n\r\n/** Registers adapters used by Breeze */\r\nexport class InterfaceRegistry {\r\n /** Creates a registry with no adapters in it. {@link config} holds the one Breeze uses;\r\n applications do not create their own. */\r\n constructor() { }\r\n /** The registered {@link AjaxAdapter}s, and the default one if any. Deprecated: Breeze 3 sends requests through `config.fetch` and needs no ajax adapter. */\r\n ajax = new InterfaceDef<AjaxAdapter>(\"ajax\");\r\n /** The registered {@link ModelLibraryAdapter}s, and the default one. */\r\n modelLibrary = new InterfaceDef<ModelLibraryAdapter>(\"modelLibrary\");\r\n /** The registered {@link DataServiceAdapter}s, and the default one. */\r\n dataService = new InterfaceDef<DataServiceAdapter>(\"dataService\");\r\n /** The registered {@link UriBuilderAdapter}s, and the default one. */\r\n uriBuilder = new InterfaceDef<UriBuilderAdapter>(\"uriBuilder\");\r\n}\r\n\r\n// The data service adapter resolves the ajax adapter when it initializes, so ajax has to\r\n// come first. Same order as configureBreeze.\r\nconst initOrder: AdapterType[] = ['modelLibrary', 'uriBuilder', 'ajax', 'dataService'];\r\n\r\n/**\r\nWhat every Breeze adapter implements: the model library, data service, URI builder and\r\n(deprecated) ajax adapters all extend this interface.\r\n*/\r\nexport interface BaseAdapter {\r\n /** @hidden @internal */\r\n _$impl?: any;\r\n /**\r\n The name the adapter is registered under, such as `'webApi'` or `'backingStore'`. Names are\r\n matched without regard to case. `registerAdapter` reads it from a throwaway instance and throws\r\n if it is empty.\r\n */\r\n name: string;\r\n /**\r\n Called by Breeze each time the adapter is initialized: when it is first created, and again\r\n whenever it is initialized by name or registered again, for example by {@link configureBreeze}.\r\n Resolve anything the adapter depends on here, not in the constructor.\r\n */\r\n initialize(): void;\r\n /**\r\n Optional. Called each time any adapter is initialized after this one first was, with\r\n `{ interfaceName, instance, isDefault }`, so that this adapter can pick up a new dependency. The data service adapters use\r\n it to re-resolve their ajax adapter when a new default ajax adapter is initialized.\r\n */\r\n checkForRecomposition?: (context: any) => void;\r\n}\r\n\r\n/**\r\nAn adapter Breeze falls back to for an interface when nothing has been registered for it.\r\n@hidden\r\n*/\r\nexport interface DefaultAdapter {\r\n ctor: AdapterCtor<any>;\r\n /** Use only when asked for by name, never as the unnamed default. */\r\n namedOnly?: boolean;\r\n}\r\n\r\nconst defaultAdapters: Partial<Record<AdapterType, DefaultAdapter>> = {};\r\n\r\n/**\r\nSets the adapters Breeze falls back to when none has been registered for an interface.\r\nCalled once, by default-adapters.ts; applies to every BreezeConfig.\r\n@hidden @internal\r\n*/\r\nexport function setDefaultAdapters(defaults: Partial<Record<AdapterType, DefaultAdapter>>) {\r\n Object.assign(defaultAdapters, defaults);\r\n}\r\n\r\n/**\r\nBreeze's global configuration: the adapter registry, the `fetch` transport, and registries Breeze\r\nuses to find functions and objects by name when it deserializes metadata. The single instance is\r\n{@link config}.\r\n\r\nTo configure Breeze, use {@link configureBreeze}. The adapter methods here (`registerAdapter`,\r\n`initializeAdapterInstance`, `getAdapterInstance` and the rest) are the 2.x API. They still\r\nwork, and adapters' own static `register()` methods use them, but an application does not\r\nnormally need to call them.\r\n*/\r\nexport class BreezeConfig {\r\n /**\r\n Functions registered by name with {@link BreezeConfig.registerFunction}. Breeze looks up\r\n validator factories here, under `\"Validator.\" + name`, when it imports metadata. Applications do\r\n not normally need it; use {@link Validator.register} and {@link Validator.registerFactory}.\r\n */\r\n functionRegistry: Record<string, Function> = {};\r\n /**\r\n Constructors registered by name with {@link BreezeConfig.registerType}. Nothing in Breeze 3\r\n reads it; applications do not normally need it.\r\n */\r\n typeRegistry: Record<string, Function> = {};\r\n /**\r\n Named instances Breeze can find again by name, keyed `\"<TypeName>.<name>\"`: every\r\n {@link JsonResultsAdapter}, {@link NamingConvention} and {@link LocalQueryComparisonOptions}\r\n registers itself here when created. Breeze uses it to resolve the names in exported metadata and\r\n exported entities. Applications do not normally need it.\r\n */\r\n objectRegistry: Record<string, any> = {};\r\n /**\r\n Published each time an adapter is initialized, with the interface name, the adapter instance\r\n and whether it became the default for its interface. Breeze uses it to let adapters that depend\r\n on each other recompose (see {@link BaseAdapter.checkForRecomposition}); applications do not\r\n normally need it.\r\n */\r\n interfaceInitialized: BreezeEvent<{\r\n /** The interface the adapter implements: `\"ajax\"`, `\"dataService\"`, `\"modelLibrary\"` or `\"uriBuilder\"`. */\r\n interfaceName: string,\r\n /** The adapter that was initialized. */\r\n instance: BaseAdapter,\r\n /** Whether it became the default adapter for its interface. */\r\n isDefault: boolean\r\n }>;\r\n\r\n /**\r\n * Adapter instances already subscribed to `interfaceInitialized` for recomposition, so that\r\n * re-initializing one does not subscribe it twice. Weak because the entry is only ever looked\r\n * up for an instance in hand, and one outliving its adapter would be its own small leak.\r\n * @hidden @internal\r\n */\r\n private _recomposers = new WeakSet<BaseAdapter>();\r\n\r\n /**\r\n The indentation Breeze passes to `JSON.stringify` when it serializes exported entities\r\n (`EntityManager.exportEntities`) and exported metadata (`MetadataStore.exportMetadata`).\r\n The default, `''`, produces compact JSON; set it to, say, `' '` for readable output.\r\n */\r\n stringifyPad = '';\r\n /**\r\n * The function Breeze makes HTTP requests with, unless a (deprecated) ajax adapter is\r\n * registered. Set it with `configureBreeze({ fetch })`. When unset, `globalThis.fetch`.\r\n */\r\n fetch?: BreezeFetch;\r\n /** @hidden @internal */\r\n _interfaceRegistry: any; // set below, on the global config. Untyped: getInterfaceDef looks interfaces up by name.\r\n /** @hidden @internal The adapter interfaces, strongly typed. Set below, on the global config. */\r\n declare interfaceRegistry: InterfaceRegistry;\r\n /**\r\n Initializes a collection of adapter implementations and makes each one the default for its corresponding interface.\r\n @deprecated Use `configureBreeze({ ... })` instead. Still works; not scheduled for removal.\r\n @param irConfig - The name of a previously registered adapter for each interface to initialize,\r\n e.g. `{ ajax: 'fetch', dataService: 'webApi' }`. Interfaces not named are left as they are.\r\n @hidden @internal\r\n */\r\n declare initializeAdapterInstances: (irConfig: InterfaceRegistryConfig) => void;\r\n\r\n /** Creates a configuration with nothing registered. Breeze creates the one instance there is,\r\n {@link config}; applications do not create their own. */\r\n constructor() {\r\n this.interfaceInitialized = new BreezeEvent(\"interfaceInitialized\", this);\r\n }\r\n\r\n /**\r\n Method use to register implementations of standard breeze interfaces. Calls to this method are usually\r\n made as the last step within an adapter implementation.\r\n @param interfaceName {String} - one of the following interface names: \"ajax\", \"dataService\", \"modelLibrary\", \"uriBuilder\"\r\n @param adapterCtor {Function} - an ctor function that returns an instance of the specified interface.\r\n\r\n @deprecated For configuring an application, use `configureBreeze({ ajax: MyAdapter, ... })`\r\n instead: the adapter classes are passed directly, so a misspelled name is a compile error\r\n rather than a runtime one. An adapter's own static `register()` still calls this - that is\r\n how an adapter registers itself, and is not deprecated. Not scheduled for removal.\r\n */\r\n registerAdapter<T extends BaseAdapter>(interfaceName: AdapterType, adapterCtor: AdapterCtor<T>) {\r\n assertParam(interfaceName, \"interfaceName\").isNonEmptyString().check();\r\n assertParam(adapterCtor, \"adapterCtor\").isFunction().check();\r\n // this impl will be thrown away after the name is retrieved.\r\n let impl = new adapterCtor();\r\n let implName = impl.name;\r\n if (!implName) {\r\n throw new Error(\"Unable to locate a 'name' property on the constructor passed into the 'registerAdapter' call.\");\r\n }\r\n let idef = this.getInterfaceDef(interfaceName);\r\n idef.registerCtor(implName, adapterCtor);\r\n }\r\n\r\n /**\r\n Returns the ctor function used to implement a specific interface with a specific adapter name.\r\n @param interfaceName {String} One of the following interface names: \"ajax\", \"dataService\", \"modelLibrary\", \"uriBuilder\"\r\n @param [adapterName] {String} The name of any previously registered adapter. If this parameter is omitted then\r\n this method returns the \"default\" adapter for this interface. If there is no default adapter, then a null is returned.\r\n @returns {Function|null} Returns either a ctor function or null.\r\n */\r\n getAdapter(interfaceName: AdapterType, adapterName: string) {\r\n let idef = this.getInterfaceDef(interfaceName);\r\n if (adapterName) {\r\n let impl = idef.getImpl(adapterName);\r\n return impl ? impl.ctor : null;\r\n } else {\r\n return idef.defaultInstance ? idef.defaultInstance._$impl.ctor : null;\r\n }\r\n }\r\n\r\n /**\r\n Initializes a single adapter implementation. Initialization means either newing a instance of the\r\n specified interface and then calling \"initialize\" on it or simply calling \"initialize\" on the instance\r\n if it already exists.\r\n @param interfaceName {String} The name of the interface to which the adapter to initialize belongs.\r\n @param adapterName {String} - The name of a previously registered adapter to initialize.\r\n @param [isDefault=true] {Boolean} - Whether to make this the default \"adapter\" for this interface.\r\n @returns {an instance of the specified adapter}\r\n\r\n @deprecated For configuring an application, use `configureBreeze({ ajax: MyAdapter, ... })`\r\n instead: the adapter classes are passed directly, so a misspelled name is a compile error\r\n rather than a runtime one. An adapter's own static `register()` still calls this - that is\r\n how an adapter registers itself, and is not deprecated. Not scheduled for removal.\r\n */\r\n initializeAdapterInstance(interfaceName: AdapterType, adapterName: string, isDefault: boolean = true) {\r\n isDefault = isDefault === undefined ? true : isDefault;\r\n assertParam(interfaceName, \"interfaceName\").isNonEmptyString().check();\r\n assertParam(adapterName, \"adapterName\").isNonEmptyString().check();\r\n assertParam(isDefault, \"isDefault\").isBoolean().check();\r\n\r\n let idef = this.getInterfaceDef(interfaceName);\r\n let impl = idef.getImpl(adapterName) || this._registerDefaultAdapter(idef, interfaceName, adapterName);\r\n if (!impl) {\r\n throw new Error(\"Unregistered adapter. Interface: \" + interfaceName + \" AdapterName: \" + adapterName);\r\n }\r\n\r\n return this._initializeAdapterInstanceCore(idef, impl, isDefault);\r\n }\r\n\r\n /**\r\n Returns the adapter instance corresponding to the specified interface and adapter names.\r\n @param interfaceName {String} The name of the interface.\r\n @param [adapterName] {String} - The name of a previously registered adapter. If this parameter is\r\n omitted then the default implementation of the specified interface is returned. If there is\r\n no defaultInstance of this interface, then the first registered instance of this interface is returned.\r\n @returns {an instance of the specified adapter}\r\n */\r\n getAdapterInstance<T extends BaseAdapter>(interfaceName: AdapterType, adapterName?: string) {\r\n let idef = this.getInterfaceDef<T>(interfaceName);\r\n let impl: IDef<T>;\r\n\r\n let isDefault = adapterName == null || adapterName === \"\";\r\n if (isDefault) {\r\n if (idef.defaultInstance) return idef.defaultInstance;\r\n impl = idef.getFirstImpl();\r\n } else {\r\n impl = idef.getImpl(adapterName!);\r\n }\r\n if (!impl) impl = this._registerDefaultAdapter(idef, interfaceName, isDefault ? undefined : adapterName)!;\r\n if (!impl) return undefined;\r\n if (impl.defaultInstance) {\r\n return impl.defaultInstance;\r\n } else {\r\n return this._initializeAdapterInstanceCore(idef, impl, isDefault);\r\n }\r\n }\r\n\r\n /** this is needed for reflection purposes when deserializing an object that needs a fn or ctor.\r\n Used to register validators. */\r\n registerFunction(fn: Function, fnName: string) {\r\n assertParam(fn, \"fn\").isFunction().check();\r\n assertParam(fnName, \"fnName\").isString().check();\r\n if (fn.prototype) {\r\n fn.prototype._$fnName = fnName;\r\n }\r\n this.functionRegistry[fnName] = fn;\r\n }\r\n\r\n /**\r\n Registers a constructor under a type name: stamps the name on its prototype as `_$typeName` and\r\n adds it to {@link BreezeConfig.typeRegistry}. Breeze registers `KeyGenerator` this way;\r\n applications do not normally need it.\r\n @param ctor - The constructor to register.\r\n @param typeName - The name to register it under.\r\n */\r\n registerType(ctor: Function, typeName: string) {\r\n assertParam(ctor, \"ctor\").isFunction().check();\r\n assertParam(typeName, \"typeName\").isString().check();\r\n if (ctor.prototype) {\r\n ctor.prototype._$typeName = typeName;\r\n }\r\n this.typeRegistry[typeName] = ctor;\r\n }\r\n\r\n /**\r\n Returns the function registered under the given name with {@link BreezeConfig.registerFunction},\r\n or `undefined` if there is none. Validators are registered as `\"Validator.\" + name`, so\r\n `config.getRegisteredFunction('Validator.maxLength')` returns the `maxLength` factory.\r\n @param fnName - The name the function was registered under.\r\n */\r\n getRegisteredFunction(fnName: string) {\r\n return this.functionRegistry[fnName];\r\n }\r\n\r\n /**\r\n Returns the registry entry for one adapter interface, which holds its registered adapters and\r\n its default instance. The name is matched without regard to case.\r\n Used by the adapter registration methods; applications do not normally need it.\r\n @param interfaceName - `'ajax'`, `'dataService'`, `'modelLibrary'` or `'uriBuilder'`.\r\n @throws if there is no interface with that name.\r\n */\r\n getInterfaceDef<T extends BaseAdapter>(interfaceName: string) {\r\n let lcName = interfaceName.toLowerCase();\r\n // source may be null\r\n let kv = core.objectFirst(this._interfaceRegistry || {}, function (k, v) {\r\n return k.toLowerCase() === lcName;\r\n });\r\n if (!kv) {\r\n throw new Error(\"Unknown interface name: \" + interfaceName);\r\n }\r\n return <InterfaceDef<T>>kv.value;\r\n }\r\n\r\n /** @deprecated @internal no-op kept for backward compatibility */\r\n setQ(q: any) {\r\n console && console.warn(\"setQ does nothing; ES6 Promise support is required - use a shim if necessary.\");\r\n }\r\n\r\n /** @hidden @internal */\r\n _storeObject(obj: Object, type: string | Function, name: string) {\r\n // uncomment this if we make this public.\r\n //assertParam(obj, \"obj\").isObject().check();\r\n //assertParam(name, \"objName\").isString().check();\r\n let key = (typeof (type) === \"string\" ? type : type.prototype._$typeName) + \".\" + name;\r\n this.objectRegistry[key] = obj;\r\n }\r\n\r\n /** @hidden @internal */\r\n _fetchObject(type: string | Function, name: string) {\r\n if (!name) return undefined;\r\n let key = (typeof (type) === \"string\" ? type : type.prototype._$typeName) + \".\" + name;\r\n let result = this.objectRegistry[key];\r\n if (!result) {\r\n throw new Error(\"Unable to locate a registered object by the name: \" + key);\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n Registers the default adapter for an interface that has none, so that Breeze works with no\r\n configuration at all (see default-adapters.ts). It runs only when the interface is first\r\n asked for and nothing has been registered for it, so importing Breeze still registers\r\n nothing, and anything an application registers wins. A named lookup falls back only when\r\n the name is the default adapter's own.\r\n @hidden @internal\r\n */\r\n _registerDefaultAdapter<T extends BaseAdapter>(idef: InterfaceDef<T>, interfaceName: AdapterType, adapterName?: string): IDef<T> | undefined {\r\n const fallback = defaultAdapters[interfaceName];\r\n if (!fallback) return undefined;\r\n if (!adapterName && fallback.namedOnly) return undefined;\r\n const name: string = new fallback.ctor().name;\r\n if (adapterName && adapterName.toLowerCase() !== name.toLowerCase()) return undefined;\r\n this.registerAdapter(interfaceName, fallback.ctor);\r\n return idef.getImpl(name);\r\n }\r\n\r\n /** @hidden @internal */\r\n _initializeAdapterInstanceCore<T extends BaseAdapter>(interfaceDef: InterfaceDef<T>, impl: IDef<T>, isDefault: boolean) {\r\n let instance: T;\r\n let inst = impl.defaultInstance;\r\n if (!inst) {\r\n instance = new (impl.ctor)();\r\n impl.defaultInstance = instance;\r\n instance._$impl = impl;\r\n } else {\r\n instance = inst;\r\n }\r\n\r\n instance.initialize();\r\n\r\n if (isDefault) {\r\n // next line needs to occur before any recomposition\r\n interfaceDef.defaultInstance = instance;\r\n }\r\n\r\n // recomposition of other impls will occur here.\r\n this.interfaceInitialized.publish({ interfaceName: interfaceDef.name, instance: instance, isDefault: isDefault });\r\n\r\n // Once per instance, not once per call. An adapter instance is cached on its impl, so\r\n // re-initializing the same one - which configureBreeze does, and a test suite does over\r\n // and over - used to add a second subscription for the same object: the subscriber list\r\n // grew without bound, each duplicate holding the adapter, and checkForRecomposition ran\r\n // once per duplicate on every later initialization. See the retention tier.\r\n if (instance.checkForRecomposition != null && !this._recomposers.has(instance)) {\r\n this._recomposers.add(instance);\r\n // now register for own dependencies.\r\n this.interfaceInitialized.subscribe((interfaceInitializedArgs) => {\r\n // The `!` is needed because narrowing does not reach inside the callback:\r\n // `instance` is a mutable binding, so TypeScript has to assume the property\r\n // could have been cleared before the subscription fires. Reading it off\r\n // `instance` here rather than capturing it in a const is deliberate - that is\r\n // what gives the adapter its `this`.\r\n instance.checkForRecomposition!(interfaceInitializedArgs);\r\n });\r\n }\r\n\r\n return instance;\r\n }\r\n\r\n}\r\n\r\n/**\r\nThe global {@link BreezeConfig}, used by every `EntityManager`, `MetadataStore` and `DataService`.\r\n\r\nTo configure Breeze, use {@link configureBreeze}, which sets this object's adapters and `fetch`.\r\nThe 2.x calls on it, such as `config.registerAdapter(...)` and\r\n`config.initializeAdapterInstance(...)`, still work and are not scheduled for removal.\r\n*/\r\nexport const config = new BreezeConfig();\r\n\r\n// The adapter interfaces. They are set here rather than in interface-registry.ts because every\r\n// adapter lookup needs them, and under \"sideEffects\": false a bundler drops a module that nothing\r\n// uses a value from - such as interface-registry.ts, which only the barrel imports. See\r\n// CHANGES-DEV.md.\r\nconfig.interfaceRegistry = new InterfaceRegistry();\r\nconfig._interfaceRegistry = config.interfaceRegistry;\r\nconfig.interfaceRegistry.modelLibrary.getDefaultInstance = function() {\r\n // Falls back to the default model library (backingStore) when none is registered.\r\n const instance = this.defaultInstance || config.getAdapterInstance<ModelLibraryAdapter>(\"modelLibrary\");\r\n if (!instance) {\r\n throw new Error(\"Unable to locate the default implementation of the '\" + this.name +\r\n \"' interface. Register one with configureBreeze({ modelLibrary: ... }).\");\r\n }\r\n return instance;\r\n};\r\n\r\n/** @deprecated Use `configureBreeze({ ... })` instead. Still works; not scheduled for removal. */\r\nconfig.initializeAdapterInstances = function (irConfig: InterfaceRegistryConfig) {\r\n // Validate only - rejects unknown keys. This used to apply irConfig onto the global\r\n // config and then walk every property of *config*, passing things like functionRegistry\r\n // to initializeAdapterInstance as adapter names, so it always threw. Nothing tested it.\r\n assertConfig(irConfig)\r\n .whereParam(\"dataService\").isOptional()\r\n .whereParam(\"modelLibrary\").isOptional()\r\n .whereParam(\"ajax\").isOptional()\r\n .whereParam(\"uriBuilder\").isOptional()\r\n .applyAll(irConfig, true);\r\n initOrder.forEach(name => {\r\n const adapterName = irConfig[name];\r\n if (adapterName) this.initializeAdapterInstance(name, adapterName, true);\r\n });\r\n};\r\n\r\n// legacy\r\n(core as any).config = config;\r\n\r\n\r\n\r\n"]}
@@ -0,0 +1,66 @@
1
+ import { BreezeConfig } from './config.js';
2
+ import { BreezeFetch } from './interface-registry.js';
3
+ import { NamingConvention } from '../metadata/naming-convention.js';
4
+ /**
5
+ * Anything with a static `register` method - which is every Breeze adapter.
6
+ * @hidden
7
+ */
8
+ export interface AdapterRegistration {
9
+ register(breezeConfig?: BreezeConfig, ...rest: any[]): any;
10
+ }
11
+ /** An ajax adapter, which may additionally accept a custom transport. */
12
+ export interface AjaxAdapterRegistration {
13
+ /**
14
+ * Registers the adapter and initializes it as the default ajax adapter, as
15
+ * `AjaxFetchAdapter.register` does. {@link configureBreeze} calls it
16
+ * with its target config and, when you pass one, the `fetch` option as the adapter's transport.
17
+ */
18
+ register(breezeConfig?: BreezeConfig, fetchFn?: BreezeFetch): any;
19
+ }
20
+ /** Options accepted by {@link configureBreeze}. */
21
+ export interface BreezeSetupOptions {
22
+ /** Model library adapter. Defaults to `ModelLibraryBackingStoreAdapter`. */
23
+ modelLibrary?: AdapterRegistration;
24
+ /** Uri builder adapter. Defaults to `UriBuilderJsonAdapter`. */
25
+ uriBuilder?: AdapterRegistration;
26
+ /**
27
+ * @deprecated Breeze no longer needs an ajax adapter: requests go through `fetch`.
28
+ * Passing one still works. It is registered as in 2.x and used instead of `config.fetch`,
29
+ * and is handed `fetch` as its transport if you supply both.
30
+ */
31
+ ajax?: AjaxAdapterRegistration;
32
+ /** Data service adapter. Defaults to `DataServiceWebApiAdapter`. */
33
+ dataService?: AdapterRegistration;
34
+ /**
35
+ * The function Breeze makes every HTTP request with. Use it to add auth headers, retry or
36
+ * logging, or to route requests through a framework HTTP client. Sets `config.fetch`;
37
+ * defaults to `globalThis.fetch`.
38
+ */
39
+ fetch?: BreezeFetch;
40
+ /** Sets the default NamingConvention. Defaults to `NamingConvention.camelCase`; use `NamingConvention.none` when the server already sends the names the client should use. */
41
+ namingConvention?: NamingConvention;
42
+ /** Configure a BreezeConfig other than the global one. Rarely needed. */
43
+ config?: BreezeConfig;
44
+ }
45
+ /**
46
+ * Configures Breeze in a single typed call.
47
+ *
48
+ * Every option is optional, and a Breeze .NET server needs none of them. With no call at
49
+ * all, Breeze uses its default adapters - the backing-store model library, the JSON uri
50
+ * builder and the Web API data service - sends requests through `globalThis.fetch`, and
51
+ * maps property names with `NamingConvention.camelCase`.
52
+ *
53
+ * ```ts
54
+ * import { configureBreeze, NamingConvention } from 'breeze-client';
55
+ *
56
+ * // a server that already sends the names the client should use, with an auth transport
57
+ * configureBreeze({ namingConvention: NamingConvention.none, fetch: myAuthFetch });
58
+ * ```
59
+ *
60
+ * Pass an adapter to replace a default, e.g. `configureBreeze({ dataService: MyAdapter })`.
61
+ *
62
+ * This replaces the stringly-typed pairs of `config.registerAdapter("dataService", Ctor)`
63
+ * and `config.initializeAdapterInstance("dataService", "webApi", true)`. Those still work and
64
+ * are unchanged, but are deprecated.
65
+ */
66
+ export declare function configureBreeze(options: BreezeSetupOptions): void;
@@ -0,0 +1,46 @@
1
+ import { config } from './config.js';
2
+ /**
3
+ * Configures Breeze in a single typed call.
4
+ *
5
+ * Every option is optional, and a Breeze .NET server needs none of them. With no call at
6
+ * all, Breeze uses its default adapters - the backing-store model library, the JSON uri
7
+ * builder and the Web API data service - sends requests through `globalThis.fetch`, and
8
+ * maps property names with `NamingConvention.camelCase`.
9
+ *
10
+ * ```ts
11
+ * import { configureBreeze, NamingConvention } from 'breeze-client';
12
+ *
13
+ * // a server that already sends the names the client should use, with an auth transport
14
+ * configureBreeze({ namingConvention: NamingConvention.none, fetch: myAuthFetch });
15
+ * ```
16
+ *
17
+ * Pass an adapter to replace a default, e.g. `configureBreeze({ dataService: MyAdapter })`.
18
+ *
19
+ * This replaces the stringly-typed pairs of `config.registerAdapter("dataService", Ctor)`
20
+ * and `config.initializeAdapterInstance("dataService", "webApi", true)`. Those still work and
21
+ * are unchanged, but are deprecated.
22
+ */
23
+ export function configureBreeze(options) {
24
+ const cfg = options.config || config;
25
+ if (options.modelLibrary) {
26
+ options.modelLibrary.register(cfg);
27
+ }
28
+ if (options.uriBuilder) {
29
+ options.uriBuilder.register(cfg);
30
+ }
31
+ if (options.fetch) {
32
+ cfg.fetch = options.fetch;
33
+ }
34
+ if (options.ajax) {
35
+ // Deprecated path. A registered ajax adapter takes precedence over config.fetch, so it
36
+ // is handed the same transport.
37
+ options.ajax.register(cfg, options.fetch);
38
+ }
39
+ if (options.dataService) {
40
+ options.dataService.register(cfg);
41
+ }
42
+ if (options.namingConvention) {
43
+ options.namingConvention.setAsDefault();
44
+ }
45
+ }
46
+ //# sourceMappingURL=configure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configure.js","sourceRoot":"","sources":["../../src/config/configure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,aAAa,CAAC;AAmDnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,eAAe,CAAC,OAA2B;IACzD,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC;IAErC,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACzB,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,uFAAuF;QACvF,gCAAgC;QAChC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,OAAO,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC;IAC1C,CAAC;AACH,CAAC","sourcesContent":["import { BreezeConfig, config } from './config.js';\nimport { BreezeFetch } from './interface-registry.js';\nimport { NamingConvention } from '../metadata/naming-convention.js';\n\n/**\n * Anything with a static `register` method - which is every Breeze adapter.\n * @hidden\n */\nexport interface AdapterRegistration {\n register(breezeConfig?: BreezeConfig, ...rest: any[]): any;\n}\n\n/** An ajax adapter, which may additionally accept a custom transport. */\nexport interface AjaxAdapterRegistration {\n /**\n * Registers the adapter and initializes it as the default ajax adapter, as\n * `AjaxFetchAdapter.register` does. {@link configureBreeze} calls it\n * with its target config and, when you pass one, the `fetch` option as the adapter's transport.\n */\n register(breezeConfig?: BreezeConfig, fetchFn?: BreezeFetch): any;\n}\n\n/** Options accepted by {@link configureBreeze}. */\nexport interface BreezeSetupOptions {\n /** Model library adapter. Defaults to `ModelLibraryBackingStoreAdapter`. */\n modelLibrary?: AdapterRegistration;\n /** Uri builder adapter. Defaults to `UriBuilderJsonAdapter`. */\n uriBuilder?: AdapterRegistration;\n /**\n * @deprecated Breeze no longer needs an ajax adapter: requests go through `fetch`.\n * Passing one still works. It is registered as in 2.x and used instead of `config.fetch`,\n * and is handed `fetch` as its transport if you supply both.\n */\n ajax?: AjaxAdapterRegistration;\n /** Data service adapter. Defaults to `DataServiceWebApiAdapter`. */\n dataService?: AdapterRegistration;\n\n /**\n * The function Breeze makes every HTTP request with. Use it to add auth headers, retry or\n * logging, or to route requests through a framework HTTP client. Sets `config.fetch`;\n * defaults to `globalThis.fetch`.\n */\n fetch?: BreezeFetch;\n\n /** Sets the default NamingConvention. Defaults to `NamingConvention.camelCase`; use `NamingConvention.none` when the server already sends the names the client should use. */\n namingConvention?: NamingConvention;\n\n /** Configure a BreezeConfig other than the global one. Rarely needed. */\n config?: BreezeConfig;\n}\n\n/**\n * Configures Breeze in a single typed call.\n *\n * Every option is optional, and a Breeze .NET server needs none of them. With no call at\n * all, Breeze uses its default adapters - the backing-store model library, the JSON uri\n * builder and the Web API data service - sends requests through `globalThis.fetch`, and\n * maps property names with `NamingConvention.camelCase`.\n *\n * ```ts\n * import { configureBreeze, NamingConvention } from 'breeze-client';\n *\n * // a server that already sends the names the client should use, with an auth transport\n * configureBreeze({ namingConvention: NamingConvention.none, fetch: myAuthFetch });\n * ```\n *\n * Pass an adapter to replace a default, e.g. `configureBreeze({ dataService: MyAdapter })`.\n *\n * This replaces the stringly-typed pairs of `config.registerAdapter(\"dataService\", Ctor)`\n * and `config.initializeAdapterInstance(\"dataService\", \"webApi\", true)`. Those still work and\n * are unchanged, but are deprecated.\n */\nexport function configureBreeze(options: BreezeSetupOptions): void {\n const cfg = options.config || config;\n\n if (options.modelLibrary) {\n options.modelLibrary.register(cfg);\n }\n if (options.uriBuilder) {\n options.uriBuilder.register(cfg);\n }\n if (options.fetch) {\n cfg.fetch = options.fetch;\n }\n if (options.ajax) {\n // Deprecated path. A registered ajax adapter takes precedence over config.fetch, so it\n // is handed the same transport.\n options.ajax.register(cfg, options.fetch);\n }\n if (options.dataService) {\n options.dataService.register(cfg);\n }\n if (options.namingConvention) {\n options.namingConvention.setAsDefault();\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { config } from './config.js';
2
+ import { AjaxFetchAdapter, defaultFetch } from '../adapters/http.js';
3
+ import { UriBuilderJsonAdapter } from '../adapters/adapter-uri-builder-json.js';
4
+ import { DataServiceWebApiAdapter } from '../adapters/adapter-data-service-webapi.js';
5
+ /*
6
+ * The adapters Breeze uses when an application registers none. With no configuration at
7
+ * all, `new EntityManager(serviceName)` tracks changes with the backing-store model library,
8
+ * builds Breeze JSON query URLs, talks to a Breeze .NET server, and sends its requests through
9
+ * `config.fetch` (globalThis.fetch unless set).
10
+ *
11
+ * Nothing is registered here. These fill a fallback table; config.ts registers a default only
12
+ * when an interface is first asked for and nothing has been registered for it, so anything an
13
+ * application registers - before or after - wins.
14
+ *
15
+ * entity-manager.ts installs them, when it loads, by passing `serverDefaultAdapters` to
16
+ * setDefaultAdapters. Using a value from this module is what keeps it in a bundle: an import
17
+ * for effect alone would be dropped under "sideEffects": false (see CHANGES-DEV.md). The model
18
+ * library default is installed by entity-metadata.ts instead, because a MetadataStore needs one
19
+ * even in a bundle with no EntityManager.
20
+ *
21
+ * Only entity-manager.ts imports this module, and nothing this module depends on may import it -
22
+ * entity-metadata.ts, say, or the barrel. That is an import cycle that fails at load time whenever
23
+ * abstract-data-service-adapter.ts loads first: DataServiceWebApiAdapter extends
24
+ * AbstractDataServiceAdapter while its module loads.
25
+ */
26
+ /** What a 2.x-style `initializeAdapterInstance('ajax', 'fetch')` gets: an ajax adapter that
27
+ reads config.fetch on every request, as the default path does. */
28
+ class ConfiguredFetchAjaxAdapter extends AjaxFetchAdapter {
29
+ constructor() {
30
+ super((input, init) => (config.fetch || defaultFetch)(input, init));
31
+ }
32
+ }
33
+ /** The defaults for the server-facing interfaces. @hidden @internal */
34
+ export const serverDefaultAdapters = {
35
+ uriBuilder: { ctor: UriBuilderJsonAdapter },
36
+ dataService: { ctor: DataServiceWebApiAdapter },
37
+ // Never the unnamed default: with no ajax adapter, requests already go through config.fetch.
38
+ ajax: { ctor: ConfiguredFetchAjaxAdapter, namedOnly: true },
39
+ };
40
+ //# sourceMappingURL=default-adapters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-adapters.js","sourceRoot":"","sources":["../../src/config/default-adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;qEACqE;AACrE,MAAM,0BAA2B,SAAQ,gBAAgB;IACvD;QACE,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,YAAY,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IACtE,CAAC;CACF;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,qBAAqB,GAAiD;IACjF,UAAU,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE;IAC3C,WAAW,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE;IAC/C,6FAA6F;IAC7F,IAAI,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE,SAAS,EAAE,IAAI,EAAE;CAC5D,CAAC","sourcesContent":["import { config } from './config.js';\r\nimport type { AdapterType, DefaultAdapter } from './config.js';\r\nimport { AjaxFetchAdapter, defaultFetch } from '../adapters/http.js';\r\nimport { UriBuilderJsonAdapter } from '../adapters/adapter-uri-builder-json.js';\r\nimport { DataServiceWebApiAdapter } from '../adapters/adapter-data-service-webapi.js';\r\n\r\n/*\r\n * The adapters Breeze uses when an application registers none. With no configuration at\r\n * all, `new EntityManager(serviceName)` tracks changes with the backing-store model library,\r\n * builds Breeze JSON query URLs, talks to a Breeze .NET server, and sends its requests through\r\n * `config.fetch` (globalThis.fetch unless set).\r\n *\r\n * Nothing is registered here. These fill a fallback table; config.ts registers a default only\r\n * when an interface is first asked for and nothing has been registered for it, so anything an\r\n * application registers - before or after - wins.\r\n *\r\n * entity-manager.ts installs them, when it loads, by passing `serverDefaultAdapters` to\r\n * setDefaultAdapters. Using a value from this module is what keeps it in a bundle: an import\r\n * for effect alone would be dropped under \"sideEffects\": false (see CHANGES-DEV.md). The model\r\n * library default is installed by entity-metadata.ts instead, because a MetadataStore needs one\r\n * even in a bundle with no EntityManager.\r\n *\r\n * Only entity-manager.ts imports this module, and nothing this module depends on may import it -\r\n * entity-metadata.ts, say, or the barrel. That is an import cycle that fails at load time whenever\r\n * abstract-data-service-adapter.ts loads first: DataServiceWebApiAdapter extends\r\n * AbstractDataServiceAdapter while its module loads.\r\n */\r\n\r\n/** What a 2.x-style `initializeAdapterInstance('ajax', 'fetch')` gets: an ajax adapter that\r\n reads config.fetch on every request, as the default path does. */\r\nclass ConfiguredFetchAjaxAdapter extends AjaxFetchAdapter {\r\n constructor() {\r\n super((input, init) => (config.fetch || defaultFetch)(input, init));\r\n }\r\n}\r\n\r\n/** The defaults for the server-facing interfaces. @hidden @internal */\r\nexport const serverDefaultAdapters: Partial<Record<AdapterType, DefaultAdapter>> = {\r\n uriBuilder: { ctor: UriBuilderJsonAdapter },\r\n dataService: { ctor: DataServiceWebApiAdapter },\r\n // Never the unnamed default: with no ajax adapter, requests already go through config.fetch.\r\n ajax: { ctor: ConfiguredFetchAjaxAdapter, namedOnly: true },\r\n};\r\n"]}