@ecodev/natural 63.9.1 → 64.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 (160) hide show
  1. package/fesm2022/ecodev-natural-vanilla.mjs +3 -3
  2. package/fesm2022/ecodev-natural-vanilla.mjs.map +1 -1
  3. package/fesm2022/ecodev-natural.mjs +520 -650
  4. package/fesm2022/ecodev-natural.mjs.map +1 -1
  5. package/index.d.ts +4264 -3
  6. package/package.json +9 -9
  7. package/src/lib/modules/sidenav/_sidenav.theme.scss +1 -1
  8. package/vanilla/index.d.ts +418 -3
  9. package/lib/classes/abstract-detail.d.ts +0 -108
  10. package/lib/classes/abstract-editable-list.d.ts +0 -70
  11. package/lib/classes/abstract-list.d.ts +0 -191
  12. package/lib/classes/abstract-navigable-list.d.ts +0 -54
  13. package/lib/classes/apollo-utils.d.ts +0 -18
  14. package/lib/classes/crypto.d.ts +0 -8
  15. package/lib/classes/cumulative-changes.d.ts +0 -27
  16. package/lib/classes/data-source.d.ts +0 -32
  17. package/lib/classes/network-activity.service.d.ts +0 -54
  18. package/lib/classes/providers.d.ts +0 -5
  19. package/lib/classes/query-variable-manager-utils.d.ts +0 -2
  20. package/lib/classes/query-variable-manager.d.ts +0 -91
  21. package/lib/classes/rxjs.d.ts +0 -42
  22. package/lib/classes/signing.d.ts +0 -7
  23. package/lib/classes/tld.d.ts +0 -10
  24. package/lib/classes/utility.d.ts +0 -85
  25. package/lib/classes/validators.d.ts +0 -72
  26. package/lib/directives/http-prefix.directive.d.ts +0 -15
  27. package/lib/modules/alert/alert.service.d.ts +0 -21
  28. package/lib/modules/alert/confirm.component.d.ts +0 -12
  29. package/lib/modules/alert/public-api.d.ts +0 -2
  30. package/lib/modules/avatar/component/avatar.component.d.ts +0 -37
  31. package/lib/modules/avatar/public-api.d.ts +0 -2
  32. package/lib/modules/avatar/service/avatar.service.d.ts +0 -24
  33. package/lib/modules/avatar/sources/gravatar.d.ts +0 -8
  34. package/lib/modules/avatar/sources/image.d.ts +0 -8
  35. package/lib/modules/avatar/sources/initials.d.ts +0 -8
  36. package/lib/modules/avatar/sources/source.d.ts +0 -23
  37. package/lib/modules/columns-picker/columns-picker.component.d.ts +0 -45
  38. package/lib/modules/columns-picker/public-api.d.ts +0 -2
  39. package/lib/modules/columns-picker/types.d.ts +0 -84
  40. package/lib/modules/common/directives/background-density.directive.d.ts +0 -37
  41. package/lib/modules/common/directives/linkable-tab.directive.d.ts +0 -29
  42. package/lib/modules/common/directives/src-density.directive.d.ts +0 -33
  43. package/lib/modules/common/pipes/capitalize.pipe.d.ts +0 -10
  44. package/lib/modules/common/pipes/ellipsis.pipe.d.ts +0 -7
  45. package/lib/modules/common/pipes/enum.pipe.d.ts +0 -14
  46. package/lib/modules/common/pipes/time-ago.pipe.d.ts +0 -18
  47. package/lib/modules/common/public-api.d.ts +0 -11
  48. package/lib/modules/common/services/memory-storage.d.ts +0 -46
  49. package/lib/modules/common/services/seo.provider.d.ts +0 -6
  50. package/lib/modules/common/services/seo.service.d.ts +0 -148
  51. package/lib/modules/detail-header/detail-header.component.d.ts +0 -43
  52. package/lib/modules/detail-header/public-api.d.ts +0 -1
  53. package/lib/modules/dialog-trigger/dialog-trigger.component.d.ts +0 -37
  54. package/lib/modules/dialog-trigger/public-api.d.ts +0 -1
  55. package/lib/modules/dropdown-components/abstract-association-select-component.directive.d.ts +0 -34
  56. package/lib/modules/dropdown-components/public-api.d.ts +0 -10
  57. package/lib/modules/dropdown-components/type-boolean/type-boolean.component.d.ts +0 -12
  58. package/lib/modules/dropdown-components/type-date/type-date.component.d.ts +0 -36
  59. package/lib/modules/dropdown-components/type-date-range/type-date-range.component.d.ts +0 -43
  60. package/lib/modules/dropdown-components/type-hierarchic-selector/type-hierarchic-selector.component.d.ts +0 -31
  61. package/lib/modules/dropdown-components/type-natural-select/type-natural-select.component.d.ts +0 -18
  62. package/lib/modules/dropdown-components/type-number/type-number.component.d.ts +0 -36
  63. package/lib/modules/dropdown-components/type-options/type-options.component.d.ts +0 -29
  64. package/lib/modules/dropdown-components/type-select/type-select.component.d.ts +0 -59
  65. package/lib/modules/dropdown-components/type-text/type-text.component.d.ts +0 -26
  66. package/lib/modules/dropdown-components/types.d.ts +0 -13
  67. package/lib/modules/dropdown-components/utils.d.ts +0 -14
  68. package/lib/modules/file/abstract-file.d.ts +0 -95
  69. package/lib/modules/file/component/file.component.d.ts +0 -58
  70. package/lib/modules/file/file-drop.directive.d.ts +0 -32
  71. package/lib/modules/file/file-select.directive.d.ts +0 -15
  72. package/lib/modules/file/file.service.d.ts +0 -19
  73. package/lib/modules/file/public-api.d.ts +0 -6
  74. package/lib/modules/file/types.d.ts +0 -7
  75. package/lib/modules/file/utils.d.ts +0 -8
  76. package/lib/modules/fixed-button/fixed-button.component.d.ts +0 -11
  77. package/lib/modules/fixed-button/public-api.d.ts +0 -1
  78. package/lib/modules/fixed-button-detail/fixed-button-detail.component.d.ts +0 -24
  79. package/lib/modules/fixed-button-detail/public-api.d.ts +0 -1
  80. package/lib/modules/hierarchic-selector/classes/flat-node.d.ts +0 -11
  81. package/lib/modules/hierarchic-selector/classes/hierarchic-configuration.d.ts +0 -56
  82. package/lib/modules/hierarchic-selector/classes/hierarchic-filters-configuration.d.ts +0 -7
  83. package/lib/modules/hierarchic-selector/classes/model-node.d.ts +0 -13
  84. package/lib/modules/hierarchic-selector/hierarchic-selector/hierarchic-selector.component.d.ts +0 -161
  85. package/lib/modules/hierarchic-selector/hierarchic-selector/hierarchic-selector.service.d.ts +0 -76
  86. package/lib/modules/hierarchic-selector/hierarchic-selector-dialog/hierarchic-selector-dialog.component.d.ts +0 -59
  87. package/lib/modules/hierarchic-selector/hierarchic-selector-dialog/hierarchic-selector-dialog.service.d.ts +0 -9
  88. package/lib/modules/hierarchic-selector/public-api.d.ts +0 -6
  89. package/lib/modules/icon/icon.directive.d.ts +0 -39
  90. package/lib/modules/icon/icon.module.d.ts +0 -9
  91. package/lib/modules/icon/public-api.d.ts +0 -2
  92. package/lib/modules/logger/error-handler.d.ts +0 -52
  93. package/lib/modules/logger/error.module.d.ts +0 -3
  94. package/lib/modules/logger/public-api.d.ts +0 -3
  95. package/lib/modules/matomo/matomo.service.d.ts +0 -42
  96. package/lib/modules/matomo/public-api.d.ts +0 -1
  97. package/lib/modules/panels/abstract-panel.d.ts +0 -37
  98. package/lib/modules/panels/fallback-if-no-opened-panels.urlmatcher.d.ts +0 -6
  99. package/lib/modules/panels/panels.component.d.ts +0 -9
  100. package/lib/modules/panels/panels.module.d.ts +0 -3
  101. package/lib/modules/panels/panels.service.d.ts +0 -121
  102. package/lib/modules/panels/panels.urlmatcher.d.ts +0 -8
  103. package/lib/modules/panels/public-api.d.ts +0 -7
  104. package/lib/modules/panels/types.d.ts +0 -61
  105. package/lib/modules/relations/public-api.d.ts +0 -1
  106. package/lib/modules/relations/relations.component.d.ts +0 -123
  107. package/lib/modules/search/classes/graphql-doctrine.d.ts +0 -4
  108. package/lib/modules/search/classes/graphql-doctrine.types.d.ts +0 -83
  109. package/lib/modules/search/classes/transformers.d.ts +0 -78
  110. package/lib/modules/search/classes/url.d.ts +0 -18
  111. package/lib/modules/search/classes/utils.d.ts +0 -17
  112. package/lib/modules/search/dropdown-container/dropdown-container.component.d.ts +0 -31
  113. package/lib/modules/search/dropdown-container/dropdown-ref.d.ts +0 -13
  114. package/lib/modules/search/dropdown-container/dropdown.service.d.ts +0 -24
  115. package/lib/modules/search/facet-selector/facet-selector.component.d.ts +0 -32
  116. package/lib/modules/search/group/group.component.d.ts +0 -21
  117. package/lib/modules/search/input/input.component.d.ts +0 -110
  118. package/lib/modules/search/public-api.d.ts +0 -11
  119. package/lib/modules/search/search/search.component.d.ts +0 -44
  120. package/lib/modules/search/types/dropdown-component.d.ts +0 -20
  121. package/lib/modules/search/types/facet.d.ts +0 -75
  122. package/lib/modules/search/types/values.d.ts +0 -32
  123. package/lib/modules/select/abstract-select.component.d.ts +0 -127
  124. package/lib/modules/select/public-api.d.ts +0 -3
  125. package/lib/modules/select/select/select.component.d.ts +0 -135
  126. package/lib/modules/select/select-enum/select-enum.component.d.ts +0 -32
  127. package/lib/modules/select/select-hierarchic/select-hierarchic.component.d.ts +0 -65
  128. package/lib/modules/sidenav/public-api.d.ts +0 -5
  129. package/lib/modules/sidenav/sidenav/sidenav.component.d.ts +0 -5
  130. package/lib/modules/sidenav/sidenav-container/sidenav-container.component.d.ts +0 -45
  131. package/lib/modules/sidenav/sidenav-content/sidenav-content.component.d.ts +0 -5
  132. package/lib/modules/sidenav/sidenav-stack.service.d.ts +0 -28
  133. package/lib/modules/sidenav/sidenav.service.d.ts +0 -86
  134. package/lib/modules/stamp/public-api.d.ts +0 -1
  135. package/lib/modules/stamp/stamp.component.d.ts +0 -15
  136. package/lib/modules/table-button/public-api.d.ts +0 -1
  137. package/lib/modules/table-button/table-button.component.d.ts +0 -32
  138. package/lib/services/abstract-model.service.d.ts +0 -244
  139. package/lib/services/debounce.service.d.ts +0 -52
  140. package/lib/services/enum.service.d.ts +0 -19
  141. package/lib/services/link-mutation.service.d.ts +0 -51
  142. package/lib/services/persistence.service.d.ts +0 -50
  143. package/lib/services/swiss-parsing-date-adapter.service.d.ts +0 -16
  144. package/lib/types/types.d.ts +0 -100
  145. package/public-api.d.ts +0 -44
  146. package/vanilla/public-api.d.ts +0 -11
  147. package/vanilla/src/lib/classes/crypto.d.ts +0 -8
  148. package/vanilla/src/lib/classes/data-source.d.ts +0 -32
  149. package/vanilla/src/lib/classes/query-variable-manager-utils.d.ts +0 -2
  150. package/vanilla/src/lib/classes/query-variable-manager.d.ts +0 -91
  151. package/vanilla/src/lib/classes/signing.d.ts +0 -7
  152. package/vanilla/src/lib/classes/utility.d.ts +0 -85
  153. package/vanilla/src/lib/modules/search/classes/graphql-doctrine.types.d.ts +0 -83
  154. package/vanilla/src/lib/modules/search/classes/utils.d.ts +0 -17
  155. package/vanilla/src/lib/modules/search/types/dropdown-component.d.ts +0 -20
  156. package/vanilla/src/lib/modules/search/types/facet.d.ts +0 -75
  157. package/vanilla/src/lib/modules/search/types/values.d.ts +0 -32
  158. package/vanilla/src/lib/services/abstract-model.service.d.ts +0 -244
  159. package/vanilla/src/lib/services/debounce.service.d.ts +0 -52
  160. package/vanilla/src/lib/types/types.d.ts +0 -100
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecodev/natural",
3
- "version": "63.9.1",
3
+ "version": "64.0.0",
4
4
  "license": "MIT",
5
5
  "repository": "github:Ecodev/natural",
6
6
  "sideEffects": false,
@@ -23,14 +23,14 @@
23
23
  "tslib": "^2.8.1"
24
24
  },
25
25
  "peerDependencies": {
26
- "@angular/cdk": "^19.2.0",
27
- "@angular/common": "^19.2.0",
28
- "@angular/core": "^19.2.0",
29
- "@angular/forms": "^19.2.0",
30
- "@angular/localize": "^19.2.0",
31
- "@angular/material": "^19.2.0",
32
- "@angular/platform-browser": "^19.2.0",
33
- "@angular/router": "^19.2.0",
26
+ "@angular/cdk": "^20.3.0",
27
+ "@angular/common": "^20.3.0",
28
+ "@angular/core": "^20.3.0",
29
+ "@angular/forms": "^20.3.0",
30
+ "@angular/localize": "^20.3.0",
31
+ "@angular/material": "^20.3.0",
32
+ "@angular/platform-browser": "^20.3.0",
33
+ "@angular/router": "^20.3.0",
34
34
  "apollo-angular": "^10.0.0",
35
35
  "es-toolkit": "^1.39.7",
36
36
  "rxjs": "^7.8.2"
@@ -10,7 +10,7 @@
10
10
  border-right: none;
11
11
  }
12
12
 
13
- mat-sidenav[ng-reflect-mode='side'] {
13
+ mat-sidenav.modeSide {
14
14
  .mat-drawer-inner-container {
15
15
  display: flex;
16
16
  flex-direction: column;
@@ -1,5 +1,420 @@
1
+ import { BehaviorSubject, Observable, OperatorFunction } from 'rxjs';
2
+ import { Apollo, MutationResult } from 'apollo-angular';
3
+ import { WatchQueryFetchPolicy, FetchResult } from '@apollo/client/core';
4
+ import { ValidatorFn, AsyncValidatorFn, AbstractControl, UntypedFormGroup } from '@angular/forms';
5
+ import { DocumentNode } from 'graphql';
6
+ import * as i0 from '@angular/core';
7
+ import { HttpInterceptorFn } from '@angular/common/http';
8
+
9
+ type QueryVariables = {
10
+ filter?: any | null;
11
+ pagination?: PaginationInput | null;
12
+ sorting?: Sorting[] | null;
13
+ };
14
+ type PaginationInput = {
15
+ offset?: number | null;
16
+ pageIndex?: number | null;
17
+ pageSize?: number | null;
18
+ };
19
+ type Sorting = {
20
+ field: any;
21
+ order?: SortingOrder | null;
22
+ nullAsHighest?: boolean | null;
23
+ emptyStringAsHighest?: boolean | null;
24
+ };
25
+ declare enum SortingOrder {
26
+ ASC = "ASC",
27
+ DESC = "DESC"
28
+ }
1
29
  /**
2
- * Generated bundle index. Do not edit.
30
+ * Filter manager stores a set of channels that contain a variable object and exposes an observable "variables" that updates with the result
31
+ * of all channels merged together.
32
+ *
33
+ * A channel is supposed to be used by a given aspect of the GUI (pagination, sorting, search, others ?).
34
+ *
35
+ * ```ts
36
+ * const fm = new QueryVariablesManager();
37
+ * fm.merge('componentA-variables', {a : [1, 2, 3]});
38
+ * ```
39
+ *
40
+ * Variables attributes is a BehaviorSubject. That mean it's not mandatory to subscribe, we can just call getValue or value attributes on
41
+ * it :
42
+ *
43
+ * ```ts
44
+ * console.log(fm.variables.value); // {a : [1, 2, 3]}
45
+ * ```
46
+ *
47
+ * Set new variables for 'componentA-variables':
48
+ *
49
+ * ```ts
50
+ * fm.merge('componentA-variables', {a : [1, 2]});
51
+ * console.log(fm.variables.value); // {a : [1, 2, 3]}
52
+ * ```
53
+ *
54
+ * Set new variables for new channel:
55
+ *
56
+ * ```ts
57
+ * fm.merge('componentB-variables', {a : [3, 4]});
58
+ * console.log(fm.variables.value); // {a : [1, 2, 3, 4]}
59
+ * ```
3
60
  */
4
- /// <amd-module name="@ecodev/natural/vanilla" />
5
- export * from './public-api';
61
+ declare class NaturalQueryVariablesManager<T extends QueryVariables = QueryVariables> {
62
+ readonly variables: BehaviorSubject<T | undefined>;
63
+ private readonly channels;
64
+ constructor(queryVariablesManager?: NaturalQueryVariablesManager<T>);
65
+ /**
66
+ * Set or override all the variables that may exist in the given channel
67
+ */
68
+ set(channelName: string, variables: Partial<T> | null | undefined): void;
69
+ /**
70
+ * Return a deep clone of the variables for the given channel name.
71
+ *
72
+ * Avoid returning the same reference to prevent an attribute change, then another channel update that would
73
+ * used this changed attribute without having explicitly asked QueryVariablesManager to update it.
74
+ */
75
+ get(channelName: string): Partial<T> | undefined;
76
+ /**
77
+ * Merge variable into a channel, overriding arrays in same channel / key
78
+ */
79
+ merge(channelName: string, newVariables: Partial<T>): void;
80
+ /**
81
+ * Apply default values to a channel
82
+ * Note : lodash defaults only defines values on destinations keys that are undefined
83
+ */
84
+ defaults(channelName: string, newVariables: Partial<T>): void;
85
+ private getChannelsCopy;
86
+ /**
87
+ * Merge channels in a single object
88
+ * Arrays are concatenated
89
+ * Filter groups are combined smartly (see mergeGroupList)
90
+ */
91
+ private updateVariables;
92
+ /**
93
+ * Cross merge two filters
94
+ * Only accepts groups with same groupLogic (ignores the first one, because there is no groupLogic in this one)
95
+ * @throws In case two non-empty lists of groups are given and at one of them mix groupLogic value, throws an error
96
+ */
97
+ private mergeGroupList;
98
+ }
99
+
100
+ type PaginatedData<T> = {
101
+ readonly items: readonly T[];
102
+ readonly offset?: number | null;
103
+ readonly pageSize: number;
104
+ readonly pageIndex: number;
105
+ readonly length: number;
106
+ };
107
+
108
+ /**
109
+ * Debounce subscriptions to update mutations, with the possibility to cancel one, flush one, or flush all of them.
110
+ *
111
+ * `modelService` is also used to separate objects by their types. So User with ID 1 is not confused with Product with ID 1.
112
+ *
113
+ * `id` must be the ID of the object that will be updated.
114
+ */
115
+ declare class NaturalDebounceService {
116
+ /**
117
+ * Stores the debounced update function
118
+ */
119
+ private readonly allDebouncedUpdateCache;
120
+ /**
121
+ * Debounce the `modelService.updateNow()` mutation for a short time. If called multiple times with the same
122
+ * modelService and id, it will postpone the subscription to the mutation.
123
+ *
124
+ * All input variables for the same object (same service and ID) will be cumulated over time. So it is possible
125
+ * to update `field1`, then `field2`, and they will be batched into a single XHR including `field1` and `field2`.
126
+ *
127
+ * But it will always keep the same debouncing timeline.
128
+ */
129
+ debounce<T extends UntypedModelService>(modelService: UntypedModelService, id: string, object: Parameters<T['updateNow']>[0]): ReturnType<T['updateNow']>;
130
+ cancelOne(modelService: UntypedModelService, id: string): void;
131
+ /**
132
+ * Immediately execute the pending update, if any.
133
+ *
134
+ * It should typically be called before resolving the object, to mutate it before re-fetching it from server.
135
+ *
136
+ * The returned observable will complete when the update completes, even if it errors.
137
+ */
138
+ flushOne(modelService: UntypedModelService, id: string): Observable<void>;
139
+ /**
140
+ * Immediately execute all pending updates.
141
+ *
142
+ * It should typically be called before login out.
143
+ *
144
+ * The returned observable will complete when all updates complete, even if some of them error.
145
+ */
146
+ flush(): Observable<void>;
147
+ private internalFlush;
148
+ /**
149
+ * Count of pending updates
150
+ */
151
+ get count(): number;
152
+ private getMap;
153
+ private delete;
154
+ static ɵfac: i0.ɵɵFactoryDeclaration<NaturalDebounceService, never>;
155
+ static ɵprov: i0.ɵɵInjectableDeclaration<NaturalDebounceService>;
156
+ }
157
+
158
+ type FormValidators = Record<string, ValidatorFn[]>;
159
+ type FormAsyncValidators = Record<string, AsyncValidatorFn[]>;
160
+ type VariablesWithInput = {
161
+ input: Literal;
162
+ };
163
+ type FormControls = Record<string, AbstractControl>;
164
+ type WithId<T> = {
165
+ id: string;
166
+ } & T;
167
+ declare abstract class NaturalAbstractModelService<Tone, Vone extends {
168
+ id: string;
169
+ }, Tall extends PaginatedData<Literal>, Vall extends QueryVariables, Tcreate, Vcreate extends VariablesWithInput, Tupdate, Vupdate extends {
170
+ id: string;
171
+ input: Literal;
172
+ }, Tdelete, Vdelete extends {
173
+ ids: string[];
174
+ }> {
175
+ protected readonly name: string;
176
+ protected readonly oneQuery: DocumentNode | null;
177
+ protected readonly allQuery: DocumentNode | null;
178
+ protected readonly createMutation: DocumentNode | null;
179
+ protected readonly updateMutation: DocumentNode | null;
180
+ protected readonly deleteMutation: DocumentNode | null;
181
+ private readonly createName;
182
+ private readonly updateName;
183
+ private readonly deleteName;
184
+ /**
185
+ * Store the creation mutations that are pending
186
+ */
187
+ private readonly creatingCache;
188
+ protected readonly apollo: Apollo;
189
+ protected readonly naturalDebounceService: NaturalDebounceService;
190
+ private readonly plural;
191
+ /**
192
+ *
193
+ * @param name service and single object query name (eg. userForFront or user).
194
+ * @param oneQuery GraphQL query to fetch a single object from ID (eg. userForCrudQuery).
195
+ * @param allQuery GraphQL query to fetch a filtered list of objects (eg. usersForCrudQuery).
196
+ * @param createMutation GraphQL mutation to create an object.
197
+ * @param updateMutation GraphQL mutation to update an object.
198
+ * @param deleteMutation GraphQL mutation to delete a list of objects.
199
+ * @param plural list query name (eg. usersForFront or users).
200
+ * @param createName create object mutation name (eg. createUser).
201
+ * @param updateName update object mutation name (eg. updateUser).
202
+ * @param deleteName delete object mutation name (eg. deleteUsers).
203
+ */
204
+ constructor(name: string, oneQuery: DocumentNode | null, allQuery: DocumentNode | null, createMutation: DocumentNode | null, updateMutation: DocumentNode | null, deleteMutation: DocumentNode | null, plural?: string | null, createName?: string | null, updateName?: string | null, deleteName?: string | null);
205
+ /**
206
+ * List of individual fields validators
207
+ */
208
+ getFormValidators(model?: Literal): FormValidators;
209
+ /**
210
+ * List of individual async fields validators
211
+ */
212
+ getFormAsyncValidators(model?: Literal): FormAsyncValidators;
213
+ /**
214
+ * List of grouped fields validators (like password + confirm password)
215
+ */
216
+ getFormGroupValidators(model?: Literal): ValidatorFn[];
217
+ /**
218
+ * List of async group fields validators (like unique constraint on multiple columns)
219
+ */
220
+ getFormGroupAsyncValidators(model?: Literal): AsyncValidatorFn[];
221
+ getFormConfig(model: Literal): FormControls;
222
+ /**
223
+ * Create the final FormGroup for the object, including all validators
224
+ *
225
+ * This method should **not** be overridden, but instead `getFormConfig`,
226
+ * `getFormGroupValidators`, `getFormGroupAsyncValidators` might be.
227
+ */
228
+ getFormGroup(model: Literal): UntypedFormGroup;
229
+ /**
230
+ * Get a single object
231
+ *
232
+ * If available it will emit object from cache immediately, then it
233
+ * will **always** fetch from network and then the observable will be completed.
234
+ *
235
+ * You must subscribe to start getting results (and fetch from network).
236
+ */
237
+ getOne(id: string): Observable<Tone>;
238
+ /**
239
+ * Watch a single object
240
+ *
241
+ * If available it will emit object from cache immediately, then it
242
+ * will **always** fetch from network, and then keep watching the cache forever.
243
+ *
244
+ * You must subscribe to start getting results (and fetch from network).
245
+ *
246
+ * You **MUST** unsubscribe.
247
+ */
248
+ watchOne(id: string, fetchPolicy?: WatchQueryFetchPolicy): Observable<Tone>;
249
+ private prepareOneQuery;
250
+ /**
251
+ * Get a collection of objects
252
+ *
253
+ * It will **always** fetch from network and then the observable will be completed.
254
+ * No cache is ever used, so it's slow but correct.
255
+ */
256
+ getAll(queryVariablesManager: NaturalQueryVariablesManager<Vall>): Observable<Tall>;
257
+ /**
258
+ * Get a collection of objects
259
+ *
260
+ * Every time the observable variables change, and they are not undefined,
261
+ * it will return result from cache, then it will **always** fetch from network,
262
+ * and then keep watching the cache forever.
263
+ *
264
+ * You must subscribe to start getting results (and fetch from network).
265
+ *
266
+ * You **MUST** unsubscribe.
267
+ */
268
+ watchAll(queryVariablesManager: NaturalQueryVariablesManager<Vall>, fetchPolicy?: WatchQueryFetchPolicy): Observable<Tall>;
269
+ /**
270
+ * This functions allow to quickly create or update objects.
271
+ *
272
+ * Manages a "creation is pending" status, and update when creation is ready.
273
+ * Uses regular update/updateNow and create methods.
274
+ * Used mainly when editing multiple objects in same controller (like in editable arrays)
275
+ */
276
+ createOrUpdate(object: Vcreate['input'] | WithId<Vupdate['input']>, now?: boolean): Observable<Tcreate | Tupdate>;
277
+ /**
278
+ * Create an object in DB and then refetch the list of objects
279
+ */
280
+ create(object: Vcreate['input']): Observable<Tcreate>;
281
+ /**
282
+ * Update an object, after a short debounce
283
+ */
284
+ update(object: WithId<Vupdate['input']>): Observable<Tupdate>;
285
+ /**
286
+ * Update an object immediately when subscribing
287
+ */
288
+ updateNow(object: WithId<Vupdate['input']>): Observable<Tupdate>;
289
+ /**
290
+ * Delete objects and then refetch the list of objects
291
+ */
292
+ delete(objects: {
293
+ id: string;
294
+ }[]): Observable<Tdelete>;
295
+ /**
296
+ * If the id is provided, resolves an observable model. The observable model will only be emitted after we are sure
297
+ * that Apollo cache is fresh and warm. Then the component can subscribe to the observable model to get the model
298
+ * immediately from Apollo cache and any subsequents future mutations that may happen to Apollo cache.
299
+ *
300
+ * Without id, returns default values, in order to show a creation form.
301
+ */
302
+ resolve(id: string | undefined): Observable<Observable<Tone | Vcreate['input']>>;
303
+ /**
304
+ * Return an object that match the GraphQL input type.
305
+ * It creates an object with manually filled data and add uncompleted data (like required attributes that can be empty strings)
306
+ */
307
+ getInput(object: Literal, forCreation: boolean): Vcreate['input'] | Vupdate['input'];
308
+ /**
309
+ * Return the number of objects matching the query. It may never complete.
310
+ *
311
+ * This is used for the unique validator
312
+ */
313
+ count(queryVariablesManager: NaturalQueryVariablesManager<Vall>): Observable<number>;
314
+ /**
315
+ * Return empty object with some default values from server perspective
316
+ *
317
+ * This is typically useful when showing a form for creation
318
+ */
319
+ getDefaultForServer(): Vcreate['input'];
320
+ /**
321
+ * You probably **should not** use this.
322
+ *
323
+ * If you are trying to *call* this method, instead you probably want to call `getDefaultForServer()` to get default
324
+ * values for a model, or `getFormConfig()` to get a configured form that includes extra form fields.
325
+ *
326
+ * If you are trying to *override* this method, instead you probably want to override `getDefaultForServer()`.
327
+ *
328
+ * The only and **very rare** reason to override this method is if the client needs extra form fields that cannot be
329
+ * accepted by the server (not part of `XXXInput` type) and that are strictly for the client form needs. In that case,
330
+ * then you can return default values for those extra form fields, and the form returned by `getFormConfig()` will
331
+ * include those extra fields.
332
+ */
333
+ protected getFormExtraFieldDefaultValues(): Literal;
334
+ /**
335
+ * This is used to extract only the array of fetched objects out of the entire fetched data
336
+ */
337
+ protected mapAll(): OperatorFunction<FetchResult<unknown>, Tall>;
338
+ /**
339
+ * This is used to extract only the created object out of the entire fetched data
340
+ */
341
+ protected mapCreation(result: MutationResult<unknown>): Tcreate;
342
+ /**
343
+ * This is used to extract only the updated object out of the entire fetched data
344
+ */
345
+ protected mapUpdate(result: MutationResult<unknown>): Tupdate;
346
+ /**
347
+ * This is used to extract only flag when deleting an object
348
+ */
349
+ protected mapDelete(result: MutationResult<unknown>): Tdelete;
350
+ /**
351
+ * Returns additional variables to be used when getting a single object
352
+ *
353
+ * This is typically a site or state ID, and is needed to get appropriate access rights
354
+ */
355
+ protected getPartialVariablesForOne(): Observable<Partial<Vone>>;
356
+ /**
357
+ * Returns additional variables to be used when getting multiple objects
358
+ *
359
+ * This is typically a site or state ID, but it could be something else to further filter the query
360
+ */
361
+ getPartialVariablesForAll(): Observable<Partial<Vall>>;
362
+ /**
363
+ * Returns additional variables to be used when creating an object
364
+ *
365
+ * This is typically a site or state ID
366
+ */
367
+ protected getPartialVariablesForCreation(object: Literal): Partial<Vcreate>;
368
+ /**
369
+ * Returns additional variables to be used when updating an object
370
+ *
371
+ * This is typically a site or state ID
372
+ */
373
+ protected getPartialVariablesForUpdate(object: Literal): Partial<Vupdate>;
374
+ /**
375
+ * Return additional variables to be used when deleting an object
376
+ *
377
+ * This is typically a site or state ID
378
+ */
379
+ protected getPartialVariablesForDelete(objects: Literal[]): Partial<Vdelete>;
380
+ /**
381
+ * Throw exception to prevent executing queries with invalid variables
382
+ */
383
+ protected throwIfObservable(value: unknown): void;
384
+ /**
385
+ * Merge given ID with additional partial variables if there is any
386
+ */
387
+ private getVariablesForOne;
388
+ /**
389
+ * Throw exception to prevent executing null queries
390
+ */
391
+ private throwIfNotQuery;
392
+ }
393
+
394
+ /**
395
+ * An object literal with any keys and values
396
+ */
397
+ type Literal = Record<string, any>;
398
+ /**
399
+ * This should be avoided if possible, and instead use a more precise type with some constraints on it to ensure that the model
400
+ * service is able to fulfill its requirements.
401
+ */
402
+ type UntypedModelService = NaturalAbstractModelService<any, any, any, any, any, any, any, any, any, any>;
403
+
404
+ /**
405
+ * Sign all HTTP POST requests that are GraphQL queries against `/graphql` endpoint with a custom signature.
406
+ *
407
+ * The server will validate the signature before executing the GraphQL query.
408
+ */
409
+ declare function graphqlQuerySigner(key: string): HttpInterceptorFn;
410
+
411
+ /**
412
+ * Format a date and time in a way that will preserve the local time zone.
413
+ * This allows the server side to know the day (without time) that was selected on client side.
414
+ *
415
+ * So something like: "2021-09-23T17:57:16+09:00"
416
+ */
417
+ declare function formatIsoDateTime(date: Date): string;
418
+
419
+ export { NaturalAbstractModelService, NaturalQueryVariablesManager, formatIsoDateTime, graphqlQuerySigner };
420
+ export type { FormValidators, Literal };
@@ -1,108 +0,0 @@
1
- import { OnInit } from '@angular/core';
2
- import { UntypedFormGroup } from '@angular/forms';
3
- import { ActivatedRoute, type NavigationExtras, Router } from '@angular/router';
4
- import { NaturalAlertService } from '../modules/alert/alert.service';
5
- import { NaturalAbstractPanel } from '../modules/panels/abstract-panel';
6
- import { NaturalAbstractModelService } from '../services/abstract-model.service';
7
- import { ExtractResolve, ExtractTcreate, ExtractTone, ExtractTupdate, Literal } from '../types/types';
8
- import { Observable } from 'rxjs';
9
- import { PaginatedData } from './data-source';
10
- import { QueryVariables } from './query-variable-manager';
11
- import * as i0 from "@angular/core";
12
- /**
13
- * `Data` contains in `model` either the model fetched from DB or default values (without ID). And besides `model`,
14
- * any other extra keys defined by Extra.
15
- */
16
- type Data<TService, Extra> = {
17
- model: {
18
- id?: string;
19
- } & ExtractResolve<TService>;
20
- } & Extra;
21
- export declare class NaturalAbstractDetail<TService extends NaturalAbstractModelService<{
22
- id: string;
23
- }, any, PaginatedData<Literal>, QueryVariables, any, any, any, any, unknown, any>, ExtraResolve extends Literal = Record<never, never>> extends NaturalAbstractPanel implements OnInit {
24
- #private;
25
- protected readonly key: string;
26
- readonly service: TService;
27
- /**
28
- * Data retrieved by the server via route resolvers.
29
- *
30
- * The key `model` is special. It is readonly and represents the model being updated
31
- * as it exists on server. The value is kept up to date when Apollo mutates it on server.
32
- *
33
- * The only time when `model` is not readonly is during creation. Only then can we modify the model values directly.
34
- *
35
- * Other keys, if present, are whatever is returned from route resolvers as-is.
36
- */
37
- data: Data<TService, ExtraResolve>;
38
- /**
39
- * Form that manages the data from the controller
40
- */
41
- form: UntypedFormGroup;
42
- /**
43
- * Show / hides the bottom fab button (mostly to hide it when we are on other tabs where semantic of button can conflict with ...
44
- * semantic of data on other tab, like relations that list other objects)
45
- */
46
- showFabButton: boolean;
47
- protected readonly alertService: NaturalAlertService;
48
- protected readonly router: Router;
49
- protected readonly route: ActivatedRoute;
50
- private readonly _dialogData;
51
- /**
52
- * Once set, this must not change anymore, especially not right after the creation mutation,
53
- * so the form does not switch from creation mode to update mode without an actual reload of
54
- * model from DB (by navigating to update page).
55
- */
56
- private _isUpdatePage;
57
- private readonly changes;
58
- constructor(key: string, service: TService);
59
- /**
60
- * You probably should not override this method. Instead, consider overriding `initForm()`.
61
- */
62
- ngOnInit(): void;
63
- changeTab(index: number): void;
64
- /**
65
- * Returns whether `data.model` was fetched from DB, so we are on an update page, or if it is a new object
66
- * with (only) default values, so we are on a creation page.
67
- *
68
- * This should be used instead of checking `data.model.id` directly, in order to type guard and get proper typing
69
- */
70
- protected isUpdatePage(): this is {
71
- data: {
72
- model: ExtractTone<TService>;
73
- };
74
- };
75
- /**
76
- * Update the object on the server with the values from the form fields that were modified since
77
- * the initialization, or since the previous successful update.
78
- *
79
- * Form fields that are never modified are **not** sent to the server, unless if you specify `submitAllFields`.
80
- */
81
- update(now?: boolean, submitAllFields?: boolean): void;
82
- create(redirect?: boolean): void;
83
- /**
84
- * `confirmer` can be used to open a custom dialog, or anything else, to confirm the deletion, instead of the standard dialog
85
- */
86
- delete(redirectionRoute?: unknown[] | {
87
- commands: unknown[];
88
- extras: NavigationExtras;
89
- }, confirmer?: Observable<boolean | undefined>): void;
90
- protected postUpdate(model: ExtractTupdate<TService>): void;
91
- /**
92
- * Returns an observable that will be subscribed to immediately and the
93
- * redirect navigation will only happen after the observable completes.
94
- */
95
- protected postCreate(model: ExtractTcreate<TService>): Observable<unknown>;
96
- protected preDelete(model: ExtractTone<TService>): void;
97
- /**
98
- * Initialize the form whenever it is needed.
99
- *
100
- * You should override this method, and not `ngOnInit()` if you need to customize the form. Because this will
101
- * correctly be called more than one time per component instance if needed, when the route changes. But `ngOnInit()`
102
- * will incorrectly be called exactly 1 time per component instance, even if the object changes via route navigation.
103
- */
104
- protected initForm(): void;
105
- static ɵfac: i0.ɵɵFactoryDeclaration<NaturalAbstractDetail<any, any>, never>;
106
- static ɵdir: i0.ɵɵDirectiveDeclaration<NaturalAbstractDetail<any, any>, never, never, {}, {}, never, never, true, never>;
107
- }
108
- export {};
@@ -1,70 +0,0 @@
1
- import { AbstractControl, UntypedFormArray, UntypedFormGroup } from '@angular/forms';
2
- import { MatTableDataSource } from '@angular/material/table';
3
- import { NaturalAbstractModelService } from '../services/abstract-model.service';
4
- import { NaturalQueryVariablesManager, QueryVariables } from './query-variable-manager';
5
- import { ExtractTallOne, ExtractVall, Literal } from '../types/types';
6
- import { PaginatedData } from './data-source';
7
- import * as i0 from "@angular/core";
8
- /**
9
- * This class helps managing non-paginated rows of items that can be edited in-place, typically in a <mat-table>.
10
- * But it does **not** mutate anything to persist the edits on the server. It is up to the consuming component to implement
11
- * custom mutation mechanism.
12
- *
13
- * To access data of this component from a parent component, use:
14
- *
15
- * ```ts
16
- * private readonly cmp = viewChildren(ComponentType);
17
- *
18
- * this.cmp.getItems();
19
- * ```
20
- *
21
- * To add empty line, call:
22
- *
23
- * ```
24
- * this.cmp.addEmpty();
25
- * ```
26
- *
27
- * @dynamic
28
- */
29
- export declare class NaturalAbstractEditableList<TService extends NaturalAbstractModelService<any, any, PaginatedData<Literal>, QueryVariables, any, any, any, any, any, any>, T extends Literal = ExtractTallOne<TService>> {
30
- protected readonly service: TService;
31
- readonly form: UntypedFormGroup;
32
- readonly formArray: UntypedFormArray;
33
- readonly variablesManager: NaturalQueryVariablesManager<ExtractVall<TService>>;
34
- readonly dataSource: MatTableDataSource<AbstractControl<any, any>, import("@angular/material/paginator").MatPaginator>;
35
- constructor(service: TService);
36
- /**
37
- * Set the list of items (overwriting what may have existed)
38
- */
39
- setItems(items: readonly T[]): void;
40
- /**
41
- * Add given items to the list
42
- * Reproduces the model data loading the same way as it would be on a detail page (via AbstractDetail controller) but without resolving
43
- */
44
- addItems(items: readonly T[]): void;
45
- removeAt(index: number): void;
46
- /**
47
- * Add empty item at the end of the list
48
- */
49
- addEmpty(): void;
50
- /**
51
- * Return a list of models without any treatment.
52
- *
53
- * To mutate models, it would be required to map them using :
54
- * - AbstractModelService.getInput()
55
- * - AbstractModelService.getPartialVariablesForCreation()
56
- * - AbstractModelService.getPartialVariablesForUpdate()
57
- * - some other required treatment.
58
- *
59
- * TODO return type is incorrect and should be closer to `Partial<T>[]` or an even looser type, because we don't really know what fields exists in the form. When we fix this, we should also remove type coercing in unit tests.
60
- */
61
- getItems(): T[];
62
- /**
63
- * Force the form validation.
64
- *
65
- * The valid state can then be read via `this.form.valid`
66
- */
67
- validateForm(): void;
68
- static ɵfac: i0.ɵɵFactoryDeclaration<NaturalAbstractEditableList<any, any>, never>;
69
- static ɵdir: i0.ɵɵDirectiveDeclaration<NaturalAbstractEditableList<any, any>, never, never, {}, {}, never, never, true, never>;
70
- }