@sumaris-net/ngx-components 18.1.7 → 18.2.1
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/doc/changelog.md +4 -0
- package/esm2022/src/app/admin/services/person.service.mjs +7 -6
- package/esm2022/src/app/core/graphql/graphql.service.mjs +2 -2
- package/esm2022/src/app/core/services/base-entity-service.class.mjs +27 -18
- package/esm2022/src/app/shared/services/entity-service.class.mjs +1 -1
- package/fesm2022/sumaris-net.ngx-components.mjs +33 -23
- package/fesm2022/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app/admin/services/person.service.d.ts +4 -18
- package/src/app/core/graphql/graphql.service.d.ts +6 -6
- package/src/app/core/services/base-entity-service.class.d.ts +13 -8
- package/src/app/shared/services/entity-service.class.d.ts +10 -10
- package/src/assets/manifest.json +1 -1
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { FetchPolicy } from '@apollo/client/core';
|
|
2
1
|
import { BehaviorSubject } from 'rxjs';
|
|
3
2
|
import { GraphqlService } from '../../core/graphql/graphql.service';
|
|
4
3
|
import { NetworkService } from '../../core/services/network.service';
|
|
5
4
|
import { EntitiesStorage } from '../../core/services/storage/entities-storage.service';
|
|
6
5
|
import { Person } from '../../core/services/model/person.model';
|
|
7
6
|
import { SortDirection } from '@angular/material/sort';
|
|
8
|
-
import { EntitiesServiceLoadOptions, LoadResult, SuggestService } from '../../shared/services/entity-service.class';
|
|
7
|
+
import { EntitiesServiceLoadOptions, EntityServiceLoadOptions, LoadResult, SuggestService } from '../../shared/services/entity-service.class';
|
|
9
8
|
import { PlatformService } from '../../core/services/platform.service';
|
|
10
9
|
import { PersonFilter } from './filter/person.filter';
|
|
11
10
|
import { BaseEntityService } from '../../core/services/base-entity-service.class';
|
|
@@ -20,31 +19,18 @@ export declare class PersonService extends BaseEntityService<Person, PersonFilte
|
|
|
20
19
|
protected entities: EntitiesStorage;
|
|
21
20
|
constructor(graphql: GraphqlService, platform: PlatformService, network: NetworkService, entities: EntitiesStorage);
|
|
22
21
|
loadAll(offset: number, size: number, sortBy?: keyof Person | string, sortDirection?: SortDirection, filter?: Partial<PersonFilter>, opts?: EntitiesServiceLoadOptions & {
|
|
23
|
-
[key: string]: any;
|
|
24
22
|
debug?: boolean;
|
|
25
23
|
}): Promise<LoadResult<Person>>;
|
|
26
|
-
loadAllLocally(offset: number, size: number, sortBy?: string, sortDirection?: SortDirection, filter?: Partial<PersonFilter>, opts?: {
|
|
27
|
-
[key: string]: any;
|
|
28
|
-
fetchPolicy?: FetchPolicy;
|
|
24
|
+
loadAllLocally(offset: number, size: number, sortBy?: string, sortDirection?: SortDirection, filter?: Partial<PersonFilter>, opts?: EntitiesServiceLoadOptions & {
|
|
29
25
|
debug?: boolean;
|
|
30
|
-
withTotal?: boolean;
|
|
31
|
-
toEntity?: boolean;
|
|
32
26
|
}): Promise<LoadResult<Person>>;
|
|
33
27
|
suggest(value: any, filter?: Partial<PersonFilter>, sortBy?: keyof Person | string, sortDirection?: SortDirection, opts?: EntitiesServiceLoadOptions): Promise<LoadResult<Person>>;
|
|
34
28
|
executeImport(filter: Partial<PersonFilter>, opts: {
|
|
35
29
|
progression?: BehaviorSubject<number>;
|
|
36
30
|
maxProgression?: number;
|
|
37
31
|
}): Promise<void>;
|
|
38
|
-
loadById(id: number, opts?:
|
|
39
|
-
|
|
40
|
-
fetchPolicy?: FetchPolicy;
|
|
41
|
-
toEntity?: boolean;
|
|
42
|
-
}): Promise<Person>;
|
|
43
|
-
loadByPubkey(pubkey: string, opts?: {
|
|
44
|
-
[key: string]: any;
|
|
45
|
-
fetchPolicy?: FetchPolicy;
|
|
46
|
-
toEntity?: boolean;
|
|
47
|
-
}): Promise<Person>;
|
|
32
|
+
loadById(id: number, opts?: EntityServiceLoadOptions): Promise<Person>;
|
|
33
|
+
loadByPubkey(pubkey: string, opts?: EntityServiceLoadOptions): Promise<Person>;
|
|
48
34
|
protected asObject(source: Person | any): any;
|
|
49
35
|
static ɵfac: i0.ɵɵFactoryDeclaration<PersonService, never>;
|
|
50
36
|
static ɵprov: i0.ɵɵInjectableDeclaration<PersonService>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { Apollo, ExtraSubscriptionOptions, QueryRef } from 'apollo-angular';
|
|
3
|
-
import { ApolloCache, ApolloClient, FetchPolicy, MutationUpdaterFn, OperationVariables, TypePolicies, WatchQueryFetchPolicy } from '@apollo/client/core';
|
|
3
|
+
import { ApolloCache, ApolloClient, FetchPolicy, MutationUpdaterFn, MutationUpdaterFunction, OperationVariables, TypePolicies, WatchQueryFetchPolicy } from '@apollo/client/core';
|
|
4
4
|
import { ServiceError } from '../services/errors';
|
|
5
5
|
import { InjectionToken } from '@angular/core';
|
|
6
6
|
import { NetworkService } from '../services/network.service';
|
|
@@ -23,18 +23,18 @@ export interface WatchQueryOptions<V> {
|
|
|
23
23
|
error?: ServiceError;
|
|
24
24
|
fetchPolicy?: WatchQueryFetchPolicy;
|
|
25
25
|
}
|
|
26
|
-
export interface MutateQueryOptions<
|
|
26
|
+
export interface MutateQueryOptions<TData, TVariables = OperationVariables> extends MutationBaseOptions<TData, TVariables> {
|
|
27
27
|
mutation: any;
|
|
28
|
-
variables?:
|
|
28
|
+
variables?: TVariables;
|
|
29
29
|
error?: ServiceError;
|
|
30
30
|
context?: {
|
|
31
31
|
serializationKey?: string;
|
|
32
32
|
tracked?: boolean;
|
|
33
33
|
timeout?: number;
|
|
34
34
|
};
|
|
35
|
-
optimisticResponse?:
|
|
36
|
-
offlineResponse?:
|
|
37
|
-
update?: MutationUpdaterFn<
|
|
35
|
+
optimisticResponse?: TData;
|
|
36
|
+
offlineResponse?: TData | ((context: any) => Promise<TData>);
|
|
37
|
+
update?: MutationUpdaterFn<TData> | MutationUpdaterFunction<TData, TVariables, any, ApolloCache<TData>>;
|
|
38
38
|
forceOffline?: boolean;
|
|
39
39
|
}
|
|
40
40
|
export declare const APP_GRAPHQL_TYPE_POLICIES: InjectionToken<TypePolicies>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
import { InternalRefetchQueriesInclude, MutationUpdaterFn } from '@apollo/client/core';
|
|
2
|
+
import { ApolloCache, InternalRefetchQueriesInclude, MutationUpdaterFn, MutationUpdaterFunction } from '@apollo/client/core';
|
|
3
3
|
import { SortDirection } from '@angular/material/sort';
|
|
4
4
|
import { BaseGraphqlService } from './base-graphql-service.class';
|
|
5
5
|
import { EntitiesServiceLoadOptions, EntitiesServiceWatchOptions, EntityServiceListenChangesOptions, IEntitiesService, IEntityService, LoadResult } from '../../shared/services/entity-service.class';
|
|
@@ -44,16 +44,20 @@ export interface BaseEntityServiceOptions<T extends Entity<any, ID>, ID = number
|
|
|
44
44
|
defaultSortDirection?: SortDirection;
|
|
45
45
|
watchQueriesUpdatePolicy?: MutableWatchQueriesUpdatePolicy;
|
|
46
46
|
}
|
|
47
|
-
export interface EntitySaveOptions {
|
|
47
|
+
export interface EntitySaveOptions<T = any, V = any> {
|
|
48
48
|
refetchQueries?: ((result: FetchResult<{
|
|
49
|
-
data:
|
|
49
|
+
data: T;
|
|
50
50
|
}>) => InternalRefetchQueriesInclude) | InternalRefetchQueriesInclude;
|
|
51
51
|
awaitRefetchQueries?: boolean;
|
|
52
52
|
update?: MutationUpdaterFn<{
|
|
53
|
-
data:
|
|
54
|
-
}
|
|
53
|
+
data: T;
|
|
54
|
+
}> | MutationUpdaterFunction<{
|
|
55
|
+
data: T;
|
|
56
|
+
}, V, any, ApolloCache<{
|
|
57
|
+
data: T;
|
|
58
|
+
}>>;
|
|
55
59
|
}
|
|
56
|
-
export declare abstract class BaseEntityService<T extends Entity<T, ID>, F extends EntityFilter<F, T, ID>, ID = number, WO extends EntitiesServiceWatchOptions = EntitiesServiceWatchOptions
|
|
60
|
+
export declare abstract class BaseEntityService<T extends Entity<T, ID>, F extends EntityFilter<F, T, ID>, ID = number, WO extends EntitiesServiceWatchOptions = EntitiesServiceWatchOptions<T>, LO extends EntitiesServiceLoadOptions = EntitiesServiceLoadOptions<T>, Q extends BaseEntityGraphqlQueries = BaseEntityGraphqlQueries, M extends BaseEntityGraphqlMutations = BaseEntityGraphqlMutations, S extends BaseEntityGraphqlSubscriptions = BaseEntityGraphqlSubscriptions> extends BaseGraphqlService<T, F, ID> implements IEntitiesService<T, F, WO>, IEntityService<T, ID, LO> {
|
|
57
61
|
protected graphql: GraphqlService;
|
|
58
62
|
protected platform: PlatformService;
|
|
59
63
|
protected dataType: new () => T;
|
|
@@ -95,9 +99,9 @@ export declare abstract class BaseEntityService<T extends Entity<T, ID>, F exten
|
|
|
95
99
|
* Delete a referential entity
|
|
96
100
|
*/
|
|
97
101
|
delete(entity: T, opts?: EntitySaveOptions | any): Promise<any>;
|
|
98
|
-
listenChanges(id: ID, opts?: EntityServiceListenChangesOptions): Observable<T>;
|
|
102
|
+
listenChanges(id: ID, opts?: EntityServiceListenChangesOptions<T>): Observable<T>;
|
|
99
103
|
copyIdAndUpdateDate(source: T, target: T): void;
|
|
100
|
-
fromObject(source: any): T;
|
|
104
|
+
fromObject(source: any, toEntity?: boolean | ((source: any) => T)): T;
|
|
101
105
|
asFilter(source: any): F;
|
|
102
106
|
equals(d1: T, d2: T): boolean;
|
|
103
107
|
isNew(data: T): boolean;
|
|
@@ -112,6 +116,7 @@ export declare abstract class BaseEntityService<T extends Entity<T, ID>, F exten
|
|
|
112
116
|
isNewFn(data: T): boolean;
|
|
113
117
|
protected ngOnStart(): Promise<void>;
|
|
114
118
|
protected fillDefaultProperties(source: T): void;
|
|
119
|
+
protected fromObjects(sources: any[], toEntity?: boolean | ((source: any) => T)): T[];
|
|
115
120
|
protected asObject(source: T, opts?: EntityAsObjectOptions): any;
|
|
116
121
|
protected getRefetchQueriesForMutation(opts?: EntitySaveOptions): ((result: FetchResult<{
|
|
117
122
|
data: any;
|
|
@@ -24,44 +24,44 @@ export declare type SuggestFn<T, F> = (value: any, filter?: F, sortBy?: string |
|
|
|
24
24
|
export declare interface SuggestService<T, F> {
|
|
25
25
|
suggest: SuggestFn<T, F>;
|
|
26
26
|
}
|
|
27
|
-
export declare interface EntityServiceLoadOptions {
|
|
27
|
+
export declare interface EntityServiceLoadOptions<E = any> {
|
|
28
28
|
fetchPolicy?: FetchPolicy;
|
|
29
29
|
trash?: boolean;
|
|
30
|
-
toEntity?: boolean;
|
|
30
|
+
toEntity?: boolean | ((source: any) => E);
|
|
31
31
|
query?: any;
|
|
32
32
|
variables?: any;
|
|
33
33
|
[key: string]: any;
|
|
34
34
|
}
|
|
35
|
-
export declare interface EntityServiceWatchOptions {
|
|
35
|
+
export declare interface EntityServiceWatchOptions<T = any> {
|
|
36
36
|
fetchPolicy?: WatchQueryFetchPolicy;
|
|
37
37
|
trash?: boolean;
|
|
38
|
-
toEntity?: boolean;
|
|
38
|
+
toEntity?: boolean | ((source: any) => T);
|
|
39
39
|
query?: any;
|
|
40
40
|
variables?: any;
|
|
41
41
|
[key: string]: any;
|
|
42
42
|
}
|
|
43
|
-
export declare interface EntityServiceListenChangesOptions {
|
|
43
|
+
export declare interface EntityServiceListenChangesOptions<T = any> {
|
|
44
44
|
interval?: number;
|
|
45
45
|
fetchPolicy?: FetchPolicy;
|
|
46
|
-
toEntity?: boolean;
|
|
46
|
+
toEntity?: boolean | ((source: any) => T);
|
|
47
47
|
query?: any;
|
|
48
48
|
variables?: any;
|
|
49
49
|
[key: string]: any;
|
|
50
50
|
}
|
|
51
|
-
export declare interface IEntityService<T, ID = any, LO = EntityServiceLoadOptions
|
|
51
|
+
export declare interface IEntityService<T, ID = any, LO = EntityServiceLoadOptions<T>> {
|
|
52
52
|
load(id: ID, opts?: LO): Promise<T>;
|
|
53
53
|
canUserWrite(data: T, opts?: any): boolean;
|
|
54
54
|
save(data: T, opts?: any): Promise<T>;
|
|
55
55
|
delete(data: T, opts?: any): Promise<any>;
|
|
56
56
|
listenChanges(id: ID, opts?: any): Observable<T | undefined>;
|
|
57
57
|
}
|
|
58
|
-
export declare interface EntitiesServiceLoadOptions extends EntityServiceLoadOptions {
|
|
58
|
+
export declare interface EntitiesServiceLoadOptions<T = any> extends EntityServiceLoadOptions<T> {
|
|
59
59
|
withTotal?: boolean;
|
|
60
60
|
}
|
|
61
|
-
export declare interface EntitiesServiceWatchOptions extends EntityServiceWatchOptions {
|
|
61
|
+
export declare interface EntitiesServiceWatchOptions<T = any> extends EntityServiceWatchOptions<T> {
|
|
62
62
|
withTotal?: boolean;
|
|
63
63
|
}
|
|
64
|
-
export declare interface IEntitiesService<T, F, O extends EntitiesServiceWatchOptions = EntitiesServiceWatchOptions
|
|
64
|
+
export declare interface IEntitiesService<T, F, O extends EntitiesServiceWatchOptions = EntitiesServiceWatchOptions<T>> {
|
|
65
65
|
watchAll(offset: number, size: number, sortBy?: string, sortDirection?: SortDirection, filter?: Partial<F>, options?: O): Observable<LoadResult<T>>;
|
|
66
66
|
saveAll(data: T[], opts?: any): Promise<T[]>;
|
|
67
67
|
deleteAll(data: T[], opts?: any): Promise<any>;
|
package/src/assets/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "ngx-sumaris-components",
|
|
3
3
|
"short_name": "ngx-sumaris-components",
|
|
4
4
|
"manifest_version": 1,
|
|
5
|
-
"version": "18.1
|
|
5
|
+
"version": "18.2.1",
|
|
6
6
|
"default_locale": "fr",
|
|
7
7
|
"description": "Angular components for building beautiful and responsive Apps",
|
|
8
8
|
"icons": [{
|