@solidev/data 0.5.0 → 0.6.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/solidev-data.mjs +177 -155
- package/fesm2022/solidev-data.mjs.map +1 -1
- package/index.d.ts +2147 -3
- package/package.json +5 -5
- package/lib/auth/auth-interceptor.service.d.ts +0 -31
- package/lib/auth/auth.service.d.ts +0 -64
- package/lib/auth/jwt.d.ts +0 -22
- package/lib/data/data-backend.d.ts +0 -72
- package/lib/data/data-collection.d.ts +0 -110
- package/lib/data/data-collection.mock.d.ts +0 -19
- package/lib/data/data-model.d.ts +0 -94
- package/lib/data/data-parameters.d.ts +0 -26
- package/lib/data/data-query.d.ts +0 -104
- package/lib/data/data-query.mock.d.ts +0 -25
- package/lib/data/fields/base.d.ts +0 -120
- package/lib/data/fields/boolean.d.ts +0 -9
- package/lib/data/fields/computed.d.ts +0 -14
- package/lib/data/fields/datetime.d.ts +0 -46
- package/lib/data/fields/index.d.ts +0 -7
- package/lib/data/fields/numbers.d.ts +0 -35
- package/lib/data/fields/primaryfield.d.ts +0 -8
- package/lib/data/fields/relations.d.ts +0 -45
- package/lib/data/fields/stringfields.d.ts +0 -50
- package/lib/dispedit/choice.pipe.d.ts +0 -13
- package/lib/dispedit/dispedit/dispedit.component.d.ts +0 -182
- package/lib/dispedit/dispedit/dispedit.constants.d.ts +0 -6
- package/lib/dispedit/factor.pipe.d.ts +0 -19
- package/lib/dispedit/factorc.pipe.d.ts +0 -19
- package/lib/dispedit/fkselect/fkselect.component.d.ts +0 -42
- package/lib/dispedit/flags/flags.component.d.ts +0 -39
- package/lib/dispedit/m2mselect/m2mselect.component.d.ts +0 -116
- package/lib/dispedit/richedit/richedit.component.d.ts +0 -38
- package/lib/dispedit/sdelete/sdelete.component.d.ts +0 -49
- package/lib/messages/message-zone/message-zone.component.d.ts +0 -13
- package/lib/messages/message.service.d.ts +0 -59
- package/lib/modellist/model-list-fields/model-list-field-header/messages.d.ts +0 -6
- package/lib/modellist/model-list-fields/model-list-field-header/model-list-field-header.component.d.ts +0 -25
- package/lib/modellist/model-list-fields/model-list-fields-selector/model-list-fields-selector.component.d.ts +0 -20
- package/lib/modellist/model-list-fields/model-list-fields.d.ts +0 -68
- package/lib/modellist/model-list-filters/filters/filtertypes.d.ts +0 -1
- package/lib/modellist/model-list-filters/filters/model-list-autocomplete-filter/model-list-autocomplete-filter.component.d.ts +0 -30
- package/lib/modellist/model-list-filters/filters/model-list-autocomplete-filter/model-list-autocomplete-filter.d.ts +0 -22
- package/lib/modellist/model-list-filters/filters/model-list-autocomplete-multi-filter/model-list-autocomplete-multi-filter.component.d.ts +0 -11
- package/lib/modellist/model-list-filters/filters/model-list-autocomplete-multi-filter/model-list-autocomplete-multi-filter.d.ts +0 -8
- package/lib/modellist/model-list-filters/filters/model-list-date-filter/model-list-date-filter.component.d.ts +0 -15
- package/lib/modellist/model-list-filters/filters/model-list-date-filter/model-list-date-filter.d.ts +0 -4
- package/lib/modellist/model-list-filters/filters/model-list-datetime-filter/model-list-datetime-filter.component.d.ts +0 -15
- package/lib/modellist/model-list-filters/filters/model-list-datetime-filter/model-list-datetime-filter.d.ts +0 -4
- package/lib/modellist/model-list-filters/filters/model-list-datetimerange-filter/model-list-datetime-range-filter.component.d.ts +0 -11
- package/lib/modellist/model-list-filters/filters/model-list-datetimerange-filter/model-list-datetimerange-filter.d.ts +0 -4
- package/lib/modellist/model-list-filters/filters/model-list-flags-filter/model-list-flags-filter.component.d.ts +0 -20
- package/lib/modellist/model-list-filters/filters/model-list-flags-filter/model-list-flags-filter.d.ts +0 -17
- package/lib/modellist/model-list-filters/filters/model-list-geodistance-filter/adapters/ban.d.ts +0 -35
- package/lib/modellist/model-list-filters/filters/model-list-geodistance-filter/model-list-geodistance-filter.component.d.ts +0 -25
- package/lib/modellist/model-list-filters/filters/model-list-geodistance-filter/model-list-geodistance-filter.d.ts +0 -18
- package/lib/modellist/model-list-filters/filters/model-list-number-filter/model-list-number-filter.component.d.ts +0 -17
- package/lib/modellist/model-list-filters/filters/model-list-number-filter/model-list-number-filter.d.ts +0 -19
- package/lib/modellist/model-list-filters/filters/model-list-select-filter/model-list-select-filter.component.d.ts +0 -17
- package/lib/modellist/model-list-filters/filters/model-list-select-filter/model-list-select-filter.d.ts +0 -17
- package/lib/modellist/model-list-filters/filters/model-list-select-multi-filter/model-list-select-multi-filter.component.d.ts +0 -18
- package/lib/modellist/model-list-filters/filters/model-list-select-multi-filter/model-list-select-multi-filter.d.ts +0 -11
- package/lib/modellist/model-list-filters/filters/model-list-text-filter/model-list-text-filter.component.d.ts +0 -16
- package/lib/modellist/model-list-filters/filters/model-list-text-filter/model-list-text-filter.d.ts +0 -4
- package/lib/modellist/model-list-filters/filters/model-list-tree-filter/model-list-tree-filter.component.d.ts +0 -55
- package/lib/modellist/model-list-filters/filters/model-list-tree-filter/model-list-tree-filter.d.ts +0 -9
- package/lib/modellist/model-list-filters/model-list-filter-group.d.ts +0 -11
- package/lib/modellist/model-list-filters/model-list-filter.d.ts +0 -59
- package/lib/modellist/model-list-filters/model-list-filters/model-list-filters.component.d.ts +0 -9
- package/lib/modellist/model-list-filters/model-list-filters-select/model-list-filters-select.component.d.ts +0 -19
- package/lib/modellist/model-list-filters/model-list-filters.d.ts +0 -21
- package/lib/modellist/model-list-paginator/model-list-paginator/model-list-paginator.component.d.ts +0 -21
- package/lib/modellist/model-list-paginator/model-list-paginator.d.ts +0 -16
- package/lib/modellist/model-list-sorter/model-list-sorter/model-list-sorter.component.d.ts +0 -22
- package/lib/modellist/model-list-sorter/model-list-sorter.d.ts +0 -61
- package/lib/modellist/model-list.service.d.ts +0 -98
- package/lib/routing/breadcrumb/breadcrumb.component.d.ts +0 -41
- package/lib/routing/routing.d.ts +0 -64
- package/lib/updates/update/update.component.d.ts +0 -8
- package/lib/updates/update.service.d.ts +0 -16
- package/lib/uploader/index.d.ts +0 -5
- package/lib/uploader/interfaces.d.ts +0 -67
- package/lib/uploader/ng-file-drop.directive.d.ts +0 -22
- package/lib/uploader/ng-file-select.directive.d.ts +0 -19
- package/lib/uploader/ngx-uploader.class.d.ts +0 -35
- package/lib/uploader/ngx-uploader.module.d.ts +0 -8
- package/lib/utils/slugify.d.ts +0 -1
- package/lib/utils/tab-memory.service.d.ts +0 -30
- package/lib/utils/template.d.ts +0 -1
- package/public-api.d.ts +0 -52
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidev/data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@angular/common": "^
|
|
6
|
-
"@angular/core": "^
|
|
7
|
-
"@ng-bootstrap/ng-bootstrap": "^
|
|
5
|
+
"@angular/common": "^20",
|
|
6
|
+
"@angular/core": "^20",
|
|
7
|
+
"@ng-bootstrap/ng-bootstrap": "^19.0.0-rc.0",
|
|
8
8
|
"jwt-decode": "^4",
|
|
9
|
-
"ngx-editor": "^
|
|
9
|
+
"ngx-editor": "^19.0.0-beta.1"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"tslib": "^2.6"
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import { HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
|
3
|
-
import { AuthServiceBase } from './auth.service';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
export declare const DATA_AUTH_SERVICE: InjectionToken<AuthServiceBase<any, any, any>>;
|
|
6
|
-
/**
|
|
7
|
-
* List of urls that should be intercepted by the auth interceptor, thus receiving the auth token
|
|
8
|
-
* Default : empty list
|
|
9
|
-
*/
|
|
10
|
-
export declare const DATA_AUTH_URLS: InjectionToken<string[]>;
|
|
11
|
-
export declare class AuthInterceptor implements HttpInterceptor {
|
|
12
|
-
private _auth;
|
|
13
|
-
private _apiUrl;
|
|
14
|
-
private _urls;
|
|
15
|
-
private _isRefreshing;
|
|
16
|
-
private _refreshTokenSubject;
|
|
17
|
-
constructor(_auth: AuthServiceBase<any, any, any>, _apiUrl: string, _urls: string[] | null);
|
|
18
|
-
/**
|
|
19
|
-
* The auth token in added to the request if :
|
|
20
|
-
* - the request is not anonymous
|
|
21
|
-
* - the request is for the api url, but not for the refresh or login urls
|
|
22
|
-
* - the request is for one of the urls specified in the DATA_AUTH_URLS injection token
|
|
23
|
-
* @param req
|
|
24
|
-
* @param next
|
|
25
|
-
*/
|
|
26
|
-
intercept(req: HttpRequest<any>, next: HttpHandler): import("rxjs").Observable<import("@angular/common/http").HttpEvent<any>>;
|
|
27
|
-
private _handle401Error;
|
|
28
|
-
private _addToken;
|
|
29
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<AuthInterceptor, [null, null, { optional: true; }]>;
|
|
30
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<AuthInterceptor>;
|
|
31
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import { IJwtBaseData, IJwtRefreshResponseJson } from './jwt';
|
|
3
|
-
import { HttpClient } from '@angular/common/http';
|
|
4
|
-
import { Observable, Subject } from 'rxjs';
|
|
5
|
-
import { DataModel } from '../data/data-model';
|
|
6
|
-
import { Collection } from '../data/data-collection';
|
|
7
|
-
import { Router } from '@angular/router';
|
|
8
|
-
import { DataMessageService } from '../messages/message.service';
|
|
9
|
-
export interface AuthParams {
|
|
10
|
-
tokenUrl: string;
|
|
11
|
-
tokenRefreshUrl: string;
|
|
12
|
-
requestReactivateUrl?: string;
|
|
13
|
-
processReactivateUrl?: string;
|
|
14
|
-
requestPwResetUrl?: string;
|
|
15
|
-
processPwResetUrl?: string;
|
|
16
|
-
loginField: string;
|
|
17
|
-
passwordField: string;
|
|
18
|
-
tokenField: string;
|
|
19
|
-
loginRoute: string[];
|
|
20
|
-
logoutRoute: string[];
|
|
21
|
-
pwresetRoute?: string[];
|
|
22
|
-
reactivateRoute?: string[];
|
|
23
|
-
userFetchFields?: string[];
|
|
24
|
-
userFetchValiditySeconds?: number;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* DATA_API_URL: stores data api base url
|
|
28
|
-
*/
|
|
29
|
-
export declare const DATA_AUTH_PARAMS: InjectionToken<AuthParams>;
|
|
30
|
-
export declare const DATA_AUTH_USER_SERVICE: InjectionToken<Collection<any>>;
|
|
31
|
-
export declare class AuthServiceBase<User extends DataModel, UserService extends Collection<User>, UserData extends IJwtBaseData> {
|
|
32
|
-
userService: UserService;
|
|
33
|
-
private _params;
|
|
34
|
-
private _router;
|
|
35
|
-
private _http;
|
|
36
|
-
private _msgs;
|
|
37
|
-
logout$: Subject<void>;
|
|
38
|
-
private _user;
|
|
39
|
-
private _user$;
|
|
40
|
-
private _token;
|
|
41
|
-
private _fetched?;
|
|
42
|
-
constructor(userService: UserService, _params: AuthParams, _router: Router, _http: HttpClient, _msgs: DataMessageService);
|
|
43
|
-
get isAnonymous(): boolean;
|
|
44
|
-
get accessToken(): string | null;
|
|
45
|
-
get refreshToken(): string | null;
|
|
46
|
-
get currentUser(): User | null;
|
|
47
|
-
get currentUser$(): Observable<User | null>;
|
|
48
|
-
get refreshUrl(): string;
|
|
49
|
-
get loginUrl(): string;
|
|
50
|
-
get loginRoute(): string[];
|
|
51
|
-
get logoutRoute(): string[];
|
|
52
|
-
get pwresetRoute(): string[] | undefined;
|
|
53
|
-
get reactivateRoute(): string[] | undefined;
|
|
54
|
-
logout(): void;
|
|
55
|
-
autoLogin(): void;
|
|
56
|
-
login(username: string, password: string): Observable<'success' | 'error' | 'invalid_token' | string>;
|
|
57
|
-
requestReactivate(username: string): Observable<boolean>;
|
|
58
|
-
requestPwReset(username: string): Observable<boolean>;
|
|
59
|
-
processReactivate(username: string, token: string): Observable<boolean>;
|
|
60
|
-
processPwReset(username: string, password: string, token: string): Observable<boolean>;
|
|
61
|
-
saveAuth(): void;
|
|
62
|
-
refresh(): Observable<IJwtRefreshResponseJson | null>;
|
|
63
|
-
private _fetchUser;
|
|
64
|
-
}
|
package/lib/auth/jwt.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface IJwtResponseJson {
|
|
2
|
-
access: string;
|
|
3
|
-
refresh: string;
|
|
4
|
-
}
|
|
5
|
-
export interface IJwtRefreshResponseJson {
|
|
6
|
-
access: string;
|
|
7
|
-
}
|
|
8
|
-
export interface IJwtBaseData {
|
|
9
|
-
token_type: 'access' | 'refresh';
|
|
10
|
-
user_id: number;
|
|
11
|
-
}
|
|
12
|
-
export declare class Jwt<UserJwtData extends IJwtBaseData> {
|
|
13
|
-
readonly access?: string;
|
|
14
|
-
readonly refresh?: string;
|
|
15
|
-
private readonly _data;
|
|
16
|
-
constructor(response?: IJwtResponseJson);
|
|
17
|
-
get data(): UserJwtData | null;
|
|
18
|
-
toJson(): {
|
|
19
|
-
access: string | undefined;
|
|
20
|
-
refresh: string | undefined;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from '@angular/common/http';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { TransferState } from '@angular/core';
|
|
4
|
-
import { Collection, IActionParams } from './data-collection';
|
|
5
|
-
import { DataModel } from './data-model';
|
|
6
|
-
import * as i0 from "@angular/core";
|
|
7
|
-
/**
|
|
8
|
-
* DataBackend provides CRUD operations to a REST api.
|
|
9
|
-
* TransferState can be used if DATA_MAX_TRANSFERSTATE_TIME is set and > 0
|
|
10
|
-
*/
|
|
11
|
-
export declare class DataBackend {
|
|
12
|
-
private _http;
|
|
13
|
-
private _transferState;
|
|
14
|
-
private _platform;
|
|
15
|
-
private _apiUrl;
|
|
16
|
-
private _maxTransferstateTime;
|
|
17
|
-
private _created;
|
|
18
|
-
constructor(_http: HttpClient, _transferState: TransferState, _platform: any, _apiUrl: string, _maxTransferstateTime?: number);
|
|
19
|
-
/**
|
|
20
|
-
* Return api url for this backend.
|
|
21
|
-
*/
|
|
22
|
-
get apiUrl(): string;
|
|
23
|
-
/**
|
|
24
|
-
* Launch an action on collection.
|
|
25
|
-
* If method is GET and collection.useTranserState & transferState are enabled,
|
|
26
|
-
* result is stored / retrieved from transferState.
|
|
27
|
-
*
|
|
28
|
-
* @param collection Collection reference
|
|
29
|
-
* @param method HTTP method
|
|
30
|
-
* @param url full URL for action
|
|
31
|
-
* @param body JSON body
|
|
32
|
-
* @param params query parameters
|
|
33
|
-
* @param headers query headers
|
|
34
|
-
* @param responseType response type
|
|
35
|
-
*
|
|
36
|
-
* @return an observable of response body
|
|
37
|
-
*/
|
|
38
|
-
action<T extends DataModel, RT>(collection: Collection<T>, method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', url: string, { body, params, headers }?: IActionParams): Observable<RT>;
|
|
39
|
-
/**
|
|
40
|
-
* Launch an action on collection, receiving a blob.
|
|
41
|
-
*
|
|
42
|
-
* @param collection Collection reference
|
|
43
|
-
* @param method HTTP method
|
|
44
|
-
* @param url full URL for action
|
|
45
|
-
* @param body JSON body
|
|
46
|
-
* @param params query parameters
|
|
47
|
-
* @param headers query headers
|
|
48
|
-
* @param responseType response type
|
|
49
|
-
*
|
|
50
|
-
* @return an observable of response body
|
|
51
|
-
*/
|
|
52
|
-
blob<T extends DataModel>(collection: Collection<T>, method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', url: string, { body, params, headers }?: IActionParams): Observable<Blob>;
|
|
53
|
-
put<T extends DataModel>(collection: Collection<T>, url: string, { body, params, headers }?: IActionParams): Observable<T>;
|
|
54
|
-
post<T extends DataModel>(collection: Collection<T>, url: string, { body, params, headers }?: IActionParams): Observable<Partial<T>>;
|
|
55
|
-
patch<T extends DataModel>(collection: Collection<T>, url: string, { body, params, headers }?: IActionParams): Observable<Partial<T>>;
|
|
56
|
-
delete<T extends DataModel, R>(collection: Collection<T>, url: string, { params, headers }?: IActionParams): Observable<R>;
|
|
57
|
-
_cachedGet<T extends DataModel, RT>(collection: Collection<T>, url: string, { params, headers }?: IActionParams): Observable<RT>;
|
|
58
|
-
get<T extends DataModel>(collection: Collection<T>, url: string, { params, headers }?: IActionParams): Observable<Partial<T>>;
|
|
59
|
-
list<T extends DataModel>(collection: Collection<T>, url: string, { params, headers }?: IActionParams): Observable<any>;
|
|
60
|
-
/**
|
|
61
|
-
* Return headers for this backend.
|
|
62
|
-
* Provided headers are copied and returned.
|
|
63
|
-
* Can be overriden by subclasses for specific headers (e.g. auth token).
|
|
64
|
-
*/
|
|
65
|
-
protected headers(headers: {
|
|
66
|
-
[key: string]: string;
|
|
67
|
-
}): {
|
|
68
|
-
[key: string]: string;
|
|
69
|
-
};
|
|
70
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<DataBackend, [null, null, null, null, { optional: true; }]>;
|
|
71
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<DataBackend>;
|
|
72
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { DataModel } from './data-model';
|
|
2
|
-
import { DataBackend } from './data-backend';
|
|
3
|
-
import { Observable } from 'rxjs';
|
|
4
|
-
import { FilterData, IQuerysetOptions, Queryset } from './data-query';
|
|
5
|
-
export type IHttpMethod = 'POST' | 'GET' | 'DELETE' | 'PUT' | 'PATCH';
|
|
6
|
-
export interface IActionParams {
|
|
7
|
-
body?: any;
|
|
8
|
-
headers?: {
|
|
9
|
-
[index: string]: string;
|
|
10
|
-
};
|
|
11
|
-
params?: {
|
|
12
|
-
[index: string]: string;
|
|
13
|
-
};
|
|
14
|
-
responseType?: 'json' | 'blob';
|
|
15
|
-
}
|
|
16
|
-
export interface ICollectionCacheParams {
|
|
17
|
-
transferState?: {
|
|
18
|
-
enabled: boolean;
|
|
19
|
-
maxTime: number;
|
|
20
|
-
maxCount: number;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export type DataModelType<T extends DataModel> = new (_coll?: Collection<T>) => T;
|
|
24
|
-
export declare class Collection<T extends DataModel> {
|
|
25
|
-
protected backend: DataBackend;
|
|
26
|
-
protected path: string;
|
|
27
|
-
model: DataModelType<T>;
|
|
28
|
-
useTransferState: boolean;
|
|
29
|
-
constructor(backend: DataBackend, path: string, model: DataModelType<T>);
|
|
30
|
-
create(data?: Partial<T>): T;
|
|
31
|
-
fromJson(data: Partial<T>): T;
|
|
32
|
-
fromJson(data: Partial<T>[]): T[];
|
|
33
|
-
queryset(options?: IQuerysetOptions): Queryset<T>;
|
|
34
|
-
fetch(id: number, { prefix, suffix, params, headers, }?: {
|
|
35
|
-
prefix?: string;
|
|
36
|
-
suffix?: string;
|
|
37
|
-
params?: {
|
|
38
|
-
[_index: string]: string;
|
|
39
|
-
};
|
|
40
|
-
headers?: {
|
|
41
|
-
[_index: string]: string;
|
|
42
|
-
};
|
|
43
|
-
}): Observable<T>;
|
|
44
|
-
action<RT>(model: T | null, method: IHttpMethod, action: string, { body, params, headers }?: IActionParams): Observable<RT>;
|
|
45
|
-
save(model: T, { updateModel }?: {
|
|
46
|
-
updateModel?: boolean;
|
|
47
|
-
}): Observable<T>;
|
|
48
|
-
update(model: T, fields?: string[], { updateModel }?: {
|
|
49
|
-
updateModel?: boolean;
|
|
50
|
-
}): Observable<T>;
|
|
51
|
-
delete(model: T, { params, headers }?: IActionParams): Observable<any>;
|
|
52
|
-
list(query?: FilterData, { prefix, suffix, params, headers, }?: {
|
|
53
|
-
prefix?: string;
|
|
54
|
-
suffix?: string;
|
|
55
|
-
params?: {
|
|
56
|
-
[_index: string]: string;
|
|
57
|
-
};
|
|
58
|
-
headers?: {
|
|
59
|
-
[_index: string]: string;
|
|
60
|
-
};
|
|
61
|
-
}): Observable<T[]>;
|
|
62
|
-
/**
|
|
63
|
-
* Calls *method* endpoint for this collection and returns raw results.
|
|
64
|
-
*
|
|
65
|
-
* @param method GET/POST/...
|
|
66
|
-
* @param prefix collection_urlPREFIXSUFFIX
|
|
67
|
-
* @param suffix collection_urlPREFIXSUFFIX
|
|
68
|
-
* @param params query paremeters
|
|
69
|
-
* @param body body as json
|
|
70
|
-
* @param headers headers
|
|
71
|
-
*/
|
|
72
|
-
raw<RT>({ method, prefix, suffix, params, body, headers, }?: {
|
|
73
|
-
method?: IHttpMethod;
|
|
74
|
-
prefix?: string;
|
|
75
|
-
suffix?: string;
|
|
76
|
-
body?: any;
|
|
77
|
-
params?: {
|
|
78
|
-
[_index: string]: string;
|
|
79
|
-
};
|
|
80
|
-
headers?: {
|
|
81
|
-
[_index: string]: string;
|
|
82
|
-
};
|
|
83
|
-
}): Observable<RT>;
|
|
84
|
-
/**
|
|
85
|
-
* Calls *method* endpoint for this collection and returns raw results.
|
|
86
|
-
*
|
|
87
|
-
* @param method GET/POST/...
|
|
88
|
-
* @param prefix collection_urlPREFIXSUFFIX
|
|
89
|
-
* @param suffix collection_urlPREFIXSUFFIX
|
|
90
|
-
* @param params query paremeters
|
|
91
|
-
* @param body body as json
|
|
92
|
-
* @param headers headers
|
|
93
|
-
*/
|
|
94
|
-
blob<RT>({ method, prefix, suffix, params, body, headers, }?: {
|
|
95
|
-
method?: IHttpMethod;
|
|
96
|
-
prefix?: string;
|
|
97
|
-
suffix?: string;
|
|
98
|
-
body?: any;
|
|
99
|
-
params?: {
|
|
100
|
-
[_index: string]: string;
|
|
101
|
-
};
|
|
102
|
-
headers?: {
|
|
103
|
-
[_index: string]: string;
|
|
104
|
-
};
|
|
105
|
-
}): Observable<Blob>;
|
|
106
|
-
getUrl(id?: number | null, { prefix, suffix }?: {
|
|
107
|
-
prefix?: string;
|
|
108
|
-
suffix?: string;
|
|
109
|
-
}): string;
|
|
110
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { DataModel } from "./data-model";
|
|
2
|
-
import { Observable } from "rxjs";
|
|
3
|
-
import { IQuerysetOptions } from "./data-query";
|
|
4
|
-
import { QuerysetMock } from "./data-query.mock";
|
|
5
|
-
import { Collection, IActionParams, IHttpMethod } from "./data-collection";
|
|
6
|
-
export declare class CollectionMock<T extends DataModel> {
|
|
7
|
-
protected model: new (coll: Collection<T>) => T;
|
|
8
|
-
mockValue?: T;
|
|
9
|
-
mockValues?: T[];
|
|
10
|
-
actionValue: any;
|
|
11
|
-
constructor(model: new (coll: Collection<T>) => T);
|
|
12
|
-
fetch(id: number, suffix?: string): Observable<T>;
|
|
13
|
-
action(model: T | null, method: IHttpMethod, action: string, params: IActionParams): Observable<any>;
|
|
14
|
-
queryset(options?: IQuerysetOptions): QuerysetMock<T>;
|
|
15
|
-
list(query?: {
|
|
16
|
-
[index: string]: string;
|
|
17
|
-
}, suffix?: string): Observable<any>;
|
|
18
|
-
fromJson(data: any, many?: boolean): T | any;
|
|
19
|
-
}
|
package/lib/data/data-model.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { BaseFieldManager, IFieldStoredMetadata } from './fields/base';
|
|
2
|
-
import { FormControl, FormGroup, ValidationErrors } from '@angular/forms';
|
|
3
|
-
import { Collection } from './data-collection';
|
|
4
|
-
import { Observable } from 'rxjs';
|
|
5
|
-
export type DataModelFields = Readonly<Map<string, IFieldStoredMetadata<any>>>;
|
|
6
|
-
/**
|
|
7
|
-
* Base class for data model.
|
|
8
|
-
*
|
|
9
|
-
* Each class must have a static __name
|
|
10
|
-
* primary field is given with id field.
|
|
11
|
-
*
|
|
12
|
-
* Some methods are provided to be used with a collection, mostly for CRUD operations.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
export declare class DataModel {
|
|
16
|
-
protected _coll?: Collection<any> | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* data model name
|
|
19
|
-
* this need to be given because class name is not fully available because of minification.
|
|
20
|
-
*/
|
|
21
|
-
protected static readonly __name: string;
|
|
22
|
-
/**
|
|
23
|
-
* Primary field; readonly; must be created and auto incremented on db side.
|
|
24
|
-
*/
|
|
25
|
-
id: number;
|
|
26
|
-
private readonly _F;
|
|
27
|
-
/**
|
|
28
|
-
* Constructor for data model instance.
|
|
29
|
-
* A matching collection can be provided.
|
|
30
|
-
* ___fields readonly property is also populated from Reflected metadata
|
|
31
|
-
*
|
|
32
|
-
* @param _coll collection used for CRUD, etc..
|
|
33
|
-
*/
|
|
34
|
-
constructor(_coll?: Collection<any> | undefined);
|
|
35
|
-
get _collection(): Collection<any>;
|
|
36
|
-
set _collection(coll: Collection<any>);
|
|
37
|
-
/**
|
|
38
|
-
* HashMap of fields metadata (type, name, manager, etc...)
|
|
39
|
-
*/
|
|
40
|
-
get F(): DataModelFields;
|
|
41
|
-
get FN(): IterableIterator<string>;
|
|
42
|
-
/**
|
|
43
|
-
* Loads model data from json.
|
|
44
|
-
* If partial is true, only fields with matching data keys will be loaded
|
|
45
|
-
* @param data
|
|
46
|
-
* @param options
|
|
47
|
-
*/
|
|
48
|
-
fromJson(data: {
|
|
49
|
-
[index: string]: any;
|
|
50
|
-
}, { partial, check }?: {
|
|
51
|
-
partial?: boolean;
|
|
52
|
-
check?: boolean;
|
|
53
|
-
}): null | ValidationErrors;
|
|
54
|
-
toJson(fields?: string | string[]): any;
|
|
55
|
-
action<T, RT extends {
|
|
56
|
-
[index: string]: any;
|
|
57
|
-
}>(method: 'POST' | 'PATCH' | 'GET' | 'DELETE' | 'PUT', name: string, { body, update, updatePartial, updateCheck, params, headers, }?: {
|
|
58
|
-
body?: {
|
|
59
|
-
[_index: string]: any;
|
|
60
|
-
};
|
|
61
|
-
update?: boolean;
|
|
62
|
-
updatePartial?: boolean;
|
|
63
|
-
updateCheck?: boolean;
|
|
64
|
-
params?: {
|
|
65
|
-
[_index: string]: string;
|
|
66
|
-
};
|
|
67
|
-
headers?: {
|
|
68
|
-
[_index: string]: string;
|
|
69
|
-
};
|
|
70
|
-
}): Observable<RT>;
|
|
71
|
-
FM<FT>(field: string): BaseFieldManager<FT>;
|
|
72
|
-
FV<FT>(field: string): FT;
|
|
73
|
-
/**
|
|
74
|
-
* Set field value. If check is true, only set value if all validators pass.
|
|
75
|
-
* Skip setting field value if manager computed flag is true.
|
|
76
|
-
*
|
|
77
|
-
* The validation result is returned.
|
|
78
|
-
*
|
|
79
|
-
* @param field field name
|
|
80
|
-
* @param value field valued
|
|
81
|
-
* @param check default false
|
|
82
|
-
* @return null or ValidationError
|
|
83
|
-
*/
|
|
84
|
-
setFV<FT>(field: string, value: FT, check?: boolean): null | ValidationErrors;
|
|
85
|
-
FC(): FormGroup;
|
|
86
|
-
FC(field: string): FormControl;
|
|
87
|
-
FC(field: string[]): FormGroup;
|
|
88
|
-
save({ updateModel }?: {
|
|
89
|
-
updateModel?: boolean;
|
|
90
|
-
}): Observable<this>;
|
|
91
|
-
update(fields?: string[], { updateModel }?: {
|
|
92
|
-
updateModel?: boolean;
|
|
93
|
-
}): Observable<this>;
|
|
94
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from "@angular/core";
|
|
2
|
-
/**
|
|
3
|
-
* DATA_API_URL: stores data api base url
|
|
4
|
-
*/
|
|
5
|
-
export declare const DATA_API_URL: InjectionToken<string>;
|
|
6
|
-
/**
|
|
7
|
-
* DATA_MAX_TRANSFERSTATE_TIME: max duration to use transferstate time
|
|
8
|
-
* If DATA_MAX_TRANSFERSTATE_TIME is zero, TransferState is not used
|
|
9
|
-
*/
|
|
10
|
-
export declare const DATA_MAX_TRANSFERSTATE_TIME: InjectionToken<number>;
|
|
11
|
-
/**
|
|
12
|
-
* DataDisplayConfig interface provides default values for display classes
|
|
13
|
-
*/
|
|
14
|
-
export interface DataDisplayConfig {
|
|
15
|
-
dispEdit: {
|
|
16
|
-
defaultMode: "inline" | "dd";
|
|
17
|
-
inputClasses: {
|
|
18
|
-
[index: string]: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export declare const BootstrapDataDisplayConfig: DataDisplayConfig;
|
|
23
|
-
/**
|
|
24
|
-
* DATA_DISPLAY_CONFIG: display config & default classes injection token
|
|
25
|
-
*/
|
|
26
|
-
export declare const DATA_DISPLAY_CONFIG: InjectionToken<DataDisplayConfig>;
|
package/lib/data/data-query.d.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { Collection } from './data-collection';
|
|
2
|
-
import { DataModel } from './data-model';
|
|
3
|
-
import { Observable } from 'rxjs';
|
|
4
|
-
import { ActivatedRoute, Router } from '@angular/router';
|
|
5
|
-
export interface FilterData {
|
|
6
|
-
[index: string]: string | number | boolean | undefined | null;
|
|
7
|
-
}
|
|
8
|
-
export interface OutFilterData {
|
|
9
|
-
[index: string]: string;
|
|
10
|
-
}
|
|
11
|
-
export type SortData = string;
|
|
12
|
-
/**
|
|
13
|
-
* Queryset parameters
|
|
14
|
-
*/
|
|
15
|
-
export interface IQuerysetOptions {
|
|
16
|
-
/** Emit fields list */
|
|
17
|
-
emitFields?: boolean;
|
|
18
|
-
/** Queryset name */
|
|
19
|
-
name?: string;
|
|
20
|
-
/** TODO: see usage */
|
|
21
|
-
route?: ActivatedRoute;
|
|
22
|
-
/** TODO: see usage */
|
|
23
|
-
router?: Router;
|
|
24
|
-
/** TODO: see usage */
|
|
25
|
-
hash?: string;
|
|
26
|
-
}
|
|
27
|
-
export interface IQueryNav {
|
|
28
|
-
page: number;
|
|
29
|
-
page_size: number;
|
|
30
|
-
}
|
|
31
|
-
export interface IQueryMetaNav {
|
|
32
|
-
count: number;
|
|
33
|
-
next: number | null;
|
|
34
|
-
page: number;
|
|
35
|
-
pages: number;
|
|
36
|
-
prev: number | null;
|
|
37
|
-
size: number;
|
|
38
|
-
}
|
|
39
|
-
export interface IQueryMetaNavParams {
|
|
40
|
-
page: string;
|
|
41
|
-
page_size: string;
|
|
42
|
-
}
|
|
43
|
-
export interface IQueryMeta {
|
|
44
|
-
nav: IQueryMetaNav;
|
|
45
|
-
parameters: IQueryMetaNavParams;
|
|
46
|
-
}
|
|
47
|
-
export interface IQueryFullResponse<T> extends IQueryMeta {
|
|
48
|
-
results: T[];
|
|
49
|
-
}
|
|
50
|
-
export declare class Queryset<T extends DataModel> {
|
|
51
|
-
protected _coll: Collection<T>;
|
|
52
|
-
/** Current filter data */
|
|
53
|
-
filterData: FilterData;
|
|
54
|
-
/** Current sorter data */
|
|
55
|
-
sortData: SortData[];
|
|
56
|
-
/** Current fields */
|
|
57
|
-
fields: string[];
|
|
58
|
-
/** Current page size */
|
|
59
|
-
pageSize: number;
|
|
60
|
-
/** Current page number */
|
|
61
|
-
page: number;
|
|
62
|
-
options: IQuerysetOptions;
|
|
63
|
-
private _loading;
|
|
64
|
-
/** Loading status (true if currently fetching data) */
|
|
65
|
-
loading: Observable<boolean>;
|
|
66
|
-
private _meta;
|
|
67
|
-
/** Results meta part observable */
|
|
68
|
-
meta: Observable<IQueryMeta>;
|
|
69
|
-
private _results;
|
|
70
|
-
/** Results data part observable */
|
|
71
|
-
results: Observable<T[]>;
|
|
72
|
-
private _full;
|
|
73
|
-
/** Full results observable (results, loading, meta) */
|
|
74
|
-
full: Observable<[T[], boolean, IQueryMeta]>;
|
|
75
|
-
constructor(_coll: Collection<T>, options?: IQuerysetOptions);
|
|
76
|
-
private _pristine;
|
|
77
|
-
/** Pristine status (true if it has not collected results yet) */
|
|
78
|
-
get pristine(): boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Update current filter data. Null or undefined values are removed from filter data.
|
|
81
|
-
* @param params filter data
|
|
82
|
-
* @param update boolean to update filter data instead of recreating it from scratch
|
|
83
|
-
*/
|
|
84
|
-
filter(params?: FilterData, update?: boolean): Queryset<T>;
|
|
85
|
-
/**
|
|
86
|
-
* Update sorting parameters, list of strings giving sort parameters e.g. sort("+name", "-id").
|
|
87
|
-
* @param sorting strings of sort parameters
|
|
88
|
-
*/
|
|
89
|
-
sort(...sorting: string[]): Queryset<T>;
|
|
90
|
-
/**
|
|
91
|
-
* Update page size.
|
|
92
|
-
* @param pageSize required page size
|
|
93
|
-
*/
|
|
94
|
-
paginateBy(pageSize?: number): Queryset<T>;
|
|
95
|
-
/**
|
|
96
|
-
* Update current page number.
|
|
97
|
-
* @param page required pqge
|
|
98
|
-
* @param fragment TODO: fragment usage for router usage
|
|
99
|
-
*/
|
|
100
|
-
setPage(page?: number, fragment?: string): Queryset<T>;
|
|
101
|
-
setFields(fields: string[]): Queryset<T>;
|
|
102
|
-
getQueryParams(): OutFilterData;
|
|
103
|
-
get(refresh?: boolean, sync?: boolean): Observable<T[]>;
|
|
104
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DataModel } from "./data-model";
|
|
2
|
-
import { CollectionMock } from "./data-collection.mock";
|
|
3
|
-
import { FilterData, IQueryMeta, IQuerysetOptions, SortData } from "./data-query";
|
|
4
|
-
import { Observable } from "rxjs";
|
|
5
|
-
export declare class QuerysetMock<T extends DataModel> {
|
|
6
|
-
protected _coll: CollectionMock<T>;
|
|
7
|
-
options: IQuerysetOptions;
|
|
8
|
-
mockData: T[];
|
|
9
|
-
filterData: FilterData;
|
|
10
|
-
sortData: SortData[];
|
|
11
|
-
pageSize: number;
|
|
12
|
-
page: number;
|
|
13
|
-
pristine: boolean;
|
|
14
|
-
loading: Observable<boolean>;
|
|
15
|
-
constructor(_coll: CollectionMock<T>, options?: IQuerysetOptions);
|
|
16
|
-
get results(): Observable<T[]>;
|
|
17
|
-
get meta(): Observable<IQueryMeta>;
|
|
18
|
-
get full(): Observable<[T[], boolean, IQueryMeta]>;
|
|
19
|
-
filter(params?: FilterData): QuerysetMock<T>;
|
|
20
|
-
sort(...sorting: string[]): QuerysetMock<T>;
|
|
21
|
-
paginateBy(pageSize?: number): QuerysetMock<T>;
|
|
22
|
-
setPage(page: number): QuerysetMock<T>;
|
|
23
|
-
getQueryParams(): FilterData;
|
|
24
|
-
get(): Observable<T[]>;
|
|
25
|
-
}
|