ngrx-entity-crud 12.0.6-beta.2

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 (184) hide show
  1. package/README.md +259 -0
  2. package/bundles/ngrx-entity-crud.umd.js +1829 -0
  3. package/bundles/ngrx-entity-crud.umd.js.map +1 -0
  4. package/esm2015/lib/actions.js +88 -0
  5. package/esm2015/lib/base-crud-gql.service.js +71 -0
  6. package/esm2015/lib/base-crud.service.js +136 -0
  7. package/esm2015/lib/create_adapter.js +14 -0
  8. package/esm2015/lib/effect.js +467 -0
  9. package/esm2015/lib/entity_state.js +23 -0
  10. package/esm2015/lib/ibase-crud-service.js +2 -0
  11. package/esm2015/lib/j-ngrx-filter.js +133 -0
  12. package/esm2015/lib/models.js +17 -0
  13. package/esm2015/lib/reducer.js +353 -0
  14. package/esm2015/lib/state_selectors.js +56 -0
  15. package/esm2015/lib/utils.js +19 -0
  16. package/esm2015/ngrx-entity-crud.js +5 -0
  17. package/esm2015/public-api.js +7 -0
  18. package/fesm2015/ngrx-entity-crud.js +1367 -0
  19. package/fesm2015/ngrx-entity-crud.js.map +1 -0
  20. package/lib/actions.d.ts +5 -0
  21. package/lib/actions.d.ts.map +1 -0
  22. package/lib/base-crud-gql.service.d.ts +19 -0
  23. package/lib/base-crud-gql.service.d.ts.map +1 -0
  24. package/lib/base-crud.service.d.ts +34 -0
  25. package/lib/base-crud.service.d.ts.map +1 -0
  26. package/lib/create_adapter.d.ts +6 -0
  27. package/lib/create_adapter.d.ts.map +1 -0
  28. package/lib/effect.d.ts +132 -0
  29. package/lib/effect.d.ts.map +1 -0
  30. package/lib/entity_state.d.ts +9 -0
  31. package/lib/entity_state.d.ts.map +1 -0
  32. package/lib/ibase-crud-service.d.ts +13 -0
  33. package/lib/ibase-crud-service.d.ts.map +1 -0
  34. package/lib/j-ngrx-filter.d.ts +14 -0
  35. package/lib/j-ngrx-filter.d.ts.map +1 -0
  36. package/lib/models.d.ts +494 -0
  37. package/lib/models.d.ts.map +1 -0
  38. package/lib/reducer.d.ts +11 -0
  39. package/lib/reducer.d.ts.map +1 -0
  40. package/lib/state_selectors.d.ts +5 -0
  41. package/lib/state_selectors.d.ts.map +1 -0
  42. package/lib/utils.d.ts +8 -0
  43. package/lib/utils.d.ts.map +1 -0
  44. package/ngrx-entity-crud.d.ts +5 -0
  45. package/ngrx-entity-crud.d.ts.map +1 -0
  46. package/ngrx-entity-crud.metadata.json +1 -0
  47. package/package.json +41 -0
  48. package/public-api.d.ts +7 -0
  49. package/public-api.d.ts.map +1 -0
  50. package/schematics/auth/files/model/auth.ts +17 -0
  51. package/schematics/auth/files/store/auth-store/actions.ts +30 -0
  52. package/schematics/auth/files/store/auth-store/auth-mock.service.ts +95 -0
  53. package/schematics/auth/files/store/auth-store/auth-store.module.ts +34 -0
  54. package/schematics/auth/files/store/auth-store/auth.guard.ts +44 -0
  55. package/schematics/auth/files/store/auth-store/auth.service.ts +28 -0
  56. package/schematics/auth/files/store/auth-store/conf.ts +2 -0
  57. package/schematics/auth/files/store/auth-store/effects.ts +53 -0
  58. package/schematics/auth/files/store/auth-store/index.d.ts +13 -0
  59. package/schematics/auth/files/store/auth-store/index.ts +13 -0
  60. package/schematics/auth/files/store/auth-store/names.ts +3 -0
  61. package/schematics/auth/files/store/auth-store/reducer.ts +16 -0
  62. package/schematics/auth/files/store/auth-store/selectors.ts +51 -0
  63. package/schematics/auth/files/store/auth-store/state.ts +16 -0
  64. package/schematics/auth/files/views/login/components/logout-button/logout-button.component.ts +49 -0
  65. package/schematics/auth/files/views/login/login-main/login-main.component.html +25 -0
  66. package/schematics/auth/files/views/login/login-main/login-main.component.ts +57 -0
  67. package/schematics/auth/files/views/login/login-routing.module.ts +30 -0
  68. package/schematics/auth/files/views/login/login.module.ts +30 -0
  69. package/schematics/auth/index.d.ts +2 -0
  70. package/schematics/auth/index.js +77 -0
  71. package/schematics/auth/index.js.map +1 -0
  72. package/schematics/auth/schema.json +21 -0
  73. package/schematics/auth0/files/store/auth-store/actions.ts +21 -0
  74. package/schematics/auth0/files/store/auth-store/auth-store.module.ts +32 -0
  75. package/schematics/auth0/files/store/auth-store/auth.guard.ts +44 -0
  76. package/schematics/auth0/files/store/auth-store/authentication.service.ts +32 -0
  77. package/schematics/auth0/files/store/auth-store/conf.ts +2 -0
  78. package/schematics/auth0/files/store/auth-store/effects.ts +59 -0
  79. package/schematics/auth0/files/store/auth-store/index.d.ts +13 -0
  80. package/schematics/auth0/files/store/auth-store/index.ts +13 -0
  81. package/schematics/auth0/files/store/auth-store/login.component.ts +75 -0
  82. package/schematics/auth0/files/store/auth-store/names.ts +3 -0
  83. package/schematics/auth0/files/store/auth-store/profile.ts +12 -0
  84. package/schematics/auth0/files/store/auth-store/reducer.ts +23 -0
  85. package/schematics/auth0/files/store/auth-store/selectors.ts +24 -0
  86. package/schematics/auth0/files/store/auth-store/state.ts +11 -0
  87. package/schematics/auth0/index.d.ts +2 -0
  88. package/schematics/auth0/index.js +67 -0
  89. package/schematics/auth0/index.js.map +1 -0
  90. package/schematics/auth0/schema.json +21 -0
  91. package/schematics/collection.json +30 -0
  92. package/schematics/my-utility.d.ts +58 -0
  93. package/schematics/my-utility.js +257 -0
  94. package/schematics/my-utility.js.map +1 -0
  95. package/schematics/ng-add/files/root-store/index.d.ts +8 -0
  96. package/schematics/ng-add/files/root-store/index.ts +8 -0
  97. package/schematics/ng-add/files/root-store/root-reducer.ts +11 -0
  98. package/schematics/ng-add/files/root-store/root-store.module.ts +29 -0
  99. package/schematics/ng-add/files/root-store/router-store/actions.ts +27 -0
  100. package/schematics/ng-add/files/root-store/router-store/effects.ts +65 -0
  101. package/schematics/ng-add/files/root-store/router-store/index.d.ts +11 -0
  102. package/schematics/ng-add/files/root-store/router-store/index.ts +11 -0
  103. package/schematics/ng-add/files/root-store/router-store/pop-up-base.component.ts +83 -0
  104. package/schematics/ng-add/files/root-store/router-store/pop-up-base.module.ts +24 -0
  105. package/schematics/ng-add/files/root-store/router-store/reducer.ts +31 -0
  106. package/schematics/ng-add/files/root-store/router-store/router-store.module.ts +30 -0
  107. package/schematics/ng-add/files/root-store/router-store/selectors.ts +63 -0
  108. package/schematics/ng-add/files/root-store/router-store/state.ts +18 -0
  109. package/schematics/ng-add/files/root-store/selectors.ts +20 -0
  110. package/schematics/ng-add/files/root-store/slide-menu-store/actions.ts +11 -0
  111. package/schematics/ng-add/files/root-store/slide-menu-store/effects.ts +10 -0
  112. package/schematics/ng-add/files/root-store/slide-menu-store/index.d.ts +13 -0
  113. package/schematics/ng-add/files/root-store/slide-menu-store/index.ts +13 -0
  114. package/schematics/ng-add/files/root-store/slide-menu-store/names.ts +3 -0
  115. package/schematics/ng-add/files/root-store/slide-menu-store/operators.ts +24 -0
  116. package/schematics/ng-add/files/root-store/slide-menu-store/reducer.ts +8 -0
  117. package/schematics/ng-add/files/root-store/slide-menu-store/selectors.ts +41 -0
  118. package/schematics/ng-add/files/root-store/slide-menu-store/slide-menu-store.module.ts +27 -0
  119. package/schematics/ng-add/files/root-store/slide-menu-store/state.ts +14 -0
  120. package/schematics/ng-add/files/root-store/state.ts +5 -0
  121. package/schematics/ng-add/index.d.ts +2 -0
  122. package/schematics/ng-add/index.js +78 -0
  123. package/schematics/ng-add/index.js.map +1 -0
  124. package/schematics/ng-add/schema.json +22 -0
  125. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +52 -0
  126. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +57 -0
  127. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +7 -0
  128. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +50 -0
  129. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +15 -0
  130. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +23 -0
  131. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +36 -0
  132. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__.module.ts +33 -0
  133. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +1 -0
  134. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +16 -0
  135. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +1 -0
  136. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +27 -0
  137. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +1 -0
  138. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +18 -0
  139. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +36 -0
  140. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__.module.ts +26 -0
  141. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +38 -0
  142. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +50 -0
  143. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +30 -0
  144. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +101 -0
  145. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +12 -0
  146. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +21 -0
  147. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +37 -0
  148. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__.module.ts +49 -0
  149. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-create-many-test-__clazz@dasherize__.component.ts +46 -0
  150. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-delete-__clazz@dasherize__.component.ts +35 -0
  151. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-edit-many-test-__clazz@dasherize__.component.ts +45 -0
  152. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-new-__clazz@dasherize__.component.ts +45 -0
  153. package/schematics/section/index.d.ts +2 -0
  154. package/schematics/section/index.js +56 -0
  155. package/schematics/section/index.js.map +1 -0
  156. package/schematics/section/schema.json +39 -0
  157. package/schematics/store/files/base-model/__clazz@dasherize__.ts +8 -0
  158. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__-store.module.ts +26 -0
  159. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.actions.ts +9 -0
  160. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.effects.ts +11 -0
  161. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.names.ts +3 -0
  162. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.reducer.ts +8 -0
  163. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.selectors.ts +18 -0
  164. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.state.ts +6 -0
  165. package/schematics/store/files/base-store/__clazz@dasherize__-store/index.d.ts +13 -0
  166. package/schematics/store/files/base-store/__clazz@dasherize__-store/index.ts +13 -0
  167. package/schematics/store/files/crud-graphql/__clazz@dasherize__-store/__clazz@dasherize__.criteria.ts +39 -0
  168. package/schematics/store/files/crud-graphql/__clazz@dasherize__-store/__clazz@dasherize__.graphql +34 -0
  169. package/schematics/store/files/crud-model/__clazz@dasherize__.ts +8 -0
  170. package/schematics/store/files/crud-service/__clazz@dasherize__.service.ts +11 -0
  171. package/schematics/store/files/crud-service-graphql/__clazz@dasherize__.service.ts +16 -0
  172. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__-store.module.ts +26 -0
  173. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.actions.ts +55 -0
  174. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.effects.ts +90 -0
  175. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.names.ts +3 -0
  176. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.reducer.ts +103 -0
  177. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.selectors.ts +26 -0
  178. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.state.ts +11 -0
  179. package/schematics/store/files/crud-store/__clazz@dasherize__-store/index.d.ts +15 -0
  180. package/schematics/store/files/crud-store/__clazz@dasherize__-store/index.ts +15 -0
  181. package/schematics/store/index.d.ts +2 -0
  182. package/schematics/store/index.js +100 -0
  183. package/schematics/store/index.js.map +1 -0
  184. package/schematics/store/schema.json +45 -0
@@ -0,0 +1,1367 @@
1
+ import { createEntityAdapter } from '@ngrx/entity';
2
+ import { createSelector, createAction, props, on, createReducer } from '@ngrx/store';
3
+ import { filter, switchMap, map, catchError, repeat, concatMap, mergeMap } from 'rxjs/operators';
4
+ import * as i0 from '@angular/core';
5
+ import { isDevMode, Injectable } from '@angular/core';
6
+ import { ofType } from '@ngrx/effects';
7
+ import { from, of } from 'rxjs';
8
+ import * as i1 from '@angular/common/http';
9
+ import { HttpHeaders, HttpClient } from '@angular/common/http';
10
+
11
+ var CrudEnum;
12
+ (function (CrudEnum) {
13
+ CrudEnum["SEARCH"] = "Search";
14
+ CrudEnum["DELETE"] = "Delete";
15
+ CrudEnum["CREATE"] = "Create";
16
+ CrudEnum["EDIT"] = "Edit";
17
+ CrudEnum["SELECT"] = "Select";
18
+ CrudEnum["RESET"] = "Reset";
19
+ })(CrudEnum || (CrudEnum = {}));
20
+ var ActionEnum;
21
+ (function (ActionEnum) {
22
+ ActionEnum["RESPONSE"] = "Response";
23
+ ActionEnum["REQUEST"] = "Request";
24
+ ActionEnum["FAILURE"] = "Failure";
25
+ ActionEnum["SUCCESS"] = "Success";
26
+ })(ActionEnum || (ActionEnum = {}));
27
+
28
+ function getInitialEntityCrudState() {
29
+ return {
30
+ ids: [],
31
+ entities: {},
32
+ isLoading: false,
33
+ isLoaded: false,
34
+ error: null,
35
+ filters: {},
36
+ lastCriteria: null,
37
+ entitiesSelected: {},
38
+ idsSelected: [],
39
+ itemSelected: null,
40
+ idSelected: null,
41
+ responses: []
42
+ };
43
+ }
44
+ function createInitialCrudStateFactory() {
45
+ function getInitialCrudState(additionalState = {}) {
46
+ return Object.assign(getInitialEntityCrudState(), additionalState);
47
+ }
48
+ return { getInitialCrudState };
49
+ }
50
+
51
+ const isEmpty = (obj) => {
52
+ return obj === null || undefined
53
+ ? true
54
+ : (() => {
55
+ for (const prop in obj) {
56
+ if (Object.prototype.hasOwnProperty.call(obj, prop)) {
57
+ return false;
58
+ }
59
+ }
60
+ return true;
61
+ })();
62
+ };
63
+ function jNgrxFilter(items, filters) {
64
+ return new JNgrxFilter().jNgrxFilter(items, filters);
65
+ }
66
+ class JNgrxFilter {
67
+ constructor() {
68
+ this.filterConstraints = {
69
+ startsWith(value, filter) {
70
+ if (filter === undefined || filter === null || filter.trim() === '') {
71
+ return true;
72
+ }
73
+ if (value === undefined || value === null) {
74
+ return false;
75
+ }
76
+ const filterValue = filter.toLowerCase();
77
+ return value.toString().toLowerCase().slice(0, filterValue.length) === filterValue;
78
+ },
79
+ contains(value, filter) {
80
+ if (filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
81
+ return true;
82
+ }
83
+ if (value === undefined || value === null) {
84
+ return false;
85
+ }
86
+ return value.toString().toLowerCase().indexOf(filter.toLowerCase()) !== -1;
87
+ },
88
+ endsWith(value, filter) {
89
+ if (filter === undefined || filter === null || filter.trim() === '') {
90
+ return true;
91
+ }
92
+ if (value === undefined || value === null) {
93
+ return false;
94
+ }
95
+ const filterValue = filter.toString().toLowerCase();
96
+ return value.toString().toLowerCase().indexOf(filterValue, value.toString().length - filterValue.length) !== -1;
97
+ },
98
+ equals(value, filter) {
99
+ if (filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
100
+ return true;
101
+ }
102
+ if (value === undefined || value === null) {
103
+ return false;
104
+ }
105
+ return value.toString().toLowerCase() === filter.toString().toLowerCase();
106
+ },
107
+ notEquals(value, filter) {
108
+ if (filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
109
+ return false;
110
+ }
111
+ if (value === undefined || value === null) {
112
+ return true;
113
+ }
114
+ return value.toString().toLowerCase() !== filter.toString().toLowerCase();
115
+ },
116
+ in(value, filters) {
117
+ if (filters === undefined || filters === null || filters.length === 0) {
118
+ return true;
119
+ }
120
+ if (value === undefined || value === null) {
121
+ return false;
122
+ }
123
+ filters.forEach(filter => {
124
+ if (filter === value) {
125
+ return true;
126
+ }
127
+ });
128
+ return false;
129
+ }
130
+ };
131
+ this.isFunction = (obj) => !!(obj && obj.constructor && obj.call && obj.apply);
132
+ }
133
+ jNgrxFilter(items, filters) {
134
+ if (isEmpty(filters)) {
135
+ return items;
136
+ }
137
+ const filteredValue = [];
138
+ items.forEach((item) => {
139
+ let localMatch = false;
140
+ // tslint:disable-next-line:forin
141
+ for (const filterField in filters) {
142
+ const filterValue = filters[filterField].value;
143
+ const filterMatchMode = filters[filterField].matchMode || 'startsWith';
144
+ const filterConstraint = this.filterConstraints[filterMatchMode];
145
+ const renderFunction = filters[filterField].renderFunction;
146
+ const dataFieldValue = this.isFunction(renderFunction) ? renderFunction(this.resolveFieldData(item, filterField)) : this.resolveFieldData(item, filterField);
147
+ if (filterConstraint(dataFieldValue, filterValue)) {
148
+ localMatch = true;
149
+ break;
150
+ }
151
+ }
152
+ if (localMatch) {
153
+ filteredValue.push(item);
154
+ }
155
+ });
156
+ return filteredValue;
157
+ }
158
+ resolveFieldData(data, field) {
159
+ if (data && field) {
160
+ if (this.isFunction(field)) {
161
+ return field(data);
162
+ }
163
+ else if (field.indexOf('.') === -1) {
164
+ return data[field];
165
+ }
166
+ else {
167
+ const fields = field.split('.');
168
+ let value = data;
169
+ for (let i = 0, len = fields.length; i < len; ++i) {
170
+ if (value == null) {
171
+ return null;
172
+ }
173
+ value = value[fields[i]];
174
+ }
175
+ return value;
176
+ }
177
+ }
178
+ else {
179
+ return null;
180
+ }
181
+ }
182
+ }
183
+
184
+ function createCrudSelectorsFactory(adapter) {
185
+ function getCrudSelectors(selectState) {
186
+ const getError = (state) => state.error;
187
+ const getIsLoading = (state) => state.isLoading;
188
+ const getIsLoaded = (state) => state.isLoaded;
189
+ const getFilters = (state) => state.filters;
190
+ const getLastCriteria = (state) => state.lastCriteria;
191
+ const getItemSelected = (state) => state.itemSelected;
192
+ const getIdSelected = (state) => state.idSelected;
193
+ // const getItemsSelected = (state: CrudState<T>): T[] => state.itemsSelected;
194
+ const getEntitiesSelected = (state) => state.entitiesSelected;
195
+ const getIdsSelected = (state) => state.idsSelected;
196
+ const getRespones = (state) => state.responses;
197
+ const selectError = createSelector(selectState, getError);
198
+ const selectIsLoading = createSelector(selectState, getIsLoading);
199
+ const selectIsLoaded = createSelector(selectState, getIsLoaded);
200
+ const selectFilters = createSelector(selectState, getFilters);
201
+ const selectLastCriteria = createSelector(selectState, getLastCriteria);
202
+ const selectItemSelected = createSelector(selectState, getItemSelected);
203
+ const selectEntitiesSelected = createSelector(selectState, getEntitiesSelected);
204
+ const selectItemsSelected = createSelector(selectEntitiesSelected, (entities) => Object.values(entities));
205
+ const selectIdSelected = createSelector(selectState, getIdSelected);
206
+ const selectIdsSelected = createSelector(selectState, getIdsSelected);
207
+ const selectResponses = createSelector(selectState, getRespones);
208
+ const { selectAll, selectEntities, selectIds, selectTotal } = adapter.getSelectors(selectState);
209
+ const selectItemsSelectedOrigin = createSelector(selectIdsSelected, selectEntities, (ids, entities) => ids.map((id) => entities[id]));
210
+ const selectItemSelectedOrigin = createSelector(selectIdSelected, selectEntities, (id, entities) => entities[id]);
211
+ const selectFilteredItems = createSelector([selectAll, selectFilters], (allTasks, filters) => {
212
+ return jNgrxFilter(allTasks, filters);
213
+ });
214
+ return {
215
+ selectError,
216
+ selectIsLoading,
217
+ selectIsLoaded,
218
+ selectFilters,
219
+ selectFilteredItems,
220
+ selectAll,
221
+ selectEntities,
222
+ selectIds,
223
+ selectTotal,
224
+ selectLastCriteria,
225
+ selectIdSelected,
226
+ selectItemSelected,
227
+ selectItemSelectedOrigin,
228
+ selectIdsSelected,
229
+ selectItemsSelected,
230
+ selectEntitiesSelected,
231
+ selectItemsSelectedOrigin,
232
+ selectResponses,
233
+ };
234
+ }
235
+ return { getCrudSelectors };
236
+ }
237
+
238
+ function createCrudActionsFactory() {
239
+ function createCrudActions(name) {
240
+ // tslint:disable:variable-name
241
+ /**
242
+ * mode:
243
+ * comportamento predefinito, il dato attualmente presente viene cancellato e ripopolato al result della chiamata
244
+ * REFRESH => il dato viene sostituito al result della chiamata.
245
+ */
246
+ const Response = createAction(`[${name}] ${ActionEnum.RESPONSE}`, props());
247
+ const ResetResponses = createAction(`[${name}] ${CrudEnum.RESET} ${ActionEnum.RESPONSE}`);
248
+ const SearchRequest = createAction(`[${name}] ${CrudEnum.SEARCH} ${ActionEnum.REQUEST}`, props());
249
+ const SearchFailure = createAction(`[${name}] ${CrudEnum.SEARCH} ${ActionEnum.FAILURE}`, props());
250
+ const SearchSuccess = createAction(`[${name}] ${CrudEnum.SEARCH} ${ActionEnum.SUCCESS}`, props());
251
+ const DeleteRequest = createAction(`[${name}] ${CrudEnum.DELETE} ${ActionEnum.REQUEST}`, props());
252
+ const DeleteFailure = createAction(`[${name}] ${CrudEnum.DELETE} ${ActionEnum.FAILURE}`, props());
253
+ const DeleteSuccess = createAction(`[${name}] ${CrudEnum.DELETE} ${ActionEnum.SUCCESS}`, props());
254
+ const DeleteManyRequest = createAction(`[${name}] ${CrudEnum.DELETE} many ${ActionEnum.REQUEST}`, props());
255
+ const DeleteManyFailure = createAction(`[${name}] ${CrudEnum.DELETE} many ${ActionEnum.FAILURE}`, props());
256
+ const DeleteManySuccess = createAction(`[${name}] ${CrudEnum.DELETE} many ${ActionEnum.SUCCESS}`, props());
257
+ const CreateRequest = createAction(`[${name}] ${CrudEnum.CREATE} ${ActionEnum.REQUEST}`, props());
258
+ const CreateFailure = createAction(`[${name}] ${CrudEnum.CREATE} ${ActionEnum.FAILURE}`, props());
259
+ const CreateSuccess = createAction(`[${name}] ${CrudEnum.CREATE} ${ActionEnum.SUCCESS}`, props());
260
+ const CreateManyRequest = createAction(`[${name}] ${CrudEnum.CREATE} many ${ActionEnum.REQUEST}`, props());
261
+ const CreateManyFailure = createAction(`[${name}] ${CrudEnum.CREATE} many ${ActionEnum.FAILURE}`, props());
262
+ const CreateManySuccess = createAction(`[${name}] ${CrudEnum.CREATE} many ${ActionEnum.SUCCESS}`, props());
263
+ const SelectRequest = createAction(`[${name}] ${CrudEnum.SELECT} ${ActionEnum.REQUEST}`, props());
264
+ const SelectFailure = createAction(`[${name}] ${CrudEnum.SELECT} ${ActionEnum.FAILURE}`, props());
265
+ const SelectSuccess = createAction(`[${name}] ${CrudEnum.SELECT} ${ActionEnum.SUCCESS}`, props());
266
+ const EditRequest = createAction(`[${name}] ${CrudEnum.EDIT} ${ActionEnum.REQUEST}`, props());
267
+ const EditFailure = createAction(`[${name}] ${CrudEnum.EDIT} ${ActionEnum.FAILURE}`, props());
268
+ const EditSuccess = createAction(`[${name}] ${CrudEnum.EDIT} ${ActionEnum.SUCCESS}`, props());
269
+ const EditManyRequest = createAction(`[${name}] ${CrudEnum.EDIT} many ${ActionEnum.REQUEST}`, props());
270
+ const EditManyFailure = createAction(`[${name}] ${CrudEnum.EDIT} many ${ActionEnum.FAILURE}`, props());
271
+ const EditManySuccess = createAction(`[${name}] ${CrudEnum.EDIT} many ${ActionEnum.SUCCESS}`, props());
272
+ const Reset = createAction(`[${name}] ${CrudEnum.RESET}`);
273
+ const Filters = createAction(`[${name}] Filters`, props());
274
+ const SelectItems = createAction(`[${name}] SelectItems`, props());
275
+ const AddManySelected = createAction(`[${name}] AddManySelected`, props());
276
+ const RemoveManySelected = createAction(`[${name}] RemoveManySelected`, props());
277
+ const RemoveAllSelected = createAction(`[${name}] RemoveAllSelected`);
278
+ const SelectItem = createAction(`[${name}] SelectItem`, props());
279
+ const Edit = createAction(`[${name}] ${CrudEnum.EDIT} `, props());
280
+ const Create = createAction(`[${name}] ${CrudEnum.CREATE}`, props());
281
+ const Delete = createAction(`[${name}] ${CrudEnum.DELETE} `, props());
282
+ return {
283
+ Response,
284
+ ResetResponses,
285
+ SearchRequest,
286
+ SearchFailure,
287
+ SearchSuccess,
288
+ DeleteRequest,
289
+ DeleteFailure,
290
+ DeleteSuccess,
291
+ DeleteManyRequest,
292
+ DeleteManyFailure,
293
+ DeleteManySuccess,
294
+ CreateRequest,
295
+ CreateFailure,
296
+ CreateSuccess,
297
+ CreateManyRequest,
298
+ CreateManyFailure,
299
+ CreateManySuccess,
300
+ SelectRequest,
301
+ SelectFailure,
302
+ SelectSuccess,
303
+ EditRequest,
304
+ EditFailure,
305
+ EditSuccess,
306
+ EditManyRequest,
307
+ EditManyFailure,
308
+ EditManySuccess,
309
+ Reset,
310
+ Filters,
311
+ SelectItems,
312
+ RemoveManySelected,
313
+ AddManySelected,
314
+ RemoveAllSelected,
315
+ SelectItem,
316
+ Edit,
317
+ Create,
318
+ Delete,
319
+ };
320
+ }
321
+ return { createCrudActions };
322
+ }
323
+
324
+ const ofFailure = () => {
325
+ return input$ => input$.pipe(filter(value => value.type.endsWith(ActionEnum.FAILURE)));
326
+ };
327
+ function selectIdValue(entity, selectId) {
328
+ const key = selectId(entity);
329
+ if (isDevMode() && key === undefined) {
330
+ console.warn('@ngrx/entity: The entity passed to the `selectId` implementation returned undefined.', 'You should probably provide your own `selectId` implementation.', 'The entity that was passed:', entity, 'The `selectId` implementation:', selectId.toString());
331
+ }
332
+ return key;
333
+ }
334
+ const toDictionary = (items, adapter) => items.reduce((prev, curr) => {
335
+ const key = selectIdValue(curr, adapter.selectId);
336
+ prev[key] = curr;
337
+ return prev;
338
+ }, {});
339
+
340
+ function evalData(fn, def = null) {
341
+ try {
342
+ return fn();
343
+ }
344
+ catch (e) {
345
+ return def;
346
+ }
347
+ }
348
+ function createCrudOns(adapter, initialState, actions) {
349
+ const searchRequestOn = on(actions.SearchRequest, (state, criteria) => {
350
+ if (!criteria.path && !criteria.mode && !criteria.queryParams) {
351
+ throw new Error('It is not possible a search without payload, use :\'{criteria:{}}\'');
352
+ }
353
+ const { itemSelected, idSelected, entitiesSelected, idsSelected } = initialState;
354
+ if (criteria.mode === 'REFRESH' || criteria.mode === 'upsertMany') {
355
+ return Object.assign({}, state, {
356
+ isLoading: true,
357
+ error: initialState.error,
358
+ lastCriteria: criteria,
359
+ itemSelected,
360
+ idSelected,
361
+ entitiesSelected,
362
+ idsSelected
363
+ });
364
+ }
365
+ return adapter.removeAll(Object.assign({}, state, {
366
+ isLoading: true,
367
+ error: initialState.error,
368
+ lastCriteria: criteria,
369
+ itemSelected,
370
+ idSelected,
371
+ entitiesSelected,
372
+ idsSelected
373
+ }));
374
+ });
375
+ const deleteRequestOn = on(actions.DeleteRequest, (state, request) => {
376
+ return Object.assign({}, state, { isLoading: true, error: initialState.error });
377
+ });
378
+ const deleteManyRequestOn = on(actions.DeleteManyRequest, (state, request) => {
379
+ return Object.assign({}, state, { isLoading: true, error: initialState.error });
380
+ });
381
+ const editRequestOn = on(actions.EditRequest, (state, request) => {
382
+ return Object.assign({}, state, { isLoading: true, error: initialState.error });
383
+ });
384
+ const editManyRequestOn = on(actions.EditManyRequest, (state, request) => {
385
+ return Object.assign({}, state, { isLoading: true, error: initialState.error });
386
+ });
387
+ const createRequestOn = on(actions.CreateRequest, (state, request) => {
388
+ return Object.assign({}, state, { isLoading: true, error: initialState.error });
389
+ });
390
+ const createManyRequestOn = on(actions.CreateManyRequest, (state, request) => {
391
+ return Object.assign({}, state, { isLoading: true, error: initialState.error });
392
+ });
393
+ const selectRequestOn = on(actions.SelectRequest, (state, request) => {
394
+ return Object.assign({}, state, { isLoading: true, error: initialState.error });
395
+ });
396
+ const searchSuccessOn = on(actions.SearchSuccess, (state, { type, items, request }) => {
397
+ const mode = evalData(() => request.mode, null) || 'setAll';
398
+ let method;
399
+ switch (mode) {
400
+ case 'REFRESH': {
401
+ // console.log('REFRESH');
402
+ method = adapter.setAll;
403
+ break;
404
+ }
405
+ case 'upsertMany': {
406
+ // console.log('upsertMany');
407
+ method = adapter.upsertMany;
408
+ break;
409
+ }
410
+ case 'setAll': {
411
+ // console.log('setAll');
412
+ method = adapter.setAll;
413
+ break;
414
+ }
415
+ default: {
416
+ // console.log('default');
417
+ method = adapter.setAll;
418
+ break;
419
+ }
420
+ }
421
+ return method(items, Object.assign({}, state, {
422
+ isLoaded: true,
423
+ isLoading: false,
424
+ error: null
425
+ }));
426
+ });
427
+ const deleteSuccessOn = on(actions.DeleteSuccess, (state, { type, id }) => {
428
+ // tolgo dallo store.idsSelected l'elemento cancellato
429
+ const idsSelected = state.idsSelected.filter((idA) => idA === id);
430
+ const entitiesSelected = idsSelected.reduce((prev, curr) => {
431
+ prev[curr] = state.entitiesSelected[curr];
432
+ return prev;
433
+ }, {});
434
+ // se ho cancellato l'id seezionato, lo tolgo dallo store.
435
+ const idSelected = !!state.idSelected && state.idSelected === id ? null : state.idSelected;
436
+ const itemSelected = !idSelected ? null : state.itemSelected;
437
+ return adapter.removeOne(id, Object.assign({}, state, {
438
+ isLoaded: true,
439
+ isLoading: false,
440
+ error: null,
441
+ idSelected,
442
+ idsSelected,
443
+ itemSelected,
444
+ entitiesSelected
445
+ }));
446
+ });
447
+ const deleteManySuccessOn = on(actions.DeleteManySuccess, (state, { type, ids }) => {
448
+ // tolgo dallo store.idsSelected gli elementi che sono stati cancellati.
449
+ const idsSelected = state.idsSelected.filter((id) => !(id in ids));
450
+ const entitiesSelected = idsSelected.reduce((prev, curr) => {
451
+ prev[curr] = state.entitiesSelected[curr];
452
+ return prev;
453
+ }, {});
454
+ // se ho cancellato l'id seezionato, lo tolgo dallo store.
455
+ const idSelected = !!state.idSelected && state.idSelected in ids ? null : state.idSelected;
456
+ const itemSelected = !idSelected ? null : state.itemSelected;
457
+ return adapter.removeMany(ids, Object.assign({}, state, {
458
+ isLoaded: true,
459
+ isLoading: false,
460
+ error: null,
461
+ idSelected,
462
+ idsSelected,
463
+ itemSelected,
464
+ entitiesSelected
465
+ }));
466
+ });
467
+ const deleteOn = on(actions.Delete, (state, { type, id }) => {
468
+ // tolgo dallo store.idsSelected l'elemento cancellato
469
+ const idsSelected = state.idsSelected.filter((idA) => idA === id);
470
+ // se ho cancellato l'id seezionato, lo tolgo dallo store.
471
+ const idSelected = !!state.idSelected && state.idSelected === id ? null : state.idSelected;
472
+ return adapter.removeOne(id, Object.assign({}, state, {
473
+ isLoaded: true,
474
+ isLoading: false,
475
+ error: null,
476
+ idSelected,
477
+ idsSelected
478
+ }));
479
+ });
480
+ const responseOn = on(actions.Response, (state, response) => {
481
+ const responses = [...state.responses, response];
482
+ return Object.assign(Object.assign({}, state), { responses });
483
+ });
484
+ const resetResponsesOn = on(actions.ResetResponses, (state) => {
485
+ const responses = [];
486
+ return Object.assign(Object.assign({}, state), { responses });
487
+ });
488
+ const createSuccessOn = on(actions.CreateSuccess, (state, { type, item }) => adapter.addOne(item, Object.assign({}, state, {
489
+ isLoaded: true,
490
+ isLoading: false,
491
+ error: null
492
+ })));
493
+ const createManySuccessOn = on(actions.CreateManySuccess, (state, { type, items }) => adapter.addMany(items, Object.assign({}, state, {
494
+ isLoaded: true,
495
+ isLoading: false,
496
+ error: null
497
+ })));
498
+ const createOn = on(actions.Create, (state, { type, item }) => adapter.addOne(item, Object.assign({}, state, {
499
+ isLoaded: true,
500
+ isLoading: false,
501
+ error: null
502
+ })));
503
+ const editSuccessOn = on(actions.EditSuccess, (state, { item, type }) => adapter.upsertOne(item, Object.assign({}, state, {
504
+ isLoaded: true,
505
+ isLoading: false,
506
+ error: null
507
+ })));
508
+ const editManySuccessOn = on(actions.EditManySuccess, (state, { items, type }) => adapter.upsertMany(items, Object.assign({}, state, {
509
+ isLoaded: true,
510
+ isLoading: false,
511
+ error: null
512
+ })));
513
+ const editOn = on(actions.Edit, (state, { item, type }) => adapter.upsertOne(item, Object.assign({}, state, {
514
+ isLoaded: true,
515
+ isLoading: false,
516
+ error: null
517
+ })));
518
+ const filtersOn = on(actions.Filters, (state, { type, filters }) => Object.assign({}, state, { filters }));
519
+ const removeAllSelectedOn = on(actions.RemoveAllSelected, (state, { type }) => {
520
+ const result = Object.assign(Object.assign({}, state), { idsSelected: [],
521
+ // itemsSelected: [], //todo: @deprecated da cancellare questo tipo di assegnazione.
522
+ entitiesSelected: {} });
523
+ return result;
524
+ });
525
+ const addManySelectedOn = on(actions.AddManySelected, (state, { type, items }) => {
526
+ const entitiesCurr = toDictionary(items, adapter);
527
+ const entitiesSelected = Object.assign(Object.assign({}, state.entitiesSelected), entitiesCurr);
528
+ const idsSelected = Object.keys(entitiesSelected);
529
+ const result = Object.assign(Object.assign({}, state), { idsSelected,
530
+ // itemsSelected: items, //todo: @deprecated da cancellare questo tipo di assegnazione.
531
+ entitiesSelected });
532
+ return result;
533
+ });
534
+ const removeManySelectedOn = on(actions.RemoveManySelected, (state, { type, ids }) => {
535
+ const idsAsString = ids.map(x => x + '');
536
+ const idsSelected = Object.keys(state.entitiesSelected).filter(id => !idsAsString.includes(id + ''));
537
+ const entitiesSelected = idsSelected.reduce((prec, curr) => (Object.assign(Object.assign({}, prec), { [curr]: state.entitiesSelected[curr] })), {});
538
+ // const itemsSelected = Object.values(entitiesSelected);
539
+ const result = Object.assign(Object.assign({}, state), { idsSelected,
540
+ // itemsSelected, //todo: @deprecated da cancellare questo tipo di assegnazione.
541
+ entitiesSelected });
542
+ return result;
543
+ });
544
+ const selectItemsOn = on(actions.SelectItems, (state, { type, items }) => {
545
+ const entitiesSelected = toDictionary(items, adapter);
546
+ const idsSelected = Object.keys(entitiesSelected);
547
+ const result = Object.assign(Object.assign({}, state), { idsSelected,
548
+ // itemsSelected: items,
549
+ entitiesSelected });
550
+ return result;
551
+ });
552
+ const selectItemOn = on(actions.SelectItem, (state, { type, item }) => {
553
+ const idSelected = selectIdValue(item, adapter.selectId);
554
+ const result = Object.assign(Object.assign({}, state), { idSelected, itemSelected: item });
555
+ return result;
556
+ });
557
+ const selectSuccessOn = on(actions.SelectSuccess, (state, { type, item }) => {
558
+ const idSelected = selectIdValue(item, adapter.selectId);
559
+ const result = Object.assign(Object.assign({}, state), { idSelected, itemSelected: item, isLoaded: true, isLoading: false, error: null });
560
+ return result;
561
+ });
562
+ const searchFailureOn = on(actions.SearchFailure, (state, { type, error }) => Object.assign({}, state, {
563
+ isLoaded: false,
564
+ isLoading: false,
565
+ error
566
+ }));
567
+ const deleteFailureOn = on(actions.DeleteFailure, (state, { type, error }) => Object.assign({}, state, {
568
+ isLoaded: false,
569
+ isLoading: false,
570
+ error
571
+ }));
572
+ const deleteManyFailureOn = on(actions.DeleteManyFailure, (state, { type, error }) => Object.assign({}, state, {
573
+ isLoaded: false,
574
+ isLoading: false,
575
+ error
576
+ }));
577
+ const createFailureOn = on(actions.CreateFailure, (state, { type, error }) => Object.assign({}, state, {
578
+ isLoaded: false,
579
+ isLoading: false,
580
+ error
581
+ }));
582
+ const createManyFailureOn = on(actions.CreateManyFailure, (state, { type, error }) => Object.assign({}, state, {
583
+ isLoaded: false,
584
+ isLoading: false,
585
+ error
586
+ }));
587
+ const editFailureOn = on(actions.EditFailure, (state, { error, type }) => Object.assign({}, state, {
588
+ isLoaded: false,
589
+ isLoading: false,
590
+ error
591
+ }));
592
+ const editManyFailureOn = on(actions.EditManyFailure, (state, { error, type }) => Object.assign({}, state, {
593
+ isLoaded: false,
594
+ isLoading: false,
595
+ error
596
+ }));
597
+ const selectFailureOn = on(actions.SelectFailure, (state, { error, type }) => Object.assign({}, state, {
598
+ isLoaded: false,
599
+ isLoading: false,
600
+ error
601
+ }));
602
+ const resetOn = on(actions.Reset, (state) => (Object.assign(Object.assign({}, state), initialState)));
603
+ return {
604
+ responseOn,
605
+ resetResponsesOn,
606
+ searchRequestOn,
607
+ deleteRequestOn,
608
+ deleteManyRequestOn,
609
+ editRequestOn,
610
+ editManyRequestOn,
611
+ createRequestOn,
612
+ createManyRequestOn,
613
+ selectRequestOn,
614
+ searchSuccessOn,
615
+ deleteSuccessOn,
616
+ deleteManySuccessOn,
617
+ createSuccessOn,
618
+ createManySuccessOn,
619
+ selectSuccessOn,
620
+ editSuccessOn,
621
+ editManySuccessOn,
622
+ searchFailureOn,
623
+ deleteFailureOn,
624
+ deleteManyFailureOn,
625
+ createFailureOn,
626
+ createManyFailureOn,
627
+ selectFailureOn,
628
+ editFailureOn,
629
+ editManyFailureOn,
630
+ resetOn,
631
+ filtersOn,
632
+ selectItemsOn,
633
+ removeAllSelectedOn,
634
+ addManySelectedOn,
635
+ removeManySelectedOn,
636
+ selectItemOn,
637
+ editOn,
638
+ createOn,
639
+ deleteOn
640
+ };
641
+ }
642
+ function createCrudReducerFactory(adapter) {
643
+ function createCrudReducer(initialState, actions, ...ons) {
644
+ const { responseOn, resetResponsesOn, searchRequestOn, deleteRequestOn, deleteManyRequestOn, editRequestOn, editManyRequestOn, createRequestOn, createManyRequestOn, selectRequestOn, searchSuccessOn, deleteSuccessOn, deleteManySuccessOn, createSuccessOn, createManySuccessOn, selectSuccessOn, editSuccessOn, editManySuccessOn, searchFailureOn, deleteFailureOn, deleteManyFailureOn, createFailureOn, createManyFailureOn, selectFailureOn, editFailureOn, editManyFailureOn, resetOn, filtersOn, selectItemsOn, removeAllSelectedOn, addManySelectedOn, removeManySelectedOn, selectItemOn, editOn, createOn, deleteOn } = createCrudOns(adapter, initialState, actions);
645
+ const totalOns = [
646
+ ...ons,
647
+ responseOn,
648
+ resetResponsesOn,
649
+ searchRequestOn,
650
+ deleteRequestOn,
651
+ deleteManyRequestOn,
652
+ editRequestOn,
653
+ editManyRequestOn,
654
+ createRequestOn,
655
+ createManyRequestOn,
656
+ selectRequestOn,
657
+ searchSuccessOn,
658
+ deleteSuccessOn,
659
+ deleteManySuccessOn,
660
+ createSuccessOn,
661
+ createManySuccessOn,
662
+ selectSuccessOn,
663
+ editSuccessOn,
664
+ editManySuccessOn,
665
+ searchFailureOn,
666
+ deleteFailureOn,
667
+ deleteManyFailureOn,
668
+ createFailureOn,
669
+ createManyFailureOn,
670
+ selectFailureOn,
671
+ editFailureOn,
672
+ editManyFailureOn,
673
+ resetOn,
674
+ filtersOn,
675
+ selectItemsOn,
676
+ removeAllSelectedOn,
677
+ addManySelectedOn,
678
+ removeManySelectedOn,
679
+ selectItemOn,
680
+ editOn,
681
+ createOn,
682
+ deleteOn
683
+ ];
684
+ return createReducer(initialState, ...totalOns);
685
+ }
686
+ return {
687
+ createCrudReducer
688
+ };
689
+ }
690
+
691
+ function createCrudEntityAdapter(options) {
692
+ const adapter = createEntityAdapter(options);
693
+ const stateFactory = createInitialCrudStateFactory();
694
+ const selectorsFactory = createCrudSelectorsFactory(adapter);
695
+ const actionsFactory = createCrudActionsFactory();
696
+ const reducerFactory = createCrudReducerFactory(adapter);
697
+ return Object.assign({}, adapter, stateFactory, selectorsFactory, actionsFactory, reducerFactory);
698
+ }
699
+
700
+ const searchCall = (service) => {
701
+ return input$ => input$.pipe(switchMap(payload => service.search(payload).pipe(map((response) => ({ response, payload })))));
702
+ };
703
+ const searchResponse = (actions, optEffect) => {
704
+ return input$ => input$.pipe(switchMap(({ response, payload }) => {
705
+ const result = [];
706
+ if (response.hasError) {
707
+ result.push(actions.SearchFailure({ error: response.message }));
708
+ if (payload.onFault) {
709
+ result.push(...payload.onFault);
710
+ }
711
+ }
712
+ else {
713
+ result.push(actions.SearchSuccess({ items: response.data, request: payload }));
714
+ result.push(actions.Filters({ filters: {} }));
715
+ if (payload.onResult) {
716
+ const onResults = payload.onResult.map(a => a.newAction ? a.newAction(response, payload) : a);
717
+ result.push(...onResults);
718
+ }
719
+ }
720
+ if ((optEffect || {}).dispatchResponse || payload.dispatchResponse) {
721
+ result.push(actions.Response({
722
+ actionType: payload.type,
723
+ request: payload,
724
+ response
725
+ }));
726
+ }
727
+ return result;
728
+ }));
729
+ };
730
+ const searchCatchError = (actions) => {
731
+ return input$ => input$.pipe(catchError((error, caught) => {
732
+ const response = [];
733
+ response.push(actions.SearchFailure({ error }));
734
+ response.push(actions.Response({
735
+ actionType: 'Failure',
736
+ request: null,
737
+ response: { hasError: true, message: error.message, data: null }
738
+ }));
739
+ return from(response);
740
+ }));
741
+ };
742
+ const searchRequest = (actions, service, optEffect) => {
743
+ return input$ => input$.pipe(ofType(actions.SearchRequest), searchCall(service), searchResponse(actions, optEffect), searchCatchError(actions), repeat());
744
+ };
745
+ /**
746
+ * @deprecated use:
747
+ *
748
+ * actions$.pipe(
749
+ * searchRequest(actions, service, clazz, optEffect)
750
+ * );
751
+ *
752
+ * or:
753
+ *
754
+ * actions$.pipe(
755
+ * ofType(actions.SearchRequest),
756
+ * searchCall(service),
757
+ * searchResponse(actions, optEffect),
758
+ * searchCatchError(actions),
759
+ * repeat()
760
+ * );
761
+ *
762
+ */
763
+ const searchRequestEffect = (actions$, actions, service, optEffect) => actions$.pipe(searchRequest(actions, service, optEffect));
764
+ const deleteCall = (service) => {
765
+ return input$ => input$.pipe(concatMap(payload => service.delete(payload).pipe(map((response) => ({ response, payload })))));
766
+ };
767
+ const deleteResponse = (actions, clazz, optEffect) => {
768
+ return input$ => input$.pipe(concatMap(({ response, payload }) => {
769
+ const result = [];
770
+ if (response.hasError) {
771
+ result.push(actions.DeleteFailure({ error: response.message }));
772
+ if (payload.onFault) {
773
+ result.push(...payload.onFault);
774
+ }
775
+ }
776
+ else {
777
+ if (!clazz.selectId) {
778
+ throw Error('the selectId method is not present in the managed entity.');
779
+ }
780
+ const id = clazz.selectId(payload.mutationParams);
781
+ result.push(actions.DeleteSuccess({ id }));
782
+ if (payload.onResult) {
783
+ const onResults = payload.onResult.map(a => a.newAction ? a.newAction(response, payload) : a);
784
+ result.push(...onResults);
785
+ }
786
+ }
787
+ if ((optEffect || {}).dispatchResponse || payload.dispatchResponse) {
788
+ result.push(actions.Response({
789
+ actionType: payload.type,
790
+ request: payload,
791
+ response
792
+ }));
793
+ }
794
+ return result;
795
+ }));
796
+ };
797
+ const deleteCatchError = (actions) => {
798
+ return input$ => input$.pipe(catchError((error, caught) => {
799
+ const response = [];
800
+ response.push(actions.EditFailure({ error }));
801
+ response.push(actions.Response({
802
+ actionType: 'Failure',
803
+ request: null,
804
+ response: { hasError: true, message: error.message, data: null }
805
+ }));
806
+ return from(response);
807
+ }));
808
+ };
809
+ const deleteRequest = (actions, service, clazz, optEffect) => {
810
+ return input$ => input$.pipe(ofType(actions.DeleteRequest), deleteCall(service), deleteResponse(actions, clazz, optEffect), deleteCatchError(actions), repeat());
811
+ };
812
+ /**
813
+ * @deprecated use:
814
+ *
815
+ * actions$.pipe(
816
+ * deleteRequest(actions, service, clazz, optEffect)
817
+ * );
818
+ *
819
+ * or:
820
+ *
821
+ * actions$.pipe(
822
+ * ofType(actions.DeleteRequest),
823
+ * deleteCall(service),
824
+ * deleteResponse(actions, clazz, optEffect),
825
+ * deleteCatchError(actions),
826
+ * repeat()
827
+ * );
828
+ *
829
+ */
830
+ const deleteRequestEffect = (actions$, actions, service, clazz, optEffect) => actions$.pipe(deleteRequest(actions, service, clazz, optEffect));
831
+ const deleteManyCall = (service) => {
832
+ return input$ => input$.pipe(concatMap(payload => service.deleteMany((payload)).pipe(map((response) => ({ response, payload })))));
833
+ };
834
+ const deleteManyResponse = (actions, clazz, optEffect) => {
835
+ return input$ => input$.pipe(concatMap(({ response, payload }) => {
836
+ const result = [];
837
+ if (response.hasError) {
838
+ result.push(actions.DeleteManyFailure({ error: response.message }));
839
+ if (payload.onFault) {
840
+ result.push(...payload.onFault);
841
+ }
842
+ }
843
+ else {
844
+ if (!clazz.selectId) {
845
+ throw Error('the selectId method is not present in the managed entity.');
846
+ }
847
+ const ids = payload.mutationParams.map(id => clazz.selectId(id));
848
+ result.push(actions.DeleteManySuccess({ ids }));
849
+ if (payload.onResult) {
850
+ const onResults = payload.onResult.map(a => a.newAction ? a.newAction(response, payload) : a);
851
+ result.push(...onResults);
852
+ }
853
+ }
854
+ if ((optEffect || {}).dispatchResponse || payload.dispatchResponse) {
855
+ result.push(actions.Response({
856
+ actionType: payload.type,
857
+ request: payload,
858
+ response
859
+ }));
860
+ }
861
+ return result;
862
+ }));
863
+ };
864
+ const deleteManyCatchError = (actions) => {
865
+ return input$ => input$.pipe(catchError((error, caught) => {
866
+ const response = [];
867
+ response.push(actions.DeleteManyFailure({ error }));
868
+ response.push(actions.Response({
869
+ actionType: 'Failure',
870
+ request: null,
871
+ response: { hasError: true, message: error.message, data: null }
872
+ }));
873
+ return from(response);
874
+ }));
875
+ };
876
+ const deleteManyRequest = (actions, service, clazz, optEffect) => {
877
+ return input$ => input$.pipe(ofType(actions.DeleteManyRequest), deleteManyCall(service), deleteManyResponse(actions, clazz, optEffect), deleteManyCatchError(actions), repeat());
878
+ };
879
+ const createCall = (service) => {
880
+ return input$ => input$.pipe(concatMap(payload => service.create(payload).pipe(map((response) => ({ response, payload })))));
881
+ };
882
+ const createResponse = (actions, optEffect) => {
883
+ return input$ => input$.pipe(concatMap(({ response, payload }) => {
884
+ const result = [];
885
+ if (response.hasError) {
886
+ result.push(actions.CreateFailure({ error: response.message }));
887
+ if (payload.onFault) {
888
+ result.push(...payload.onFault);
889
+ }
890
+ }
891
+ else {
892
+ const item = response.data;
893
+ result.push(actions.CreateSuccess({ item }));
894
+ if (payload.onResult) {
895
+ const onResults = payload.onResult.map(a => a.newAction ? a.newAction(response, payload) : a);
896
+ result.push(...onResults);
897
+ }
898
+ }
899
+ if ((optEffect || {}).dispatchResponse || payload.dispatchResponse) {
900
+ result.push(actions.Response({
901
+ actionType: payload.type,
902
+ request: payload,
903
+ response
904
+ }));
905
+ }
906
+ return result;
907
+ }));
908
+ };
909
+ const createCatchError = (actions) => {
910
+ return input$ => input$.pipe(catchError((error, caught) => {
911
+ const response = [];
912
+ response.push(actions.CreateFailure({ error }));
913
+ response.push(actions.Response({
914
+ actionType: 'Failure',
915
+ request: null,
916
+ response: { hasError: true, message: error.message, data: null }
917
+ }));
918
+ return from(response);
919
+ }));
920
+ };
921
+ const createRequest = (actions, service, optEffect) => {
922
+ return input$ => input$.pipe(ofType(actions.CreateRequest), createCall(service), createResponse(actions, optEffect), createCatchError(actions), repeat());
923
+ };
924
+ /**
925
+ * @deprecated use:
926
+ *
927
+ * actions$.pipe(
928
+ * createRequest(actions, service, optEffect)
929
+ * );
930
+ *
931
+ * or:
932
+ *
933
+ * actions$.pipe(
934
+ * ofType(actions.DeleteRequest),
935
+ * createCall(service),
936
+ * createResponse(actions, optEffect),
937
+ * createCatchError(actions),
938
+ * repeat()
939
+ * );
940
+ *
941
+ */
942
+ const createRequestEffect = (actions$, actions, service, optEffect) => actions$.pipe(createRequest(actions, service, optEffect));
943
+ const createManyCall = (service) => {
944
+ return input$ => input$.pipe(concatMap(payload => service.createMany(payload).pipe(map((response) => ({ response, payload })))));
945
+ };
946
+ const createManyResponse = (actions, optEffect) => {
947
+ return input$ => input$.pipe(concatMap(({ response, payload }) => {
948
+ const result = [];
949
+ if (response.hasError) {
950
+ result.push(actions.CreateManyFailure({ error: response.message }));
951
+ if (payload.onFault) {
952
+ result.push(...payload.onFault);
953
+ }
954
+ }
955
+ else {
956
+ const items = response.data;
957
+ result.push(actions.CreateManySuccess({ items }));
958
+ if (payload.onResult) {
959
+ const onResults = payload.onResult.map(a => a.newAction ? a.newAction(response, payload) : a);
960
+ result.push(...onResults);
961
+ }
962
+ }
963
+ if ((optEffect || {}).dispatchResponse || payload.dispatchResponse) {
964
+ result.push(actions.Response({
965
+ actionType: payload.type,
966
+ request: payload,
967
+ response
968
+ }));
969
+ }
970
+ return result;
971
+ }));
972
+ };
973
+ const createManyCatchError = (actions) => {
974
+ return input$ => input$.pipe(catchError((error, caught) => {
975
+ const response = [];
976
+ response.push(actions.EditManyFailure({ error }));
977
+ response.push(actions.Response({
978
+ actionType: 'Failure',
979
+ request: null,
980
+ response: { hasError: true, message: error.message, data: null }
981
+ }));
982
+ return from(response);
983
+ }));
984
+ };
985
+ const createManyRequest = (actions, service, optEffect) => {
986
+ return input$ => input$.pipe(ofType(actions.CreateManyRequest), createManyCall(service), createManyResponse(actions, optEffect), createManyCatchError(actions), repeat());
987
+ };
988
+ const editCall = (service) => {
989
+ return input$ => input$.pipe(concatMap(payload => service.update(payload).pipe(map((response) => ({ response, payload })))));
990
+ };
991
+ const editResponse = (actions, optEffect) => {
992
+ return input$ => input$.pipe(concatMap(({ response, payload }) => {
993
+ const result = [];
994
+ if (response.hasError) {
995
+ result.push(actions.EditFailure({ error: response.message }));
996
+ if (payload.onFault) {
997
+ result.push(...payload.onFault);
998
+ }
999
+ }
1000
+ else {
1001
+ const item = response.data;
1002
+ result.push(actions.EditSuccess({ item }));
1003
+ if (payload.onResult) {
1004
+ const onResults = payload.onResult.map(a => a.newAction ? a.newAction(response, payload) : a);
1005
+ result.push(...onResults);
1006
+ }
1007
+ }
1008
+ if ((optEffect || {}).dispatchResponse || payload.dispatchResponse) {
1009
+ result.push(actions.Response({
1010
+ actionType: payload.type,
1011
+ request: payload,
1012
+ response
1013
+ }));
1014
+ }
1015
+ return result;
1016
+ }));
1017
+ };
1018
+ const editCatchError = (actions) => {
1019
+ return input$ => input$.pipe(catchError((error, caught) => {
1020
+ const response = [];
1021
+ response.push(actions.EditFailure({ error }));
1022
+ response.push(actions.Response({
1023
+ actionType: 'Failure',
1024
+ request: null,
1025
+ response: { hasError: true, message: error.message, data: null }
1026
+ }));
1027
+ return from(response);
1028
+ }));
1029
+ };
1030
+ const editRequest = (actions, service, optEffect) => {
1031
+ return input$ => input$.pipe(ofType(actions.EditRequest), editCall(service), editResponse(actions, optEffect), editCatchError(actions), repeat());
1032
+ };
1033
+ /**
1034
+ * @deprecated use:
1035
+ *
1036
+ * actions$.pipe(
1037
+ * editRequest(actions, service, optEffect)
1038
+ * );
1039
+ *
1040
+ * or:
1041
+ *
1042
+ * actions$.pipe(
1043
+ * ofType(actions.EditRequest),
1044
+ * editCall(service),
1045
+ * editResponse(actions, optEffect),
1046
+ * editCatchError(actions),
1047
+ * repeat()
1048
+ * );
1049
+ *
1050
+ */
1051
+ const editRequestEffect = (actions$, actions, service, optEffect) => actions$.pipe(editRequest(actions, service, optEffect));
1052
+ const editManyCall = (service) => {
1053
+ return input$ => input$.pipe(concatMap(payload => service.updateMany(payload).pipe(map((response) => ({ response, payload })))));
1054
+ };
1055
+ const editManyResponse = (actions, optEffect) => {
1056
+ return input$ => input$.pipe(concatMap(({ response, payload }) => {
1057
+ const result = [];
1058
+ if (response.hasError) {
1059
+ result.push(actions.EditManyFailure({ error: response.message }));
1060
+ if (payload.onFault) {
1061
+ result.push(...payload.onFault);
1062
+ }
1063
+ }
1064
+ else {
1065
+ const items = response.data;
1066
+ result.push(actions.EditManySuccess({ items }));
1067
+ if (payload.onResult) {
1068
+ const onResults = payload.onResult.map(a => a.newAction ? a.newAction(response, payload) : a);
1069
+ result.push(...onResults);
1070
+ }
1071
+ }
1072
+ if ((optEffect || {}).dispatchResponse || payload.dispatchResponse) {
1073
+ result.push(actions.Response({
1074
+ actionType: payload.type,
1075
+ request: payload,
1076
+ response
1077
+ }));
1078
+ }
1079
+ return result;
1080
+ }));
1081
+ };
1082
+ const editManyCatchError = (actions) => {
1083
+ return input$ => input$.pipe(catchError((error, caught) => {
1084
+ const response = [];
1085
+ response.push(actions.EditManyFailure({ error }));
1086
+ response.push(actions.Response({
1087
+ actionType: 'Failure',
1088
+ request: null,
1089
+ response: { hasError: true, message: error.message, data: null }
1090
+ }));
1091
+ return from(response);
1092
+ }));
1093
+ };
1094
+ const editManyRequest = (actions, service, optEffect) => {
1095
+ return input$ => input$.pipe(ofType(actions.EditManyRequest), editManyCall(service), editManyResponse(actions, optEffect), editManyCatchError(actions), repeat());
1096
+ };
1097
+ const selectCall = (service) => {
1098
+ return input$ => input$.pipe(concatMap(payload => service.select(payload).pipe(
1099
+ // @ts-ignore
1100
+ map((response) => ({ response, payload })))));
1101
+ };
1102
+ const selectResponse = (actions, optEffect) => {
1103
+ return input$ => input$.pipe(concatMap(({ response, payload }) => {
1104
+ const result = [];
1105
+ if (response.hasError) {
1106
+ result.push(actions.SelectFailure({ error: response.message }));
1107
+ if (payload.onFault) {
1108
+ result.push(...payload.onFault);
1109
+ }
1110
+ }
1111
+ else {
1112
+ const item = response.data;
1113
+ result.push(actions.SelectSuccess({ item }));
1114
+ if (payload.onResult) {
1115
+ const onResults = payload.onResult.map(a => a.newAction ? a.newAction(response, payload) : a);
1116
+ result.push(...onResults);
1117
+ }
1118
+ }
1119
+ if ((optEffect || {}).dispatchResponse || payload.dispatchResponse) {
1120
+ result.push(actions.Response({
1121
+ actionType: payload.type,
1122
+ request: payload,
1123
+ response
1124
+ }));
1125
+ }
1126
+ return result;
1127
+ }));
1128
+ };
1129
+ const selectCatchError = (actions) => {
1130
+ return input$ => input$.pipe(catchError((error, caught) => {
1131
+ const response = [];
1132
+ response.push(actions.EditFailure({ error }));
1133
+ response.push(actions.Response({
1134
+ actionType: 'Failure',
1135
+ request: null,
1136
+ response: { hasError: true, message: error.message, data: null }
1137
+ }));
1138
+ return from(response);
1139
+ }));
1140
+ };
1141
+ const selectRequest = (actions, service, optEffect) => {
1142
+ return input$ => input$.pipe(ofType(actions.SelectRequest), selectCall(service), selectResponse(actions, optEffect), selectCatchError(actions), repeat());
1143
+ };
1144
+ /**
1145
+ * @deprecated use:
1146
+ *
1147
+ * actions$.pipe(
1148
+ * selectRequest(actions, service, clazz, optEffect)
1149
+ * );
1150
+ *
1151
+ * or:
1152
+ *
1153
+ * actions$.pipe(
1154
+ * ofType(actions.SelectRequest),
1155
+ * selectCall(service),
1156
+ * selectResponse(actions, optEffect),
1157
+ * selectCatchError(actions),
1158
+ * repeat()
1159
+ * );
1160
+ *
1161
+ */
1162
+ const selectRequestEffect = (actions$, actions, service, optEffect) => actions$.pipe(selectRequest(actions, service, optEffect));
1163
+
1164
+ class BaseCrudService {
1165
+ constructor(http) {
1166
+ this.http = http;
1167
+ this.service = '';
1168
+ this.id = 'id';
1169
+ this.debug = false;
1170
+ this.httpOptions = () => {
1171
+ return {
1172
+ headers: new HttpHeaders({ 'Content-Type': 'application/json' })
1173
+ };
1174
+ };
1175
+ this.searchMap = res => res;
1176
+ this.getId = (value) => value[this.id];
1177
+ }
1178
+ debugMode() {
1179
+ this.debug = true;
1180
+ }
1181
+ create(opt) {
1182
+ if (typeof (console) !== 'undefined' && this.debug) {
1183
+ console.log('%c BaseCrudService.create()', 'color: #777777');
1184
+ console.log('%c Extended from: ' + this.constructor.name, 'color: #777777');
1185
+ }
1186
+ const path = !!opt && !!opt.path ? opt.path : null;
1187
+ return this.http.post(`${this.getUrl(path)}`, opt.mutationParams, this.httpOptions());
1188
+ }
1189
+ createMany(opt) {
1190
+ this.checkOptRequest(opt);
1191
+ const result = opt.mutationParams.map(mutationParams => {
1192
+ const optB = Object.assign(Object.assign({}, opt), { mutationParams });
1193
+ return this.create(optB).pipe(map(value => (Object.assign(Object.assign({}, value), { data: [value.data] }))) // trasformo la singola risposta da {data:T} in {data:T[]}
1194
+ );
1195
+ });
1196
+ return of(...result).pipe(mergeMap(value => value));
1197
+ }
1198
+ /**
1199
+ * metodo introdotto per la verifica di OptRequest
1200
+ * nella nuova versione è stato sostituito opt.item e opt.items con opt.mutationParams
1201
+ * in modo da renderlo compatibile come nomenclatura a graphql
1202
+ * @param opt
1203
+ */
1204
+ checkOptRequest(opt) {
1205
+ if (opt && opt.hasOwnProperty('item') && !!opt.item) {
1206
+ throw new Error('Error, in new versions of the library the "items" or "item" attribute have been replaced by "mutationParams". all project attributes must be renamed.');
1207
+ }
1208
+ if (opt && opt.hasOwnProperty('items') && !!opt.items) {
1209
+ throw new Error('Error, in new versions of the library the "items" or "item" attribute have been replaced by "mutationParams". all project attributes must be renamed.');
1210
+ }
1211
+ return true;
1212
+ }
1213
+ search(value) {
1214
+ if (typeof (console) !== 'undefined' && this.debug) {
1215
+ console.log('BaseCrudService.search()');
1216
+ console.log('Extended from: ' + this.constructor.name);
1217
+ }
1218
+ const url = value && value.hasOwnProperty('path') && !!value.path ? value.path.join('/') : '';
1219
+ let httpOptions = this.httpOptions();
1220
+ if (value && value.hasOwnProperty('queryParams') && !!value.queryParams) {
1221
+ httpOptions = (Object.assign(Object.assign({}, httpOptions), { params: value.queryParams }));
1222
+ }
1223
+ return this.http.get(this.getUrl() + url, httpOptions).pipe(map(this.searchMap));
1224
+ }
1225
+ select(opt) {
1226
+ if (typeof (console) !== 'undefined' && this.debug) {
1227
+ console.log('%c BaseCrudService.select()', 'color: #777777');
1228
+ console.log('%c Extended from: ' + this.constructor.name, 'color: #777777');
1229
+ }
1230
+ const id = this.getId(opt.queryParams);
1231
+ const path = !!opt && !!opt.path ? opt.path : null;
1232
+ return this
1233
+ .http
1234
+ .get(`${this.getUrl(path)}/${id}`, this.httpOptions());
1235
+ }
1236
+ update(opt) {
1237
+ this.checkOptRequest(opt);
1238
+ if (typeof (console) !== 'undefined' && this.debug) {
1239
+ console.log('%c BaseCrudService.update()', 'color: #777777');
1240
+ console.log('%c Extended from: ' + this.constructor.name, 'color: #777777');
1241
+ }
1242
+ const id = this.getId(opt.mutationParams);
1243
+ const path = !!opt && !!opt.path ? opt.path : null;
1244
+ return this.http.put(`${this.getUrl(path)}/${id}`, opt.mutationParams, this.httpOptions());
1245
+ }
1246
+ updateMany(opt) {
1247
+ this.checkOptRequest(opt);
1248
+ const result = opt.mutationParams.map(mutationParams => {
1249
+ const optB = Object.assign(Object.assign({}, opt), { mutationParams });
1250
+ return this.update(optB).pipe(map(value => (Object.assign(Object.assign({}, value), { data: [value.data] }))) // trasformo la singola risposta da {data:T} in {data:T[]}
1251
+ );
1252
+ });
1253
+ return of(...result).pipe(mergeMap(value => value));
1254
+ }
1255
+ delete(opt) {
1256
+ this.checkOptRequest(opt);
1257
+ if (typeof (console) !== 'undefined' && this.debug) {
1258
+ console.log('%c BaseCrudService.delete()', 'color: #777777');
1259
+ console.log('%c Extended from: ' + this.constructor.name, 'color: #777777');
1260
+ }
1261
+ const id = this.getId(opt.mutationParams);
1262
+ const path = !!opt && !!opt.path ? opt.path : null;
1263
+ return this.http.delete(`${this.getUrl(path)}/${id}`, this.httpOptions());
1264
+ }
1265
+ deleteMany(opt) {
1266
+ this.checkOptRequest(opt);
1267
+ const result = opt.mutationParams.map(mutationParams => {
1268
+ const optB = Object.assign(Object.assign({}, opt), { mutationParams });
1269
+ return this.delete(optB);
1270
+ });
1271
+ return of(...result).pipe(mergeMap(value => value));
1272
+ }
1273
+ getUrl(path) {
1274
+ const result = !!path ? `${this.service}/${path.join('/')}` : this.service;
1275
+ if (typeof (console) !== 'undefined' && this.debug) {
1276
+ console.log('%c BaseCrudService.getUrl(path?:string[]): string', 'color: #777777');
1277
+ console.log('%c path: ' + path, 'color: #777777');
1278
+ console.log('%c Extended from: ' + this.constructor.name, 'color: #777777');
1279
+ console.log('%c result: ' + result, 'color: #777777');
1280
+ }
1281
+ return result;
1282
+ }
1283
+ }
1284
+ BaseCrudService.ɵprov = i0.ɵɵdefineInjectable({ factory: function BaseCrudService_Factory() { return new BaseCrudService(i0.ɵɵinject(i1.HttpClient)); }, token: BaseCrudService, providedIn: "root" });
1285
+ BaseCrudService.decorators = [
1286
+ { type: Injectable, args: [{
1287
+ providedIn: 'root'
1288
+ },] }
1289
+ ];
1290
+ BaseCrudService.ctorParameters = () => [
1291
+ { type: HttpClient }
1292
+ ];
1293
+
1294
+ class BaseCrudGqlService {
1295
+ search(value) {
1296
+ return this.query(value);
1297
+ }
1298
+ select(opt) {
1299
+ return this.mutate(opt);
1300
+ }
1301
+ create(opt) {
1302
+ return this.mutate(opt);
1303
+ }
1304
+ createMany(opt) {
1305
+ return this.mutate(opt);
1306
+ }
1307
+ update(opt) {
1308
+ return this.mutate(opt);
1309
+ }
1310
+ updateMany(opt) {
1311
+ return this.mutate(opt);
1312
+ }
1313
+ delete(opt) {
1314
+ return this.mutate(opt);
1315
+ }
1316
+ deleteMany(opt) {
1317
+ return this.mutate(opt);
1318
+ }
1319
+ //todo tolgo tipizzazione MutationOptions mutateMany(opt: OptRequest<MutationOptions>): Observable<Response<string[]>> {
1320
+ mutateMany(opt) {
1321
+ return this.apollo.mutate(opt.mutationParams).pipe(map((response) => {
1322
+ debugger;
1323
+ return ({
1324
+ message: '',
1325
+ hasError: false,
1326
+ data: response.data.allCoins
1327
+ });
1328
+ }));
1329
+ }
1330
+ //todo tolgo tipizzazione MutationOptions mutate(opt: OptRequest<MutationOptions>): Observable<Response<string[]>> {
1331
+ mutate(opt) {
1332
+ return this.apollo.mutate(opt.mutationParams).pipe(map((response) => {
1333
+ debugger;
1334
+ return ({
1335
+ message: '',
1336
+ hasError: false,
1337
+ data: response.data.allCoins
1338
+ });
1339
+ }));
1340
+ }
1341
+ //todo tolgo tipizzazione QueryOptions query(value?: ICriteria<QueryOptions>): Observable<Response<T[]>> {
1342
+ query(value) {
1343
+ console.log('CoinService.search()');
1344
+ return this.apollo
1345
+ .query(value.queryParams).pipe(map((response) => {
1346
+ debugger;
1347
+ return ({
1348
+ message: '',
1349
+ hasError: false,
1350
+ data: response.data.allCoins
1351
+ });
1352
+ }));
1353
+ }
1354
+ }
1355
+ BaseCrudGqlService.ɵprov = i0.ɵɵdefineInjectable({ factory: function BaseCrudGqlService_Factory() { return new BaseCrudGqlService(); }, token: BaseCrudGqlService, providedIn: "root" });
1356
+ BaseCrudGqlService.decorators = [
1357
+ { type: Injectable, args: [{
1358
+ providedIn: 'root'
1359
+ },] }
1360
+ ];
1361
+
1362
+ /**
1363
+ * Generated bundle index. Do not edit.
1364
+ */
1365
+
1366
+ export { ActionEnum, BaseCrudGqlService, BaseCrudService, CrudEnum, createCall, createCatchError, createCrudEntityAdapter, createCrudOns, createManyCall, createManyCatchError, createManyRequest, createManyResponse, createRequest, createRequestEffect, createResponse, deleteCall, deleteCatchError, deleteManyCall, deleteManyCatchError, deleteManyRequest, deleteManyResponse, deleteRequest, deleteRequestEffect, deleteResponse, editCall, editCatchError, editManyCall, editManyCatchError, editManyRequest, editManyResponse, editRequest, editRequestEffect, editResponse, searchCall, searchCatchError, searchRequest, searchRequestEffect, searchResponse, selectCall, selectCatchError, selectRequest, selectRequestEffect, selectResponse };
1367
+ //# sourceMappingURL=ngrx-entity-crud.js.map