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,202 @@
1
+ import { config } from '../config/config.js';
2
+ import { core } from '../core/core.js';
3
+ import { appendQueryStringParameter, encodeParams } from './adapter-core.js';
4
+ /*
5
+ * How Breeze makes HTTP requests.
6
+ *
7
+ * Breeze 3 needs no ajax adapter. Data service adapters send their requests through
8
+ * `config.fetch` - set with `configureBreeze({ fetch })` - which defaults to
9
+ * `globalThis.fetch`. This module is the one implementation of that path: turning Breeze's
10
+ * description of a request into a fetch call, and reading the response back.
11
+ *
12
+ * The ajax adapter contract (`AjaxAdapter`, the "ajax" registry slot) remains as a
13
+ * deprecated compatibility layer. `AjaxFetchAdapter` is built on the functions here, and so
14
+ * is the adapter data service adapters fall back to when none is registered.
15
+ *
16
+ * This module imports './config' and './core' directly, never the './breeze' barrel: the
17
+ * abstract data service adapter depends on it, and the barrel depends on that.
18
+ */
19
+ /** The transport used when none is supplied. Wrapped so that `fetch` keeps its receiver,
20
+ which some environments require. */
21
+ export const defaultFetch = (input, init) => globalThis.fetch(input, init);
22
+ /** Turns Breeze's description of a request into the arguments for a fetch call. */
23
+ export function toFetchArgs(request) {
24
+ const hasBody = request.type !== "GET" && request.type !== "HEAD";
25
+ // Content-Type describes a body, so a GET gets none - which also keeps it a CORS
26
+ // "simple request" with no preflight. Headers on the request are merged in last; the
27
+ // fetch adapter used to ignore them.
28
+ const headers = {};
29
+ if (hasBody) {
30
+ headers['Content-Type'] = request.contentType || 'application/json';
31
+ }
32
+ Object.assign(headers, request.headers);
33
+ const init = {
34
+ method: request.type,
35
+ mode: 'cors',
36
+ cache: 'no-cache',
37
+ credentials: 'include',
38
+ headers: headers,
39
+ redirect: 'follow',
40
+ // 'referrer' is deliberately unset. 'client' is the browser default, but Node's fetch
41
+ // (undici) rejects it as an invalid URL, so setting it explicitly breaks server-side
42
+ // and test usage for no gain.
43
+ };
44
+ if (hasBody) {
45
+ const data = request.data;
46
+ init.body = typeof data === "string" ? data : JSON.stringify(data);
47
+ }
48
+ let url = request.url;
49
+ if (!core.isEmpty(request.params)) {
50
+ url = appendQueryStringParameter(url, encodeParams(request.params));
51
+ }
52
+ return { url, init };
53
+ }
54
+ /**
55
+ * Sends one request and resolves with its outcome. Never rejects: a transport failure is
56
+ * reported with status 0, and a body that cannot be read with the real HTTP status.
57
+ */
58
+ export async function sendFetch(fetchFn, url, init, request) {
59
+ let response;
60
+ try {
61
+ response = await fetchFn(url, init);
62
+ }
63
+ catch (err) {
64
+ return failure(request, 0, errorText(err), null, null, err);
65
+ }
66
+ let data;
67
+ try {
68
+ data = response.ok ? await response.json() : await response.text();
69
+ }
70
+ catch (err) {
71
+ return failure(request, response.status, 'Unable to read the response body: ' + errorText(err), null, response, err);
72
+ }
73
+ return response.ok
74
+ ? success(request, data, response.statusText, response)
75
+ : failure(request, response.status, response.statusText, data, response, null);
76
+ }
77
+ function success(request, data, statusText, response) {
78
+ return {
79
+ succeeded: true,
80
+ httpResponse: {
81
+ config: request,
82
+ data: data,
83
+ getHeaders: getHeadersFn(response),
84
+ status: response ? response.status : 200,
85
+ statusText: statusText,
86
+ },
87
+ };
88
+ }
89
+ function failure(request, status, statusText, body, response, errorThrown) {
90
+ return {
91
+ succeeded: false,
92
+ httpResponse: {
93
+ config: request,
94
+ data: body,
95
+ error: errorThrown || statusText,
96
+ getHeaders: getHeadersFn(response),
97
+ status: status,
98
+ statusText: statusText,
99
+ },
100
+ };
101
+ }
102
+ function errorText(err) {
103
+ return (err && err.message) || String(err);
104
+ }
105
+ // response is null when the transport itself failed, before any response existed.
106
+ function getHeadersFn(response) {
107
+ if (!response || response.status === 0) { // timeout or abort; no headers
108
+ return function (headerName) {
109
+ return (headerName && headerName.length > 0) ? "" : {};
110
+ };
111
+ }
112
+ return function (headerName) {
113
+ if (headerName && headerName.length > 0) {
114
+ return response.headers.get(headerName);
115
+ }
116
+ const hob = {};
117
+ response.headers.forEach((val, key) => {
118
+ hob[key] = val;
119
+ });
120
+ return hob;
121
+ };
122
+ }
123
+ /**
124
+ * Ajax adapter using the fetch API.
125
+ *
126
+ * @deprecated Breeze 3 needs no ajax adapter: requests go through `config.fetch`, set with
127
+ * `configureBreeze({ fetch })`. This class is kept so that 2.x startup code - `register()`,
128
+ * `configureBreeze({ ajax: AjaxFetchAdapter })`, `config.initializeAdapterInstance('ajax',
129
+ * 'fetch')` - and code using `defaultSettings` or `requestInterceptor` keeps working. It is
130
+ * not scheduled for removal.
131
+ */
132
+ export class AjaxFetchAdapter {
133
+ static adapterName = "fetch";
134
+ name;
135
+ defaultSettings;
136
+ requestInterceptor;
137
+ /** The function used to make the request. Defaults to `globalThis.fetch`. */
138
+ fetchFn;
139
+ constructor(fetchFn) {
140
+ this.name = AjaxFetchAdapter.adapterName;
141
+ this.defaultSettings = {};
142
+ this.requestInterceptor = undefined;
143
+ this.fetchFn = fetchFn || defaultFetch;
144
+ }
145
+ /**
146
+ * @param breezeConfig - defaults to the global breeze config
147
+ * @param fetchFn - the transport this adapter uses. Defaults to `globalThis.fetch`.
148
+ */
149
+ static register(breezeConfig, fetchFn) {
150
+ breezeConfig = breezeConfig || config;
151
+ if (fetchFn) {
152
+ // registerAdapter news up the ctor, so a custom transport needs a factory.
153
+ breezeConfig.registerAdapter("ajax", function () { return new AjaxFetchAdapter(fetchFn); });
154
+ }
155
+ else {
156
+ breezeConfig.registerAdapter("ajax", AjaxFetchAdapter);
157
+ }
158
+ return breezeConfig.initializeAdapterInstance("ajax", AjaxFetchAdapter.adapterName, true);
159
+ }
160
+ initialize() {
161
+ }
162
+ ajax(ajaxConfig) {
163
+ if (!this.fetchFn) {
164
+ throw new Error("fetch API not supported in this browser");
165
+ }
166
+ let { url, init } = toFetchArgs(ajaxConfig);
167
+ if (!core.isEmpty(this.defaultSettings)) {
168
+ let compositeConfig = core.extend({}, this.defaultSettings);
169
+ init = core.extend(compositeConfig, init);
170
+ // extend is shallow; extend headers separately
171
+ let headers = core.extend({}, this.defaultSettings.headers); // copy default headers 1st
172
+ init.headers = core.extend(headers, init.headers);
173
+ }
174
+ // An interceptor may change requestInfo.config (the fetch init), cancel the request by
175
+ // setting it to null, or answer it itself through success/error.
176
+ let requestInfo = {
177
+ adapter: this,
178
+ config: init,
179
+ dsaConfig: ajaxConfig,
180
+ success: (data, statusText, response) => ajaxConfig.success(success(ajaxConfig, data, statusText, response).httpResponse),
181
+ error: (status, statusText, body, response, errorThrown) => ajaxConfig.error(failure(ajaxConfig, status, statusText, body, response, errorThrown).httpResponse),
182
+ };
183
+ if (core.isFunction(this.requestInterceptor)) {
184
+ let ri = this.requestInterceptor;
185
+ ri(requestInfo);
186
+ if (ri.oneTime) {
187
+ this.requestInterceptor = undefined;
188
+ }
189
+ }
190
+ if (requestInfo.config) {
191
+ sendFetch(this.fetchFn, url, requestInfo.config, ajaxConfig).then(outcome => outcome.succeeded ? ajaxConfig.success(outcome.httpResponse) : ajaxConfig.error(outcome.httpResponse));
192
+ }
193
+ }
194
+ }
195
+ /**
196
+ * What a data service adapter uses when no ajax adapter is registered. It sends requests
197
+ * through `config.fetch`, read at call time, so a later `configureBreeze({ fetch })` takes
198
+ * effect without re-initializing anything.
199
+ * @hidden @internal
200
+ */
201
+ export const builtinAjax = new AjaxFetchAdapter((input, init) => (config.fetch || defaultFetch)(input,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C,MAAc,EAAE,UAAkB,EAAE,IAAmB,EAAE,QAAyB,EAAE,WAAgB,EAAE,EAAE,CAC9G,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,YAAY,CAAC;SACtG,CAAC;QAEF,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC7C,IAAI,EAAE,GAAG,IAAI,CAAC,kBAAyB,CAAC;YACxC,EAAE,CAAC,WAAW,CAAC,CAAC;YAChB,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;gBACf,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;YACtC,CAAC;QACH,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACvB,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAC1E,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;QAC3G,CAAC;IACH,CAAC;;AAGH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAgB,IAAI,gBAAgB,CAC1D,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,YAAY,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC","sourcesContent":["import { BreezeConfig, config } from '../config/config.js';\nimport { core } from '../core/core.js';\nimport { appendQueryStringParameter, encodeParams } from './adapter-core.js';\nimport type { AjaxAdapter, AjaxConfig, AjaxRequestInterceptor, BreezeFetch } from '../config/interface-registry.js';\nimport type { HttpResponse } from '../manager/entity-manager.js';\n\n/*\n * How Breeze makes HTTP requests.\n *\n * Breeze 3 needs no ajax adapter. Data service adapters send their requests through\n * `config.fetch` - set with `configureBreeze({ fetch })` - which defaults to\n * `globalThis.fetch`. This module is the one implementation of that path: turning Breeze's\n * description of a request into a fetch call, and reading the response back.\n *\n * The ajax adapter contract (`AjaxAdapter`, the \"ajax\" registry slot) remains as a\n * deprecated compatibility layer. `AjaxFetchAdapter` is built on the functions here, and so\n * is the adapter data service adapters fall back to when none is registered.\n *\n * This module imports './config' and './core' directly, never the './breeze' barrel: the\n * abstract data service adapter depends on it, and the barrel depends on that.\n */\n\n/** The transport used when none is supplied. Wrapped so that `fetch` keeps its receiver,\n which some environments require. */\nexport const defaultFetch: BreezeFetch = (input, init) => globalThis.fetch(input as any, init);\n\n/** Breeze's description of one request, without the callbacks. */\nexport type HttpRequestConfig = Omit<AjaxConfig, 'success' | 'error'>;\n\n/** The outcome of one request. Failures are values, not rejections. */\nexport interface HttpOutcome {\n succeeded: boolean;\n httpResponse: HttpResponse;\n}\n\n/** Turns Breeze's description of a request into the arguments for a fetch call. */\nexport function toFetchArgs(request: HttpRequestConfig): { url: string, init: RequestInit } {\n const hasBody = request.type !== \"GET\" && request.type !== \"HEAD\";\n\n // Content-Type describes a body, so a GET gets none - which also keeps it a CORS\n // \"simple request\" with no preflight. Headers on the request are merged in last; the\n // fetch adapter used to ignore them.\n const headers: Record<string, string> = {};\n if (hasBody) {\n headers['Content-Type'] = request.contentType || 'application/json';\n }\n Object.assign(headers, request.headers);\n\n const init: RequestInit = {\n method: request.type,\n mode: 'cors',\n cache: 'no-cache',\n credentials: 'include',\n headers: headers,\n redirect: 'follow',\n // 'referrer' is deliberately unset. 'client' is the browser default, but Node's fetch\n // (undici) rejects it as an invalid URL, so setting it explicitly breaks server-side\n // and test usage for no gain.\n };\n if (hasBody) {\n const data = request.data;\n init.body = typeof data === \"string\" ? data : JSON.stringify(data);\n }\n\n let url = request.url;\n if (!core.isEmpty(request.params)) {\n url = appendQueryStringParameter(url, encodeParams(request.params!));\n }\n return { url, init };\n}\n\n/**\n * Sends one request and resolves with its outcome. Never rejects: a transport failure is\n * reported with status 0, and a body that cannot be read with the real HTTP status.\n */\nexport async function sendFetch(fetchFn: BreezeFetch, url: string, init: RequestInit,\n request: HttpRequestConfig): Promise<HttpOutcome> {\n let response: Response;\n try {\n response = await fetchFn(url, init);\n } catch (err) {\n return failure(request, 0, errorText(err), null, null, err);\n }\n\n let data: any;\n try {\n data = response.ok ? await response.json() : await response.text();\n } catch (err) {\n return failure(request, response.status, 'Unable to read the response body: ' + errorText(err),\n null, response, err);\n }\n\n return response.ok\n ? success(request, data, response.statusText, response)\n : failure(request, response.status, response.statusText, data, response, null);\n}\n\nfunction success(request: HttpRequestConfig, data: any, statusText: string, response: Response | null): HttpOutcome {\n return {\n succeeded: true,\n httpResponse: {\n config: request,\n data: data,\n getHeaders: getHeadersFn(response),\n status: response ? response.status : 200,\n statusText: statusText,\n } as HttpResponse,\n };\n}\n\nfunction failure(request: HttpRequestConfig, status: number, statusText: string, body: any,\n response: Response | null, errorThrown: any): HttpOutcome {\n return {\n succeeded: false,\n httpResponse: {\n config: request,\n data: body,\n error: errorThrown || statusText,\n getHeaders: getHeadersFn(response),\n status: status,\n statusText: statusText,\n } as HttpResponse,\n };\n}\n\nfunction errorText(err: any): string {\n return (err && err.message) || String(err);\n}\n\n// response is null when the transport itself failed, before any response existed.\nfunction getHeadersFn(response: Response | null): any {\n if (!response || response.status === 0) { // timeout or abort; no headers\n return function (headerName: string) {\n return (headerName && headerName.length > 0) ? \"\" : {};\n };\n }\n return function (headerName: string) {\n if (headerName && headerName.length > 0) {\n return response.headers.get(headerName);\n }\n const hob: Record<string, any> = {};\n response.headers.forEach((val, key) => {\n hob[key] = val;\n });\n return hob;\n };\n}\n\n/**\n * Ajax adapter using the fetch API.\n *\n * @deprecated Breeze 3 needs no ajax adapter: requests go through `config.fetch`, set with\n * `configureBreeze({ fetch })`. This class is kept so that 2.x startup code - `register()`,\n * `configureBreeze({ ajax: AjaxFetchAdapter })`, `config.initializeAdapterInstance('ajax',\n * 'fetch')` - and code using `defaultSettings` or `requestInterceptor` keeps working. It is\n * not scheduled for removal.\n */\nexport class AjaxFetchAdapter implements AjaxAdapter {\n static adapterName = \"fetch\";\n name: string;\n defaultSettings: { headers?: { [name: string]: string } };\n requestInterceptor?: AjaxRequestInterceptor;\n /** The function used to make the request. Defaults to `globalThis.fetch`. */\n fetchFn: BreezeFetch;\n\n constructor(fetchFn?: BreezeFetch) {\n this.name = AjaxFetchAdapter.adapterName;\n this.defaultSettings = {};\n this.requestInterceptor = undefined;\n this.fetchFn = fetchFn || defaultFetch;\n }\n\n /**\n * @param breezeConfig - defaults to the global breeze config\n * @param fetchFn - the transport this adapter uses. Defaults to `globalThis.fetch`.\n */\n static register(breezeConfig?: BreezeConfig, fetchFn?: BreezeFetch) {\n breezeConfig = breezeConfig || config;\n if (fetchFn) {\n // registerAdapter news up the ctor, so a custom transport needs a factory.\n breezeConfig.registerAdapter(\"ajax\", <any>function () { return new AjaxFetchAdapter(fetchFn); });\n } else {\n breezeConfig.registerAdapter(\"ajax\", AjaxFetchAdapter);\n }\n return breezeConfig.initializeAdapterInstance(\"ajax\", AjaxFetchAdapter.adapterName, true) as AjaxFetchAdapter;\n }\n\n initialize() {\n }\n\n ajax(ajaxConfig: AjaxConfig) {\n if (!this.fetchFn) {\n throw new Error(\"fetch API not supported in this browser\");\n }\n\n let { url, init } = toFetchArgs(ajaxConfig);\n\n if (!core.isEmpty(this.defaultSettings)) {\n let compositeConfig = core.extend({}, this.defaultSettings);\n init = core.extend(compositeConfig, init) as any;\n // extend is shallow; extend headers separately\n let headers = core.extend({}, this.defaultSettings.headers); // copy default headers 1st\n init.headers = core.extend(headers, init.headers) as any;\n }\n\n // An interceptor may change requestInfo.config (the fetch init), cancel the request by\n // setting it to null, or answer it itself through success/error.\n let requestInfo = {\n adapter: this,\n config: init as RequestInit | null,\n dsaConfig: ajaxConfig,\n success: (data: any, statusText: string, response: Response) =>\n ajaxConfig.success(success(ajaxConfig, data, statusText, response).httpResponse),\n error: (status: number, statusText: string, body: string | null, response: Response | null, errorThrown: any) =>\n ajaxConfig.error(failure(ajaxConfig, status, statusText, body, response, errorThrown).httpResponse),\n };\n\n if (core.isFunction(this.requestInterceptor)) {\n let ri = this.requestInterceptor as any;\n ri(requestInfo);\n if (ri.oneTime) {\n this.requestInterceptor = undefined;\n }\n }\n\n if (requestInfo.config) {\n sendFetch(this.fetchFn, url, requestInfo.config, ajaxConfig).then(outcome =>\n outcome.succeeded ? ajaxConfig.success(outcome.httpResponse) : ajaxConfig.error(outcome.httpResponse));\n }\n }\n}\n\n/**\n * What a data service adapter uses when no ajax adapter is registered. It sends requests\n * through `config.fetch`, read at call time, so a later `configureBreeze({ fetch })` takes\n * effect without re-initializing anything.\n * @hidden @internal\n */\nexport const builtinAjax: AjaxAdapter = new AjaxFetchAdapter(\n (input, init) => (config.fetch || defaultFetch)(input, init));\n"]}
@@ -0,0 +1,21 @@
1
+ import type { HttpClient } from '@angular/common/http';
2
+ import type { BreezeFetch } from '../config/interface-registry.js';
3
+ /**
4
+ * A {@link BreezeFetch} that sends Breeze's requests through Angular's `HttpClient`, so that they
5
+ * pass through your interceptors and, in tests, `HttpTestingController`.
6
+ *
7
+ * ```ts
8
+ * // app.config.ts
9
+ * import { httpClientFetch } from 'breeze-client/adapter-angular-httpclient';
10
+ *
11
+ * provideAppInitializer(() => { configureBreeze({ fetch: httpClientFetch(inject(HttpClient)) }); }),
12
+ * ```
13
+ *
14
+ * `HttpClient` throws on a status outside 200-299 rather than returning the response. This hands
15
+ * Breeze that response anyway - its status, body and headers - because that is how Breeze turns a
16
+ * rejected save into `entityErrors` and a 409 into a concurrency conflict. A request that never
17
+ * completed (status 0) is left to fail, and Breeze reports it as a transport failure.
18
+ *
19
+ * @param http - the application's `HttpClient`
20
+ */
21
+ export declare function httpClientFetch(http: HttpClient): BreezeFetch;
@@ -0,0 +1,70 @@
1
+ import { firstValueFrom } from 'rxjs';
2
+ // Breeze's requests through Angular's HttpClient.
3
+ //
4
+ // breeze-client/adapter-angular-httpclient. Optional, and opt-in like breeze-client/rxjs: import
5
+ // it from its own subpath. Nothing in `breeze-client` imports this module, and @angular/common is
6
+ // an optional peer dependency, so an application that is not Angular never installs it.
7
+ //
8
+ // import { httpClientFetch } from 'breeze-client/adapter-angular-httpclient';
9
+ // configureBreeze({ fetch: httpClientFetch(inject(HttpClient)) });
10
+ //
11
+ // It imports Angular's TYPES only. The one runtime question it asks of Angular - is this error an
12
+ // HttpErrorResponse? - it answers by the error's name rather than with instanceof, so the published
13
+ // JavaScript never loads @angular/common, and an application with two copies of Angular (a library
14
+ // bundling its own, say) cannot fail the check.
15
+ //
16
+ // This replaces breeze-client/adapter-ajax-httpclient from Breeze 2.x.
17
+ /**
18
+ * A {@link BreezeFetch} that sends Breeze's requests through Angular's `HttpClient`, so that they
19
+ * pass through your interceptors and, in tests, `HttpTestingController`.
20
+ *
21
+ * ```ts
22
+ * // app.config.ts
23
+ * import { httpClientFetch } from 'breeze-client/adapter-angular-httpclient';
24
+ *
25
+ * provideAppInitializer(() => { configureBreeze({ fetch: httpClientFetch(inject(HttpClient)) }); }),
26
+ * ```
27
+ *
28
+ * `HttpClient` throws on a status outside 200-299 rather than returning the response. This hands
29
+ * Breeze that response anyway - its status, body and headers - because that is how Breeze turns a
30
+ * rejected save into `entityErrors` and a 409 into a concurrency conflict. A request that never
31
+ * completed (status 0) is left to fail, and Breeze reports it as a transport failure.
32
+ *
33
+ * @param http - the application's `HttpClient`
34
+ */
35
+ export function httpClientFetch(http) {
36
+ return async (input, init) => {
37
+ try {
38
+ const res = await firstValueFrom(http.request(init?.method ?? 'GET', String(input), {
39
+ body: init?.body ?? null,
40
+ headers: init?.headers,
41
+ observe: 'response',
42
+ responseType: 'text',
43
+ }));
44
+ return toResponse(res.body, res.status, res.statusText, res.headers);
45
+ }
46
+ catch (e) {
47
+ if (isHttpErrorResponse(e) && e.status !== 0) {
48
+ return toResponse(e.error, e.status, e.statusText, e.headers);
49
+ }
50
+ throw e;
51
+ }
52
+ };
53
+ }
54
+ /** By name, not instanceof: no runtime import of Angular, and no trouble with two copies of it. */
55
+ function isHttpErrorResponse(e) {
56
+ return e != null && typeof e === 'object' && e.name === 'HttpErrorResponse';
57
+ }
58
+ function toResponse(body, status, statusText, headers) {
59
+ const h = new Headers();
60
+ for (const name of headers.keys()) {
61
+ const value = headers.get(name);
62
+ if (value != null)
63
+ h.set(name, value);
64
+ }
65
+ const text = typeof body === 'string' ? body : body == null ? null : JSON.stringify(body);
66
+ // A 204 or 304 may not carry a body, and new Response() throws if given one.
67
+ const bodyless = status === 204 || status === 304 || text === '';
68
+ return new Response(bodyless ? null : text, { status, statusText, headers: h });
69
+ }
70
+ //# sourceMappingURL=adapter-angular-httpclient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-angular-httpclient.js","sourceRoot":"","sources":["../../src/angular/adapter-angular-httpclient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAItC,kDAAkD;AAClD,EAAE;AACF,iGAAiG;AACjG,kGAAkG;AAClG,wFAAwF;AACxF,EAAE;AACF,kFAAkF;AAClF,uEAAuE;AACvE,EAAE;AACF,kGAAkG;AAClG,oGAAoG;AACpG,mGAAmG;AACnG,gDAAgD;AAChD,EAAE;AACF,uEAAuE;AAEvE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAAC,IAAgB;IAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;gBAClF,IAAI,EAAE,IAAI,EAAE,IAAI,IAAI,IAAI;gBACxB,O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,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1F,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC;IACjE,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AAClF,CAAC","sourcesContent":["import { firstValueFrom } from 'rxjs';\nimport type { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';\nimport type { BreezeFetch } from '../config/interface-registry.js';\n\n// Breeze's requests through Angular's HttpClient.\n//\n// breeze-client/adapter-angular-httpclient. Optional, and opt-in like breeze-client/rxjs: import\n// it from its own subpath. Nothing in `breeze-client` imports this module, and @angular/common is\n// an optional peer dependency, so an application that is not Angular never installs it.\n//\n// import { httpClientFetch } from 'breeze-client/adapter-angular-httpclient';\n// configureBreeze({ fetch: httpClientFetch(inject(HttpClient)) });\n//\n// It imports Angular's TYPES only. The one runtime question it asks of Angular - is this error an\n// HttpErrorResponse? - it answers by the error's name rather than with instanceof, so the published\n// JavaScript never loads @angular/common, and an application with two copies of Angular (a library\n// bundling its own, say) cannot fail the check.\n//\n// This replaces breeze-client/adapter-ajax-httpclient from Breeze 2.x.\n\n/**\n * A {@link BreezeFetch} that sends Breeze's requests through Angular's `HttpClient`, so that they\n * pass through your interceptors and, in tests, `HttpTestingController`.\n *\n * ```ts\n * // app.config.ts\n * import { httpClientFetch } from 'breeze-client/adapter-angular-httpclient';\n *\n * provideAppInitializer(() => { configureBreeze({ fetch: httpClientFetch(inject(HttpClient)) }); }),\n * ```\n *\n * `HttpClient` throws on a status outside 200-299 rather than returning the response. This hands\n * Breeze that response anyway - its status, body and headers - because that is how Breeze turns a\n * rejected save into `entityErrors` and a 409 into a concurrency conflict. A request that never\n * completed (status 0) is left to fail, and Breeze reports it as a transport failure.\n *\n * @param http - the application's `HttpClient`\n */\nexport function httpClientFetch(http: HttpClient): BreezeFetch {\n return async (input, init) => {\n try {\n const res = await firstValueFrom(http.request(init?.method ?? 'GET', String(input), {\n body: init?.body ?? null,\n headers: init?.headers as Record<string, string>,\n observe: 'response',\n responseType: 'text',\n }));\n return toResponse(res.body, res.status, res.statusText, res.headers);\n } catch (e) {\n if (isHttpErrorResponse(e) && e.status !== 0) {\n return toResponse(e.error, e.status, e.statusText, e.headers);\n }\n throw e;\n }\n };\n}\n\n/** By name, not instanceof: no runtime import of Angular, and no trouble with two copies of it. */\nfunction isHttpErrorResponse(e: unknown): e is HttpErrorResponse {\n return e != null && typeof e === 'object' && (e as { name?: unknown }).name === 'HttpErrorResponse';\n}\n\nfunction toResponse(body: unknown, status: number, statusText: string, headers: HttpHeaders): Response {\n const h = new Headers();\n for (const name of headers.keys()) {\n const value = headers.get(name);\n if (value != null) h.set(name, value);\n }\n const text = typeof body === 'string' ? body : body == null ? null : JSON.stringify(body);\n // A 204 or 304 may not carry a body, and new Response() throws if given one.\n const bodyless = status === 204 || status === 304 || text === '';\n return new Response(bodyless ? null : text, { status, statusText, headers: h });\n}\n"]}
package/breeze.d.ts ADDED
@@ -0,0 +1,215 @@
1
+ import { AbstractDataServiceAdapter } from './adapters/abstract-data-service-adapter.js';
2
+ import { assertParam, assertConfig, Param } from './core/assert-param.js';
3
+ import { BreezeConfig } from './config/config.js';
4
+ import { BreezeEnum } from './core/enum.js';
5
+ import { BreezeEvent } from './core/event.js';
6
+ import type { ComplexArray } from './entity/complex-array.js';
7
+ import { DataService, JsonResultsAdapter } from './metadata/data-service.js';
8
+ import type { DataServiceConfig, JsonResultsAdapterConfig, NodeContext, NodeMeta } from './metadata/data-service.js';
9
+ import { DataType } from './metadata/data-type.js';
10
+ import { EntityAction } from './entity/entity-action.js';
11
+ import { EntityAspect, ComplexAspect } from './entity/entity-aspect.js';
12
+ import { EntityBase, ComplexObjectBase } from './entity/entity-base.js';
13
+ import type { Entity, ComplexObject, StructuralObject, PropertyChangedEventArgs, QueriedAs, EntityAspectOf, ComplexAspectOf } from './entity/entity-aspect.js';
14
+ import { EntityKey } from './entity/entity-key.js';
15
+ import { EntityManager, ProblemTypes, isConcurrencyError } from './manager/entity-manager.js';
16
+ import type { EntityManagerConfig, EntityError, EntityChangedEventArgs, SaveContext, SaveBundle, HttpResponse, KeyMapping, ServerError, SaveResult, QueryResult, ValidationErrorsChangedEventArgs, HasChangesChangedEventArgs } from './manager/entity-manager.js';
17
+ import { EntityQuery, FilterQueryOp, BooleanQueryOp, OrderByClause, ExpandClause, SelectClause } from './query/entity-query.js';
18
+ import { EntityState } from './entity/entity-state.js';
19
+ import { InterfaceRegistry } from './config/interface-registry.js';
20
+ import type { AjaxAdapter, AjaxConfig, BreezeFetch, DataServiceAdapter, ModelLibraryAdapter, ChangeRequestInterceptor, UriBuilderAdapter, InterfaceRegistryConfig, AjaxRequestInterceptor } from './config/interface-registry.js';
21
+ import { KeyGenerator } from './entity/key-generator.js';
22
+ import { LocalQueryComparisonOptions } from './metadata/local-query-comparison-options.js';
23
+ import { MappingContext } from './query/mapping-context.js';
24
+ import { MetadataStore, EntityType, ComplexType, DataProperty, NavigationProperty, AutoGeneratedKeyType, entityTypeForCtor } from './metadata/entity-metadata.js';
25
+ import type { StructuralType, EntityProperty } from './metadata/entity-metadata.js';
26
+ import { NamingConvention } from './metadata/naming-convention.js';
27
+ import { Predicate, UnaryPredicate, BinaryPredicate, AnyAllPredicate, AndOrPredicate, LitExpr, FnExpr, PropExpr } from './query/predicate.js';
28
+ import type { VisitContext, Visitor, ExpressionContext } from './query/predicate.js';
29
+ import { QueryOptions, FetchStrategy, MergeStrategy } from './query/query-options.js';
30
+ import { SaveOptions } from './manager/save-options.js';
31
+ import { ValidationError, Validator } from './validation/validate.js';
32
+ import { ValidationOptions } from './validation/validation-options.js';
33
+ import { config } from './config/config.js';
34
+ import type { BaseAdapter } from './config/config.js';
35
+ import { configureBreeze } from './config/configure.js';
36
+ import type { BreezeSetupOptions, AdapterRegistration, AjaxAdapterRegistration } from './config/configure.js';
37
+ import { core } from './core/core.js';
38
+ import type { Callback, ErrorCallback } from './core/core.js';
39
+ import { makeRelationArray, makePrimitiveArray, makeComplexArray } from './entity/array.js';
40
+ import type { RelationArray } from './entity/relation-array.js';
41
+ import type { ArrayChangedArgs } from './entity/observable-array.js';
42
+ export { BreezeConfig };
43
+ export type { ComplexArray, RelationArray };
44
+ export { AbstractDataServiceAdapter, AndOrPredicate, AnyAllPredicate, assertConfig, assertParam, AutoGeneratedKeyType, BinaryPredicate, BreezeEnum, BreezeEvent, ComplexAspect, ComplexObjectBase, ComplexType, config, configureBreeze, core, DataProperty, DataService, DataType, EntityAction, EntityAspect, EntityBase, EntityKey, EntityManager, EntityQuery, EntityState, EntityType, entityTypeForCtor, ExpandClause, FetchStrategy, FilterQueryOp, FnExpr, InterfaceRegistry, JsonResultsAdapter, KeyGenerator, LitExpr, LocalQueryComparisonOptions, makeComplexArray, makePrimitiveArray, makeRelationArray, MappingContext, MergeStrategy, MetadataStore, NamingConvention, NavigationProperty, OrderByClause, Predicate, PropExpr, QueryOptions, SaveOptions, SelectClause, UnaryPredicate, ValidationError, ValidationOptions, Validator, ProblemTypes, isConcurrencyError, };
45
+ export type { AjaxAdapter, AjaxConfig, AjaxRequestInterceptor, ArrayChangedArgs, BaseAdapter, BreezeFetch, Callback, ChangeRequestInterceptor, ComplexObject, BreezeSetupOptions, AdapterRegistration, AjaxAdapterRegistration, DataServiceAdapter, DataServiceConfig, Entity, EntityChangedEventArgs, EntityError, EntityManagerConfig, EntityProperty, ErrorCallback, ExpressionContext, HasChangesChangedEventArgs, HttpResponse, InterfaceRegistryConfig, JsonResultsAdapterConfig, KeyMapping, ModelLibraryAdapter, NodeContext, NodeMeta, PropertyChangedEventArgs, QueriedAs, EntityAspectOf, ComplexAspectOf, QueryResult, SaveBundle, SaveContext, SaveResult, ServerError, StructuralObject, StructuralType, UriBuilderAdapter, ValidationErrorsChangedEventArgs, VisitContext, Visitor, };
46
+ /** Every class, enum and helper of the Breeze 2.x API in one object - the `breeze` that 2.x code
47
+ imports or finds as a global. Kept so that code written against 2.x runs unchanged. New code
48
+ imports what it uses by name, which lets a bundler leave out the rest. */
49
+ export declare const breeze: {
50
+ /** The base class of Breeze's data service adapters, for anyone writing one. The same as the
51
+ `AbstractDataServiceAdapter` export. */
52
+ AbstractDataServiceAdapter: typeof AbstractDataServiceAdapter;
53
+ /** Always `null`. Breeze 2.x exposed its argument-checking helpers here; Breeze 3 does not. */
54
+ assertConfig: any;
55
+ /** Always `null`. Breeze 2.x exposed its argument-checking helpers here; Breeze 3 does not. */
56
+ assertParam: any;
57
+ /** The same as the {@link AutoGeneratedKeyType} export. */
58
+ AutoGeneratedKeyType: typeof AutoGeneratedKeyType;
59
+ /** The operators that combine predicates in a query - `and`, `or` and `not` - as an enum. The
60
+ same as the `BooleanQueryOp` export. */
61
+ BooleanQueryOp: typeof BooleanQueryOp;
62
+ /** The same as the {@link ComplexAspect} export. */
63
+ ComplexAspect: typeof ComplexAspect;
64
+ /** The same as the {@link ComplexType} export. */
65
+ ComplexType: typeof ComplexType;
66
+ /** The same as the {@link config} export: the older adapter-registration API. New code calls
67
+ {@link configureBreeze} instead. */
68
+ config: BreezeConfig;
69
+ /** The same as the {@link core} export. */
70
+ core: {
71
+ hasOwnProperty: (obj: Object, key: string) => boolean;
72
+ getOwnPropertyValues: (source: Object) => any[];
73
+ getPropertyDescriptor: (obj: Object, propertyName: string) => PropertyDescriptor | undefined;
74
+ objectForEach: (obj: Object, kvFn: (key: string, val: any) => any) => void;
75
+ objectFirst: (obj: Object, kvPredicate: (key: string, val: any) => boolean) => {
76
+ key: string;
77
+ value: any;
78
+ } | null;
79
+ objectMap: (obj: Object, kvFn?: (key: string, val: any) => any) => any[];
80
+ extend: (target: Object, source?: Object, propNames?: string[]) => Object;
81
+ propEq: (propertyName: string, value: any) => (obj: Object) => boolean;
82
+ propsEq: (property1Name: string, property2Name: string, value: any) => (obj: Object) => boolean;
83
+ pluck: (propertyName: any) => (obj: Object) => any;
84
+ map: <T>(items: T | T[], fn: (v: T, ix?: number) => any, includeNull?: boolean) => any | any[];
85
+ resolveProperties: (sources: Object[], propertyNames: string[]) => any;
86
+ setAsDefault: (target: Object, ctor: {
87
+ new (...args: any[]): any;
88
+ defaultInstance?: any;
89
+ }) => any;
90
+ updateWithDefaults: (target: Object, defaults: Object) => any;
91
+ getMapArray: <K, V>(map: Map<K, V[]>, key: K) => V[];
92
+ toArray: (item: any) => any[];
93
+ arrayEquals: (a1: any[], a2: any[], equalsFn?: (x1: any, x2: any) => boolean) => boolean;
94
+ arraySlice: (ar: any[], start?: number, end?: number) => any[];
95
+ arrayFirst: <T>(array: T[], predicate: (i: any) => boolean) => T;
96
+ arrayIndexOf: <T>(array: T[], predicate: (i: any) => boolean) => number;
97
+ arrayRemoveItem: <T>(array: T[], predicateOrItem: T | ((i: T) => boolean), shouldRemoveMultiple?: boolean) => boolean;
98
+ arrayZip: (a1: any[], a2: any[], callback: (x1: any, x2: any) => any) => any[];
99
+ arrayAddItemUnique: <T>(array: T[], item: T) => void;
100
+ arrayFlatMap: typeof import("./core/core.js").arrayFlatMap;
101
+ using: (obj: Object, property: string, tempValue: any, fn: () => any) => any;
102
+ wrapExecution: (startFn: () => any, endFn: (state: any) => any, fn: () => any) => any;
103
+ memoize: (fn: any) => any;
104
+ getUuid: typeof import("./core/core.js").getUuid;
105
+ durationToSeconds: (duration: string) => number;
106
+ isSettable: (obj: Object, propertyName: string) => boolean;
107
+ isDate: (o: any) => boolean;
108
+ isDateString: (s: string) => boolean;
109
+ isGuid: (value: any) => boolean;
110
+ isDuration: (value: any) => boolean;
111
+ isFunction: (o: any) => boolean;
112
+ isEmpty: (obj: any) => boolean;
113
+ identity: (x: any) => any;
114
+ noop: () => void;
115
+ stringStartsWith: typeof import("./core/core.js").stringStartsWith;
116
+ stringEndsWith: typeof import("./core/core.js").stringEndsWith;
117
+ formatString: typeof import("./core/core.js").formatString;
118
+ toJson: (source: Object, template: Object, target?: Object) => Object;
119
+ toJSONSafe: (obj: any, replacer?: (prop: string, value: any) => any) => any;
120
+ toJSONSafeReplacer: (prop: string, val: any) => any;
121
+ strings: {
122
+ TO_TYPE: string;
123
+ };
124
+ };
125
+ /** The same as the {@link DataProperty} export. */
126
+ DataProperty: typeof DataProperty;
127
+ /** The same as the {@link DataService} export. */
128
+ DataService: typeof DataService;
129
+ /** The same as the {@link DataType} export. */
130
+ DataType: typeof DataType;
131
+ /** The same as the {@link EntityAction} export. */
132
+ EntityAction: typeof EntityAction;
133
+ /** The same as the {@link EntityAspect} export. */
134
+ EntityAspect: typeof EntityAspect;
135
+ /** The same as the {@link EntityKey} export. */
136
+ EntityKey: typeof EntityKey;
137
+ /** The same as the {@link EntityManager} export. */
138
+ EntityManager: typeof EntityManager;
139
+ /** The same as the {@link EntityQuery} export. */
140
+ EntityQuery: typeof EntityQuery;
141
+ /** The same as the {@link EntityState} export. */
142
+ EntityState: typeof EntityState;
143
+ /** The same as the {@link EntityType} export. */
144
+ EntityType: typeof EntityType;
145
+ /** The same as the {@link BreezeEvent} export, under its 2.x name. */
146
+ Event: typeof BreezeEvent;
147
+ /** The same as the {@link FetchStrategy} export. */
148
+ FetchStrategy: typeof FetchStrategy;
149
+ /** The same as the {@link FilterQueryOp} export. */
150
+ FilterQueryOp: typeof FilterQueryOp;
151
+ /** The same as the {@link InterfaceRegistry} export. */
152
+ InterfaceRegistry: typeof InterfaceRegistry;
153
+ /** The same as the {@link JsonResultsAdapter} export. */
154
+ JsonResultsAdapter: typeof JsonResultsAdapter;
155
+ /** The same as the {@link KeyGenerator} export. */
156
+ KeyGenerator: typeof KeyGenerator;
157
+ /** The same as the {@link LocalQueryComparisonOptions} export. */
158
+ LocalQueryComparisonOptions: typeof LocalQueryComparisonOptions;
159
+ /** Turns an array into the array behind a collection of complex objects. For model library
160
+ adapter authors; Breeze's own adapter calls it when it sets up an entity. */
161
+ makeComplexArray: typeof makeComplexArray;
162
+ /** Turns an array into the array behind a collection of primitive values. For model library
163
+ adapter authors; Breeze's own adapter calls it when it sets up an entity. */
164
+ makePrimitiveArray: typeof makePrimitiveArray;
165
+ /** Turns an array into the {@link RelationArray} behind a collection navigation property. For
166
+ model library adapter authors; Breeze's own adapter calls it when it sets up an entity. */
167
+ makeRelationArray: typeof makeRelationArray;
168
+ /** The same as the {@link MergeStrategy} export. */
169
+ MergeStrategy: typeof MergeStrategy;
170
+ /** The same as the {@link MetadataStore} export. */
171
+ MetadataStore: typeof MetadataStore;
172
+ /** The same as the {@link NamingConvention} export. */
173
+ NamingConvention: typeof NamingConvention;
174
+ /** The same as the {@link NavigationProperty} export. */
175
+ NavigationProperty: typeof NavigationProperty;
176
+ /** The class that holds a query's `orderBy`. Exposed for Breeze's own tests; applications do not
177
+ need it. */
178
+ OrderByClause: typeof OrderByClause;
179
+ /** Breeze's internal argument-checking helper. Applications do not need it. */
180
+ Param: typeof Param;
181
+ /** The same as the {@link Predicate} export. */
182
+ Predicate: typeof Predicate;
183
+ /** The same as the {@link QueryOptions} export. */
184
+ QueryOptions: typeof QueryOptions;
185
+ /** The same as the {@link SaveOptions} export. */
186
+ SaveOptions: typeof SaveOptions;
187
+ /** The same as the {@link ValidationError} export. */
188
+ ValidationError: typeof ValidationError;
189
+ /** The same as the {@link ValidationOptions} export. */
190
+ ValidationOptions: typeof ValidationOptions;
191
+ /** The same as the {@link Validator} export. */
192
+ Validator: typeof Validator;
193
+ /** The version of `breeze-client`. A test keeps it equal to the one in package.json. */
194
+ version: string;
195
+ };
196
+ export type { AdapterCtor, AdapterType } from './config/config.js';
197
+ export type { AjaxRequest, ChangeRequestInterceptorCtor } from './config/interface-registry.js';
198
+ export type { ComplexTypeConfig, DataPropertyConfig, EntityTypeConfig, EntityTypeSetConfig, MetadataFetchedEventArgs, MetadataStoreConfig, NavigationPropertyConfig, } from './metadata/entity-metadata.js';
199
+ export type { EntityByKeyResult, EntityTypeArg, ExportEntitiesArg, IEntityByKeyResult, ImportConfig, ImportResult, InitialValues, ITempKeyMap, QueryErrorCallback, QuerySuccessCallback, SaveError, } from './manager/entity-manager.js';
200
+ export type { LocalQueryComparisonOptionsConfig } from './metadata/local-query-comparison-options.js';
201
+ export type { NamingConventionConfig } from './metadata/naming-convention.js';
202
+ export type { CollectionElement, CollectionPath, FilterOpFor, FilterValueExpression, FilterValueFor, FunctionExpressionPath, FilterClause, FilterOpsObject, FilterOpNameFor, NavigationPath, OrderByPath, KeyValues, OriginalValues, PropertyPath, PropertyValue, QuantifierOp, SelectPath, WhereObject, } from './query/property-path.js';
203
+ export type { TypedPredicateFactory } from './query/predicate.js';
204
+ export type { QueryOptionsConfig } from './query/query-options.js';
205
+ export type { SaveOptionsConfig } from './manager/save-options.js';
206
+ export type { ValidationContext, ValidationFn, ValidationMessageContext } from './validation/validate.js';
207
+ export type { ValidationOptionsConfig } from './validation/validation-options.js';
208
+ /** Kept for code written against Breeze 2.x and `breeze-bridge2-angular`. Breeze 3 uses native
209
+ promises and has nothing to configure here. */
210
+ export declare namespace promises {
211
+ /** An empty interface, kept so that code written for `breeze-bridge2-angular`, which named it,
212
+ still compiles. Breeze 3 uses native promises. */
213
+ interface IPromiseService {
214
+ }
215
+ }