@ecodev/natural 62.1.2 → 62.3.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.
- package/fesm2022/ecodev-natural-vanilla.mjs +1199 -0
- package/fesm2022/ecodev-natural-vanilla.mjs.map +1 -0
- package/fesm2022/ecodev-natural.mjs +625 -644
- package/fesm2022/ecodev-natural.mjs.map +1 -1
- package/lib/classes/abstract-editable-list.d.ts +3 -2
- package/lib/classes/network-activity.service.d.ts +54 -0
- package/lib/classes/validators.d.ts +1 -1
- package/lib/modules/avatar/component/avatar.component.d.ts +21 -36
- package/lib/modules/avatar/service/avatar.service.d.ts +3 -2
- package/lib/modules/columns-picker/columns-picker.component.d.ts +2 -2
- package/lib/modules/common/services/seo.provider.d.ts +2 -2
- package/lib/modules/dropdown-components/type-natural-select/type-natural-select.component.d.ts +1 -0
- package/lib/modules/dropdown-components/type-select/type-select.component.d.ts +1 -1
- package/lib/modules/file/abstract-file.d.ts +8 -5
- package/lib/modules/file/component/file.component.d.ts +9 -4
- package/lib/modules/file/file-drop.directive.d.ts +2 -3
- package/lib/modules/fixed-button-detail/fixed-button-detail.component.d.ts +2 -3
- package/lib/modules/hierarchic-selector/classes/model-node.d.ts +1 -1
- package/lib/modules/hierarchic-selector/hierarchic-selector/hierarchic-selector.component.d.ts +3 -3
- package/lib/modules/icon/icon.module.d.ts +2 -2
- package/lib/modules/panels/panels.service.d.ts +17 -2
- package/lib/modules/relations/relations.component.d.ts +4 -4
- package/lib/modules/search/dropdown-container/dropdown-container.component.d.ts +2 -3
- package/lib/modules/search/group/group.component.d.ts +2 -3
- package/lib/modules/search/input/input.component.d.ts +5 -5
- package/lib/modules/search/search/search.component.d.ts +5 -4
- package/lib/modules/select/abstract-select.component.d.ts +3 -3
- package/lib/modules/select/select/select.component.d.ts +4 -4
- package/lib/modules/sidenav/sidenav-container/sidenav-container.component.d.ts +1 -1
- package/lib/modules/table-button/table-button.component.d.ts +18 -18
- package/package.json +16 -14
- package/public-api.d.ts +1 -0
- package/src/lib/_natural.theme.scss +1 -2
- package/vanilla/index.d.ts +5 -0
- package/vanilla/package.json +3 -0
- package/vanilla/public-api.d.ts +11 -0
- package/vanilla/src/lib/classes/crypto.d.ts +8 -0
- package/vanilla/src/lib/classes/data-source.d.ts +32 -0
- package/vanilla/src/lib/classes/query-variable-manager-utils.d.ts +2 -0
- package/vanilla/src/lib/classes/query-variable-manager.d.ts +91 -0
- package/vanilla/src/lib/classes/signing.d.ts +7 -0
- package/vanilla/src/lib/classes/utility.d.ts +77 -0
- package/vanilla/src/lib/modules/search/classes/graphql-doctrine.types.d.ts +83 -0
- package/vanilla/src/lib/modules/search/classes/utils.d.ts +17 -0
- package/vanilla/src/lib/modules/search/types/dropdown-component.d.ts +20 -0
- package/vanilla/src/lib/modules/search/types/facet.d.ts +75 -0
- package/vanilla/src/lib/modules/search/types/values.d.ts +32 -0
- package/vanilla/src/lib/services/abstract-model.service.d.ts +244 -0
- package/vanilla/src/lib/services/debounce.service.d.ts +52 -0
- package/vanilla/src/lib/types/types.d.ts +100 -0
- package/esm2022/ecodev-natural.mjs +0 -5
- package/esm2022/lib/classes/abstract-detail.mjs +0 -229
- package/esm2022/lib/classes/abstract-editable-list.mjs +0 -99
- package/esm2022/lib/classes/abstract-list.mjs +0 -461
- package/esm2022/lib/classes/abstract-navigable-list.mjs +0 -133
- package/esm2022/lib/classes/apollo-utils.mjs +0 -59
- package/esm2022/lib/classes/crypto.mjs +0 -23
- package/esm2022/lib/classes/cumulative-changes.mjs +0 -50
- package/esm2022/lib/classes/data-source.mjs +0 -71
- package/esm2022/lib/classes/providers.mjs +0 -13
- package/esm2022/lib/classes/query-variable-manager-utils.mjs +0 -14
- package/esm2022/lib/classes/query-variable-manager.mjs +0 -172
- package/esm2022/lib/classes/rxjs.mjs +0 -54
- package/esm2022/lib/classes/signing.mjs +0 -38
- package/esm2022/lib/classes/tld.mjs +0 -1476
- package/esm2022/lib/classes/utility.mjs +0 -234
- package/esm2022/lib/classes/validators.mjs +0 -179
- package/esm2022/lib/directives/http-prefix.directive.mjs +0 -47
- package/esm2022/lib/modules/alert/alert.service.mjs +0 -53
- package/esm2022/lib/modules/alert/confirm.component.mjs +0 -16
- package/esm2022/lib/modules/alert/public-api.mjs +0 -6
- package/esm2022/lib/modules/avatar/component/avatar.component.mjs +0 -203
- package/esm2022/lib/modules/avatar/public-api.mjs +0 -6
- package/esm2022/lib/modules/avatar/service/avatar.service.mjs +0 -63
- package/esm2022/lib/modules/avatar/sources/gravatar.mjs +0 -29
- package/esm2022/lib/modules/avatar/sources/image.mjs +0 -13
- package/esm2022/lib/modules/avatar/sources/initials.mjs +0 -39
- package/esm2022/lib/modules/avatar/sources/source.mjs +0 -16
- package/esm2022/lib/modules/columns-picker/columns-picker.component.mjs +0 -145
- package/esm2022/lib/modules/columns-picker/public-api.mjs +0 -5
- package/esm2022/lib/modules/columns-picker/types.mjs +0 -2
- package/esm2022/lib/modules/common/directives/background-density.directive.mjs +0 -63
- package/esm2022/lib/modules/common/directives/linkable-tab.directive.mjs +0 -93
- package/esm2022/lib/modules/common/directives/src-density.directive.mjs +0 -72
- package/esm2022/lib/modules/common/pipes/capitalize.pipe.mjs +0 -24
- package/esm2022/lib/modules/common/pipes/ellipsis.pipe.mjs +0 -17
- package/esm2022/lib/modules/common/pipes/enum.pipe.mjs +0 -24
- package/esm2022/lib/modules/common/pipes/time-ago.pipe.mjs +0 -140
- package/esm2022/lib/modules/common/public-api.mjs +0 -14
- package/esm2022/lib/modules/common/services/memory-storage.mjs +0 -110
- package/esm2022/lib/modules/common/services/seo.provider.mjs +0 -23
- package/esm2022/lib/modules/common/services/seo.service.mjs +0 -235
- package/esm2022/lib/modules/detail-header/detail-header.component.mjs +0 -84
- package/esm2022/lib/modules/detail-header/public-api.mjs +0 -5
- package/esm2022/lib/modules/dialog-trigger/dialog-trigger.component.mjs +0 -72
- package/esm2022/lib/modules/dialog-trigger/public-api.mjs +0 -5
- package/esm2022/lib/modules/dropdown-components/abstract-association-select-component.directive.mjs +0 -100
- package/esm2022/lib/modules/dropdown-components/public-api.mjs +0 -14
- package/esm2022/lib/modules/dropdown-components/type-boolean/type-boolean.component.mjs +0 -39
- package/esm2022/lib/modules/dropdown-components/type-date/type-date.component.mjs +0 -173
- package/esm2022/lib/modules/dropdown-components/type-date-range/type-date-range.component.mjs +0 -134
- package/esm2022/lib/modules/dropdown-components/type-hierarchic-selector/type-hierarchic-selector.component.mjs +0 -80
- package/esm2022/lib/modules/dropdown-components/type-natural-select/type-natural-select.component.mjs +0 -48
- package/esm2022/lib/modules/dropdown-components/type-number/type-number.component.mjs +0 -110
- package/esm2022/lib/modules/dropdown-components/type-options/type-options.component.mjs +0 -64
- package/esm2022/lib/modules/dropdown-components/type-select/type-select.component.mjs +0 -175
- package/esm2022/lib/modules/dropdown-components/type-text/type-text.component.mjs +0 -62
- package/esm2022/lib/modules/dropdown-components/types.mjs +0 -41
- package/esm2022/lib/modules/dropdown-components/utils.mjs +0 -35
- package/esm2022/lib/modules/file/abstract-file.mjs +0 -230
- package/esm2022/lib/modules/file/component/file.component.mjs +0 -172
- package/esm2022/lib/modules/file/file-drop.directive.mjs +0 -111
- package/esm2022/lib/modules/file/file-select.directive.mjs +0 -26
- package/esm2022/lib/modules/file/file.service.mjs +0 -43
- package/esm2022/lib/modules/file/public-api.mjs +0 -9
- package/esm2022/lib/modules/file/types.mjs +0 -2
- package/esm2022/lib/modules/file/utils.mjs +0 -129
- package/esm2022/lib/modules/fixed-button/fixed-button.component.mjs +0 -30
- package/esm2022/lib/modules/fixed-button/public-api.mjs +0 -5
- package/esm2022/lib/modules/fixed-button-detail/fixed-button-detail.component.mjs +0 -56
- package/esm2022/lib/modules/fixed-button-detail/public-api.mjs +0 -5
- package/esm2022/lib/modules/hierarchic-selector/classes/flat-node.mjs +0 -18
- package/esm2022/lib/modules/hierarchic-selector/classes/hierarchic-configuration.mjs +0 -2
- package/esm2022/lib/modules/hierarchic-selector/classes/hierarchic-filters-configuration.mjs +0 -2
- package/esm2022/lib/modules/hierarchic-selector/classes/model-node.mjs +0 -14
- package/esm2022/lib/modules/hierarchic-selector/hierarchic-selector/hierarchic-selector.component.mjs +0 -398
- package/esm2022/lib/modules/hierarchic-selector/hierarchic-selector/hierarchic-selector.service.mjs +0 -243
- package/esm2022/lib/modules/hierarchic-selector/hierarchic-selector-dialog/hierarchic-selector-dialog.component.mjs +0 -38
- package/esm2022/lib/modules/hierarchic-selector/hierarchic-selector-dialog/hierarchic-selector-dialog.service.mjs +0 -22
- package/esm2022/lib/modules/hierarchic-selector/public-api.mjs +0 -10
- package/esm2022/lib/modules/icon/icon.directive.mjs +0 -96
- package/esm2022/lib/modules/icon/icon.module.mjs +0 -33
- package/esm2022/lib/modules/icon/public-api.mjs +0 -6
- package/esm2022/lib/modules/logger/error-handler.mjs +0 -87
- package/esm2022/lib/modules/logger/error.module.mjs +0 -22
- package/esm2022/lib/modules/logger/public-api.mjs +0 -6
- package/esm2022/lib/modules/matomo/matomo.service.mjs +0 -96
- package/esm2022/lib/modules/matomo/public-api.mjs +0 -5
- package/esm2022/lib/modules/panels/abstract-panel.mjs +0 -76
- package/esm2022/lib/modules/panels/fallback-if-no-opened-panels.urlmatcher.mjs +0 -12
- package/esm2022/lib/modules/panels/panels.component.mjs +0 -27
- package/esm2022/lib/modules/panels/panels.module.mjs +0 -10
- package/esm2022/lib/modules/panels/panels.service.mjs +0 -329
- package/esm2022/lib/modules/panels/panels.urlmatcher.mjs +0 -75
- package/esm2022/lib/modules/panels/public-api.mjs +0 -11
- package/esm2022/lib/modules/panels/types.mjs +0 -3
- package/esm2022/lib/modules/relations/public-api.mjs +0 -5
- package/esm2022/lib/modules/relations/relations.component.mjs +0 -254
- package/esm2022/lib/modules/search/classes/graphql-doctrine.mjs +0 -111
- package/esm2022/lib/modules/search/classes/graphql-doctrine.types.mjs +0 -14
- package/esm2022/lib/modules/search/classes/transformers.mjs +0 -142
- package/esm2022/lib/modules/search/classes/url.mjs +0 -53
- package/esm2022/lib/modules/search/classes/utils.mjs +0 -25
- package/esm2022/lib/modules/search/dropdown-container/dropdown-container-animations.mjs +0 -44
- package/esm2022/lib/modules/search/dropdown-container/dropdown-container.component.mjs +0 -87
- package/esm2022/lib/modules/search/dropdown-container/dropdown-ref.mjs +0 -24
- package/esm2022/lib/modules/search/dropdown-container/dropdown.service.mjs +0 -90
- package/esm2022/lib/modules/search/facet-selector/facet-selector.component.mjs +0 -45
- package/esm2022/lib/modules/search/group/group.component.mjs +0 -53
- package/esm2022/lib/modules/search/input/input.component.mjs +0 -365
- package/esm2022/lib/modules/search/public-api.mjs +0 -7
- package/esm2022/lib/modules/search/search/search.component.mjs +0 -102
- package/esm2022/lib/modules/search/types/dropdown-component.mjs +0 -2
- package/esm2022/lib/modules/search/types/facet.mjs +0 -2
- package/esm2022/lib/modules/search/types/values.mjs +0 -2
- package/esm2022/lib/modules/select/abstract-select.component.mjs +0 -232
- package/esm2022/lib/modules/select/public-api.mjs +0 -7
- package/esm2022/lib/modules/select/select/select.component.mjs +0 -310
- package/esm2022/lib/modules/select/select-enum/select-enum.component.mjs +0 -57
- package/esm2022/lib/modules/select/select-hierarchic/select-hierarchic.component.mjs +0 -155
- package/esm2022/lib/modules/sidenav/public-api.mjs +0 -9
- package/esm2022/lib/modules/sidenav/sidenav/sidenav.component.mjs +0 -15
- package/esm2022/lib/modules/sidenav/sidenav-container/sidenav-container.component.mjs +0 -90
- package/esm2022/lib/modules/sidenav/sidenav-content/sidenav-content.component.mjs +0 -11
- package/esm2022/lib/modules/sidenav/sidenav-stack.service.mjs +0 -50
- package/esm2022/lib/modules/sidenav/sidenav.service.mjs +0 -196
- package/esm2022/lib/modules/stamp/public-api.mjs +0 -5
- package/esm2022/lib/modules/stamp/stamp.component.mjs +0 -23
- package/esm2022/lib/modules/table-button/public-api.mjs +0 -5
- package/esm2022/lib/modules/table-button/table-button.component.mjs +0 -78
- package/esm2022/lib/services/abstract-model.service.mjs +0 -526
- package/esm2022/lib/services/debounce.service.mjs +0 -149
- package/esm2022/lib/services/enum.service.mjs +0 -64
- package/esm2022/lib/services/link-mutation.service.mjs +0 -154
- package/esm2022/lib/services/persistence.service.mjs +0 -115
- package/esm2022/lib/services/swiss-parsing-date-adapter.service.mjs +0 -63
- package/esm2022/lib/types/types.mjs +0 -2
- package/esm2022/public-api.mjs +0 -46
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { Apollo, MutationResult } from 'apollo-angular';
|
|
2
|
+
import { FetchResult, WatchQueryFetchPolicy } from '@apollo/client/core';
|
|
3
|
+
import { AbstractControl, AsyncValidatorFn, UntypedFormGroup, ValidatorFn } from '@angular/forms';
|
|
4
|
+
import { DocumentNode } from 'graphql';
|
|
5
|
+
import { Observable, OperatorFunction } from 'rxjs';
|
|
6
|
+
import { NaturalQueryVariablesManager, QueryVariables } from '../classes/query-variable-manager';
|
|
7
|
+
import { Literal } from '../types/types';
|
|
8
|
+
import { PaginatedData } from '../classes/data-source';
|
|
9
|
+
import { NaturalDebounceService } from './debounce.service';
|
|
10
|
+
export type FormValidators = Record<string, ValidatorFn[]>;
|
|
11
|
+
export type FormAsyncValidators = Record<string, AsyncValidatorFn[]>;
|
|
12
|
+
export type VariablesWithInput = {
|
|
13
|
+
input: Literal;
|
|
14
|
+
};
|
|
15
|
+
export type FormControls = Record<string, AbstractControl>;
|
|
16
|
+
export type WithId<T> = {
|
|
17
|
+
id: string;
|
|
18
|
+
} & T;
|
|
19
|
+
export declare abstract class NaturalAbstractModelService<Tone, Vone extends {
|
|
20
|
+
id: string;
|
|
21
|
+
}, Tall extends PaginatedData<Literal>, Vall extends QueryVariables, Tcreate, Vcreate extends VariablesWithInput, Tupdate, Vupdate extends {
|
|
22
|
+
id: string;
|
|
23
|
+
input: Literal;
|
|
24
|
+
}, Tdelete, Vdelete extends {
|
|
25
|
+
ids: string[];
|
|
26
|
+
}> {
|
|
27
|
+
protected readonly name: string;
|
|
28
|
+
protected readonly oneQuery: DocumentNode | null;
|
|
29
|
+
protected readonly allQuery: DocumentNode | null;
|
|
30
|
+
protected readonly createMutation: DocumentNode | null;
|
|
31
|
+
protected readonly updateMutation: DocumentNode | null;
|
|
32
|
+
protected readonly deleteMutation: DocumentNode | null;
|
|
33
|
+
private readonly createName;
|
|
34
|
+
private readonly updateName;
|
|
35
|
+
private readonly deleteName;
|
|
36
|
+
/**
|
|
37
|
+
* Store the creation mutations that are pending
|
|
38
|
+
*/
|
|
39
|
+
private readonly creatingCache;
|
|
40
|
+
protected readonly apollo: Apollo;
|
|
41
|
+
protected readonly naturalDebounceService: NaturalDebounceService;
|
|
42
|
+
private readonly plural;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param name service and single object query name (eg. userForFront or user).
|
|
46
|
+
* @param oneQuery GraphQL query to fetch a single object from ID (eg. userForCrudQuery).
|
|
47
|
+
* @param allQuery GraphQL query to fetch a filtered list of objects (eg. usersForCrudQuery).
|
|
48
|
+
* @param createMutation GraphQL mutation to create an object.
|
|
49
|
+
* @param updateMutation GraphQL mutation to update an object.
|
|
50
|
+
* @param deleteMutation GraphQL mutation to delete a list of objects.
|
|
51
|
+
* @param plural list query name (eg. usersForFront or users).
|
|
52
|
+
* @param createName create object mutation name (eg. createUser).
|
|
53
|
+
* @param updateName update object mutation name (eg. updateUser).
|
|
54
|
+
* @param deleteName delete object mutation name (eg. deleteUsers).
|
|
55
|
+
*/
|
|
56
|
+
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);
|
|
57
|
+
/**
|
|
58
|
+
* List of individual fields validators
|
|
59
|
+
*/
|
|
60
|
+
getFormValidators(model?: Literal): FormValidators;
|
|
61
|
+
/**
|
|
62
|
+
* List of individual async fields validators
|
|
63
|
+
*/
|
|
64
|
+
getFormAsyncValidators(model?: Literal): FormAsyncValidators;
|
|
65
|
+
/**
|
|
66
|
+
* List of grouped fields validators (like password + confirm password)
|
|
67
|
+
*/
|
|
68
|
+
getFormGroupValidators(model?: Literal): ValidatorFn[];
|
|
69
|
+
/**
|
|
70
|
+
* List of async group fields validators (like unique constraint on multiple columns)
|
|
71
|
+
*/
|
|
72
|
+
getFormGroupAsyncValidators(model?: Literal): AsyncValidatorFn[];
|
|
73
|
+
getFormConfig(model: Literal): FormControls;
|
|
74
|
+
/**
|
|
75
|
+
* Create the final FormGroup for the object, including all validators
|
|
76
|
+
*
|
|
77
|
+
* This method should **not** be overridden, but instead `getFormConfig`,
|
|
78
|
+
* `getFormGroupValidators`, `getFormGroupAsyncValidators` might be.
|
|
79
|
+
*/
|
|
80
|
+
getFormGroup(model: Literal): UntypedFormGroup;
|
|
81
|
+
/**
|
|
82
|
+
* Get a single object
|
|
83
|
+
*
|
|
84
|
+
* If available it will emit object from cache immediately, then it
|
|
85
|
+
* will **always** fetch from network and then the observable will be completed.
|
|
86
|
+
*
|
|
87
|
+
* You must subscribe to start getting results (and fetch from network).
|
|
88
|
+
*/
|
|
89
|
+
getOne(id: string): Observable<Tone>;
|
|
90
|
+
/**
|
|
91
|
+
* Watch a single object
|
|
92
|
+
*
|
|
93
|
+
* If available it will emit object from cache immediately, then it
|
|
94
|
+
* will **always** fetch from network, and then keep watching the cache forever.
|
|
95
|
+
*
|
|
96
|
+
* You must subscribe to start getting results (and fetch from network).
|
|
97
|
+
*
|
|
98
|
+
* You **MUST** unsubscribe.
|
|
99
|
+
*/
|
|
100
|
+
watchOne(id: string, fetchPolicy?: WatchQueryFetchPolicy): Observable<Tone>;
|
|
101
|
+
private prepareOneQuery;
|
|
102
|
+
/**
|
|
103
|
+
* Get a collection of objects
|
|
104
|
+
*
|
|
105
|
+
* It will **always** fetch from network and then the observable will be completed.
|
|
106
|
+
* No cache is ever used, so it's slow but correct.
|
|
107
|
+
*/
|
|
108
|
+
getAll(queryVariablesManager: NaturalQueryVariablesManager<Vall>): Observable<Tall>;
|
|
109
|
+
/**
|
|
110
|
+
* Get a collection of objects
|
|
111
|
+
*
|
|
112
|
+
* Every time the observable variables change, and they are not undefined,
|
|
113
|
+
* it will return result from cache, then it will **always** fetch from network,
|
|
114
|
+
* and then keep watching the cache forever.
|
|
115
|
+
*
|
|
116
|
+
* You must subscribe to start getting results (and fetch from network).
|
|
117
|
+
*
|
|
118
|
+
* You **MUST** unsubscribe.
|
|
119
|
+
*/
|
|
120
|
+
watchAll(queryVariablesManager: NaturalQueryVariablesManager<Vall>, fetchPolicy?: WatchQueryFetchPolicy): Observable<Tall>;
|
|
121
|
+
/**
|
|
122
|
+
* This functions allow to quickly create or update objects.
|
|
123
|
+
*
|
|
124
|
+
* Manages a "creation is pending" status, and update when creation is ready.
|
|
125
|
+
* Uses regular update/updateNow and create methods.
|
|
126
|
+
* Used mainly when editing multiple objects in same controller (like in editable arrays)
|
|
127
|
+
*/
|
|
128
|
+
createOrUpdate(object: Vcreate['input'] | WithId<Vupdate['input']>, now?: boolean): Observable<Tcreate | Tupdate>;
|
|
129
|
+
/**
|
|
130
|
+
* Create an object in DB and then refetch the list of objects
|
|
131
|
+
*/
|
|
132
|
+
create(object: Vcreate['input']): Observable<Tcreate>;
|
|
133
|
+
/**
|
|
134
|
+
* Update an object, after a short debounce
|
|
135
|
+
*/
|
|
136
|
+
update(object: WithId<Vupdate['input']>): Observable<Tupdate>;
|
|
137
|
+
/**
|
|
138
|
+
* Update an object immediately when subscribing
|
|
139
|
+
*/
|
|
140
|
+
updateNow(object: WithId<Vupdate['input']>): Observable<Tupdate>;
|
|
141
|
+
/**
|
|
142
|
+
* Delete objects and then refetch the list of objects
|
|
143
|
+
*/
|
|
144
|
+
delete(objects: {
|
|
145
|
+
id: string;
|
|
146
|
+
}[]): Observable<Tdelete>;
|
|
147
|
+
/**
|
|
148
|
+
* If the id is provided, resolves an observable model. The observable model will only be emitted after we are sure
|
|
149
|
+
* that Apollo cache is fresh and warm. Then the component can subscribe to the observable model to get the model
|
|
150
|
+
* immediately from Apollo cache and any subsequents future mutations that may happen to Apollo cache.
|
|
151
|
+
*
|
|
152
|
+
* Without id, returns default values, in order to show a creation form.
|
|
153
|
+
*/
|
|
154
|
+
resolve(id: string | undefined): Observable<Observable<Tone | Vcreate['input']>>;
|
|
155
|
+
/**
|
|
156
|
+
* Return an object that match the GraphQL input type.
|
|
157
|
+
* It creates an object with manually filled data and add uncompleted data (like required attributes that can be empty strings)
|
|
158
|
+
*/
|
|
159
|
+
getInput(object: Literal, forCreation: boolean): Vcreate['input'] | Vupdate['input'];
|
|
160
|
+
/**
|
|
161
|
+
* Return the number of objects matching the query. It may never complete.
|
|
162
|
+
*
|
|
163
|
+
* This is used for the unique validator
|
|
164
|
+
*/
|
|
165
|
+
count(queryVariablesManager: NaturalQueryVariablesManager<Vall>): Observable<number>;
|
|
166
|
+
/**
|
|
167
|
+
* Return empty object with some default values from server perspective
|
|
168
|
+
*
|
|
169
|
+
* This is typically useful when showing a form for creation
|
|
170
|
+
*/
|
|
171
|
+
getDefaultForServer(): Vcreate['input'];
|
|
172
|
+
/**
|
|
173
|
+
* You probably **should not** use this.
|
|
174
|
+
*
|
|
175
|
+
* If you are trying to *call* this method, instead you probably want to call `getDefaultForServer()` to get default
|
|
176
|
+
* values for a model, or `getFormConfig()` to get a configured form that includes extra form fields.
|
|
177
|
+
*
|
|
178
|
+
* If you are trying to *override* this method, instead you probably want to override `getDefaultForServer()`.
|
|
179
|
+
*
|
|
180
|
+
* The only and **very rare** reason to override this method is if the client needs extra form fields that cannot be
|
|
181
|
+
* accepted by the server (not part of `XXXInput` type) and that are strictly for the client form needs. In that case,
|
|
182
|
+
* then you can return default values for those extra form fields, and the form returned by `getFormConfig()` will
|
|
183
|
+
* include those extra fields.
|
|
184
|
+
*/
|
|
185
|
+
protected getFormExtraFieldDefaultValues(): Literal;
|
|
186
|
+
/**
|
|
187
|
+
* This is used to extract only the array of fetched objects out of the entire fetched data
|
|
188
|
+
*/
|
|
189
|
+
protected mapAll(): OperatorFunction<FetchResult<unknown>, Tall>;
|
|
190
|
+
/**
|
|
191
|
+
* This is used to extract only the created object out of the entire fetched data
|
|
192
|
+
*/
|
|
193
|
+
protected mapCreation(result: MutationResult<unknown>): Tcreate;
|
|
194
|
+
/**
|
|
195
|
+
* This is used to extract only the updated object out of the entire fetched data
|
|
196
|
+
*/
|
|
197
|
+
protected mapUpdate(result: MutationResult<unknown>): Tupdate;
|
|
198
|
+
/**
|
|
199
|
+
* This is used to extract only flag when deleting an object
|
|
200
|
+
*/
|
|
201
|
+
protected mapDelete(result: MutationResult<unknown>): Tdelete;
|
|
202
|
+
/**
|
|
203
|
+
* Returns additional variables to be used when getting a single object
|
|
204
|
+
*
|
|
205
|
+
* This is typically a site or state ID, and is needed to get appropriate access rights
|
|
206
|
+
*/
|
|
207
|
+
protected getPartialVariablesForOne(): Observable<Partial<Vone>>;
|
|
208
|
+
/**
|
|
209
|
+
* Returns additional variables to be used when getting multiple objects
|
|
210
|
+
*
|
|
211
|
+
* This is typically a site or state ID, but it could be something else to further filter the query
|
|
212
|
+
*/
|
|
213
|
+
getPartialVariablesForAll(): Observable<Partial<Vall>>;
|
|
214
|
+
/**
|
|
215
|
+
* Returns additional variables to be used when creating an object
|
|
216
|
+
*
|
|
217
|
+
* This is typically a site or state ID
|
|
218
|
+
*/
|
|
219
|
+
protected getPartialVariablesForCreation(object: Literal): Partial<Vcreate>;
|
|
220
|
+
/**
|
|
221
|
+
* Returns additional variables to be used when updating an object
|
|
222
|
+
*
|
|
223
|
+
* This is typically a site or state ID
|
|
224
|
+
*/
|
|
225
|
+
protected getPartialVariablesForUpdate(object: Literal): Partial<Vupdate>;
|
|
226
|
+
/**
|
|
227
|
+
* Return additional variables to be used when deleting an object
|
|
228
|
+
*
|
|
229
|
+
* This is typically a site or state ID
|
|
230
|
+
*/
|
|
231
|
+
protected getPartialVariablesForDelete(objects: Literal[]): Partial<Vdelete>;
|
|
232
|
+
/**
|
|
233
|
+
* Throw exception to prevent executing queries with invalid variables
|
|
234
|
+
*/
|
|
235
|
+
protected throwIfObservable(value: unknown): void;
|
|
236
|
+
/**
|
|
237
|
+
* Merge given ID with additional partial variables if there is any
|
|
238
|
+
*/
|
|
239
|
+
private getVariablesForOne;
|
|
240
|
+
/**
|
|
241
|
+
* Throw exception to prevent executing null queries
|
|
242
|
+
*/
|
|
243
|
+
private throwIfNotQuery;
|
|
244
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { UntypedModelService } from '../types/types';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Debounce subscriptions to update mutations, with the possibility to cancel one, flush one, or flush all of them.
|
|
6
|
+
*
|
|
7
|
+
* `modelService` is also used to separate objects by their types. So User with ID 1 is not confused with Product with ID 1.
|
|
8
|
+
*
|
|
9
|
+
* `id` must be the ID of the object that will be updated.
|
|
10
|
+
*/
|
|
11
|
+
export declare class NaturalDebounceService {
|
|
12
|
+
/**
|
|
13
|
+
* Stores the debounced update function
|
|
14
|
+
*/
|
|
15
|
+
private readonly allDebouncedUpdateCache;
|
|
16
|
+
/**
|
|
17
|
+
* Debounce the `modelService.updateNow()` mutation for a short time. If called multiple times with the same
|
|
18
|
+
* modelService and id, it will postpone the subscription to the mutation.
|
|
19
|
+
*
|
|
20
|
+
* All input variables for the same object (same service and ID) will be cumulated over time. So it is possible
|
|
21
|
+
* to update `field1`, then `field2`, and they will be batched into a single XHR including `field1` and `field2`.
|
|
22
|
+
*
|
|
23
|
+
* But it will always keep the same debouncing timeline.
|
|
24
|
+
*/
|
|
25
|
+
debounce<T extends UntypedModelService>(modelService: UntypedModelService, id: string, object: Parameters<T['updateNow']>[0]): ReturnType<T['updateNow']>;
|
|
26
|
+
cancelOne(modelService: UntypedModelService, id: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Immediately execute the pending update, if any.
|
|
29
|
+
*
|
|
30
|
+
* It should typically be called before resolving the object, to mutate it before re-fetching it from server.
|
|
31
|
+
*
|
|
32
|
+
* The returned observable will complete when the update completes, even if it errors.
|
|
33
|
+
*/
|
|
34
|
+
flushOne(modelService: UntypedModelService, id: string): Observable<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Immediately execute all pending updates.
|
|
37
|
+
*
|
|
38
|
+
* It should typically be called before login out.
|
|
39
|
+
*
|
|
40
|
+
* The returned observable will complete when all updates complete, even if some of them error.
|
|
41
|
+
*/
|
|
42
|
+
flush(): Observable<void>;
|
|
43
|
+
private internalFlush;
|
|
44
|
+
/**
|
|
45
|
+
* Count of pending updates
|
|
46
|
+
*/
|
|
47
|
+
get count(): number;
|
|
48
|
+
private getMap;
|
|
49
|
+
private delete;
|
|
50
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NaturalDebounceService, never>;
|
|
51
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<NaturalDebounceService>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { PaginatedData } from '../classes/data-source';
|
|
2
|
+
import { NaturalAbstractModelService, VariablesWithInput } from '../services/abstract-model.service';
|
|
3
|
+
import { QueryVariables } from '../classes/query-variable-manager';
|
|
4
|
+
import { ObservedValueOf } from 'rxjs';
|
|
5
|
+
import { ResolveData } from '@angular/router';
|
|
6
|
+
/**
|
|
7
|
+
* An object literal with any keys and values
|
|
8
|
+
*/
|
|
9
|
+
export type Literal = Record<string, any>;
|
|
10
|
+
/**
|
|
11
|
+
* An object with either a name or a fullName (or maybe both)
|
|
12
|
+
*/
|
|
13
|
+
export type NameOrFullName = {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
fullName?: string;
|
|
17
|
+
} | {
|
|
18
|
+
id: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
fullName: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Extract the Tone type from a NaturalAbstractModelService
|
|
24
|
+
*/
|
|
25
|
+
export type ExtractTone<P> = P extends NaturalAbstractModelService<infer Tone, any, any, any, any, any, any, any, any, any> ? Tone : never;
|
|
26
|
+
/**
|
|
27
|
+
* Extract the Vone type from a NaturalAbstractModelService
|
|
28
|
+
*/
|
|
29
|
+
export type ExtractVone<P> = P extends NaturalAbstractModelService<any, infer Vone, any, any, any, any, any, any, any, any> ? Vone extends {
|
|
30
|
+
id: string;
|
|
31
|
+
} ? Vone : never : never;
|
|
32
|
+
/**
|
|
33
|
+
* Extract the Tall type from a NaturalAbstractModelService
|
|
34
|
+
*/
|
|
35
|
+
export type ExtractTall<P> = P extends NaturalAbstractModelService<any, any, infer Tall, any, any, any, any, any, any, any> ? Tall extends PaginatedData<Literal> ? Tall : never : never;
|
|
36
|
+
/**
|
|
37
|
+
* Extract the TallOne type for a single item coming from a list of items from a NaturalAbstractModelService
|
|
38
|
+
*/
|
|
39
|
+
export type ExtractTallOne<P> = P extends NaturalAbstractModelService<any, any, PaginatedData<infer TallOne extends Literal>, any, any, any, any, any, any, any> ? TallOne extends Literal ? TallOne : never : never;
|
|
40
|
+
/**
|
|
41
|
+
* Extract the Vall type from a NaturalAbstractModelService
|
|
42
|
+
*/
|
|
43
|
+
export type ExtractVall<P> = P extends NaturalAbstractModelService<any, any, any, infer Vall, any, any, any, any, any, any> ? Vall extends QueryVariables ? Vall : never : never;
|
|
44
|
+
/**
|
|
45
|
+
* Extract the Tcreate type from a NaturalAbstractModelService
|
|
46
|
+
*/
|
|
47
|
+
export type ExtractTcreate<P> = P extends NaturalAbstractModelService<any, any, any, any, infer Tcreate, any, any, any, any, any> ? Tcreate : never;
|
|
48
|
+
/**
|
|
49
|
+
* Extract the Vcreate type from a NaturalAbstractModelService
|
|
50
|
+
*/
|
|
51
|
+
export type ExtractVcreate<P> = P extends NaturalAbstractModelService<any, any, any, any, any, infer Vcreate, any, any, any, any> ? Vcreate extends VariablesWithInput ? Vcreate : never : never;
|
|
52
|
+
/**
|
|
53
|
+
* Extract the Tupdate type from a NaturalAbstractModelService
|
|
54
|
+
*/
|
|
55
|
+
export type ExtractTupdate<P> = P extends NaturalAbstractModelService<any, any, any, any, any, any, infer Tupdate, any, any, any> ? Tupdate : never;
|
|
56
|
+
/**
|
|
57
|
+
* Extract the Vupdate type from a NaturalAbstractModelService
|
|
58
|
+
*/
|
|
59
|
+
export type ExtractVupdate<P> = P extends NaturalAbstractModelService<any, any, any, any, any, any, any, infer Vupdate, any, any> ? Vupdate extends {
|
|
60
|
+
id: string;
|
|
61
|
+
input: Literal;
|
|
62
|
+
} ? Vupdate : never : never;
|
|
63
|
+
/**
|
|
64
|
+
* Extract the Tdelete type from a NaturalAbstractModelService
|
|
65
|
+
*/
|
|
66
|
+
export type ExtractTdelete<P> = P extends NaturalAbstractModelService<any, any, any, any, any, any, any, any, infer Tdelete, any> ? Tdelete : never;
|
|
67
|
+
/**
|
|
68
|
+
* Extract the Vdelete type from a NaturalAbstractModelService
|
|
69
|
+
*/
|
|
70
|
+
export type ExtractVdelete<P> = P extends NaturalAbstractModelService<any, any, any, any, any, any, any, any, any, infer Vdelete> ? Vdelete extends {
|
|
71
|
+
ids: string[];
|
|
72
|
+
} ? Vdelete : never : never;
|
|
73
|
+
/**
|
|
74
|
+
* Extract the resolve type from a NaturalAbstractModelService
|
|
75
|
+
*/
|
|
76
|
+
export type ExtractResolve<P> = P extends NaturalAbstractModelService<any, any, any, any, any, any, any, any, any, any> ? ObservedValueOf<ObservedValueOf<ReturnType<P['resolve']>>> : never;
|
|
77
|
+
/**
|
|
78
|
+
* This should be avoided if possible, and instead use a more precise type with some constraints on it to ensure that the model
|
|
79
|
+
* service is able to fulfill its requirements.
|
|
80
|
+
*/
|
|
81
|
+
export type UntypedModelService = NaturalAbstractModelService<any, any, any, any, any, any, any, any, any, any>;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the resolved data type, as available in components, from the given resolvers
|
|
84
|
+
*
|
|
85
|
+
* Eg:
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* const actionResolvers = {
|
|
89
|
+
* model: resolveAction,
|
|
90
|
+
* statuses: () => inject(NaturalEnumService).get('Status'),
|
|
91
|
+
* } as const;
|
|
92
|
+
*
|
|
93
|
+
* // In action.component.ts
|
|
94
|
+
* const data: ResolvedData<typeof actionResolvers>;
|
|
95
|
+
* data.statuses.forEach(...);
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export type ResolvedData<T extends ResolveData> = {
|
|
99
|
+
readonly [KeyType in keyof Pick<T, keyof T>]: ObservedValueOf<ReturnType<Pick<T, keyof T>[KeyType]>>;
|
|
100
|
+
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generated bundle index. Do not edit.
|
|
3
|
-
*/
|
|
4
|
-
export * from './public-api';
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWNvZGV2LW5hdHVyYWwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9wcm9qZWN0cy9uYXR1cmFsL3NyYy9lY29kZXYtbmF0dXJhbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpYy1hcGknO1xuIl19
|