@stemy/ngx-utils 19.5.25 → 19.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.
@@ -1,6 +1,7 @@
1
1
  import { ElementRef, EventEmitter, InjectionToken, Injector, NgZone, Provider, TemplateRef, Type } from "@angular/core";
2
- import { HttpClient, HttpErrorResponse, HttpHeaders } from "@angular/common/http";
2
+ import { HttpClient, HttpHeaders } from "@angular/common/http";
3
3
  import { ActivatedRouteSnapshot, Data, LoadChildrenCallback, Route, Routes, UrlTree } from "@angular/router";
4
+ import { Observable } from "rxjs";
4
5
  import { DurationLikeObject } from "luxon";
5
6
  import { StringKeys } from "./helper-types";
6
7
  export type DurationUnit = StringKeys<DurationLikeObject>;
@@ -66,9 +67,14 @@ export interface ILanguageService {
66
67
  getTranslationFromObject(translations: ITranslations, params?: any, lang?: string): string;
67
68
  getTranslationFromArray(translations: ITranslation[], params?: any, lang?: string): string;
68
69
  }
70
+ export interface IUserData {
71
+ _id?: string;
72
+ id?: string;
73
+ email?: string;
74
+ [key: string]: any;
75
+ }
69
76
  export interface IAuthService {
70
77
  isAuthenticated: boolean;
71
- userChanged: EventEmitter<any>;
72
78
  checkAuthenticated(): Promise<boolean>;
73
79
  }
74
80
  export type RouteValidator = (auth: IAuthService, route?: IRoute, next?: ActivatedRouteSnapshot) => Promise<boolean>;
@@ -338,24 +344,50 @@ export interface InteractiveCanvasPointer {
338
344
  clientX: number;
339
345
  clientY: number;
340
346
  }
341
- export interface IHttpHeaders {
347
+ export interface HttpRequestHeaders {
342
348
  [header: string]: string | string[];
343
349
  }
344
- export interface IHttpParams {
350
+ export interface HttpRequestQuery {
345
351
  [key: string]: any;
346
352
  }
347
- export interface IRequestOptions {
353
+ /**
354
+ * Base http request options that get sent to backend
355
+ */
356
+ export interface HttpClientRequestOptions {
348
357
  method?: string;
349
358
  body?: any;
350
- headers?: IHttpHeaders | HttpHeaders;
351
- originalHeaders?: IHttpHeaders;
352
- params?: IHttpParams;
359
+ headers?: HttpRequestHeaders | HttpHeaders;
360
+ originalHeaders?: HttpRequestHeaders;
361
+ params?: HttpRequestQuery;
353
362
  observe?: "body" | "response";
363
+ /**
364
+ * Used for uploads
365
+ */
354
366
  reportProgress?: boolean;
367
+ /**
368
+ * Specifies the type of response
369
+ */
355
370
  responseType?: "arraybuffer" | "blob" | "json" | "text";
356
371
  withCredentials?: boolean;
357
372
  timeout?: number;
358
373
  }
374
+ /**
375
+ * Extended http request options that the consumer can use
376
+ */
377
+ export interface HttpRequestOptions extends HttpClientRequestOptions {
378
+ /**
379
+ * Read a specific property from the body if observe equals to 'body' and responseType equals to 'json'
380
+ */
381
+ read?: string;
382
+ /**
383
+ * Specifies when the cache for the request expires as an Observable
384
+ */
385
+ cache?: Observable<any>;
386
+ }
387
+ /**
388
+ * Defines the type of uploadable content
389
+ */
390
+ export type UploadData = Record<string, any> | ArrayBuffer | FormData;
359
391
  export interface IIssueContext {
360
392
  url: string;
361
393
  }
@@ -365,58 +397,55 @@ export interface IProgress {
365
397
  total?: number;
366
398
  }
367
399
  export type ProgressListener = (progress: IProgress) => void;
368
- export type PromiseExecutor = (resolve: (value?: any | PromiseLike<any>) => void, reject: (reason?: any) => void) => void;
369
- export declare class HttpPromise extends Promise<any> {
370
- protected rejectHandler: (reason?: HttpErrorResponse) => void;
371
- protected hasRejectHandler: boolean;
372
- protected attachCount: number;
373
- protected runCount: number;
374
- constructor(rejectHandler: (reason?: HttpErrorResponse) => void, executor: PromiseExecutor);
375
- then<TResult1, TResult2>(onFulfilled?: ((value: any) => (PromiseLike<TResult1> | TResult1)) | null | undefined, onRejected?: ((reason: HttpErrorResponse) => (PromiseLike<TResult2> | TResult2)) | null | undefined): Promise<TResult1 | TResult2>;
376
- catch<TResult = never>(onRejected?: ((reason: HttpErrorResponse) => (PromiseLike<TResult> | TResult)) | null | undefined): Promise<any | TResult>;
377
- }
400
+ export type CacheExpireMode = boolean | "auth" | Date;
378
401
  export interface IHttpService {
379
402
  language: ILanguageService;
403
+ cached(mode: CacheExpireMode): Observable<any>;
380
404
  url(url: string): string;
381
- makeListParams(page: number, itemsPerPage: number, orderBy?: string, orderDescending?: boolean, filter?: string): IHttpParams;
405
+ makeListParams(page: number, itemsPerPage: number, orderBy?: string, orderDescending?: boolean, filter?: string): HttpRequestQuery;
382
406
  }
383
407
  export interface IBaseHttpClient extends HttpClient {
384
- readonly requestHeaders: IHttpHeaders;
385
- readonly requestParams: IHttpParams;
408
+ readonly requestHeaders: HttpRequestHeaders;
409
+ readonly requestParams: HttpRequestQuery;
386
410
  }
387
411
  export interface IApiService extends IHttpService {
388
- cache: any;
389
412
  client: IBaseHttpClient;
390
- get(url: string, options?: IRequestOptions): Promise<any>;
391
- delete(url: string, options?: IRequestOptions): Promise<any>;
392
- post(url: string, body?: any, options?: IRequestOptions): Promise<any>;
393
- put(url: string, body?: any, options?: IRequestOptions): Promise<any>;
394
- patch(url: string, body?: any, options?: IRequestOptions): Promise<any>;
395
- upload(url: string, body: any, listener?: ProgressListener, options?: IRequestOptions): Promise<any>;
396
- list(url: string, params: IHttpParams, options?: IRequestOptions): Promise<IPaginationData>;
397
- }
398
- export interface IOpenApiSchemaProperty {
413
+ get(url: string, options?: HttpRequestOptions): Promise<any>;
414
+ delete(url: string, options?: HttpRequestOptions): Promise<any>;
415
+ post(url: string, body?: any, options?: HttpRequestOptions): Promise<any>;
416
+ put(url: string, body?: any, options?: HttpRequestOptions): Promise<any>;
417
+ patch(url: string, body?: any, options?: HttpRequestOptions): Promise<any>;
418
+ upload(url: string, body: any, listener?: ProgressListener, options?: HttpRequestOptions): Promise<any>;
419
+ list(url: string, params: HttpRequestQuery, options?: HttpRequestOptions): Promise<IPaginationData>;
420
+ }
421
+ export interface DynamicSchemaRef {
422
+ dynamicSchema?: string;
423
+ dynamicSchemaUrl?: string;
424
+ dynamicSchemaName?: string;
425
+ }
426
+ export interface OpenApiSchemaRef {
427
+ $ref?: string;
428
+ }
429
+ export interface OpenApiSchemaProperty extends DynamicSchemaRef, OpenApiSchemaRef {
399
430
  id: string;
400
431
  type?: string;
401
432
  format?: string;
402
433
  column?: boolean;
403
434
  additionalProperties?: any;
404
- $ref?: string;
405
- allOf?: ReadonlyArray<{
406
- $ref?: string;
407
- }>;
408
- items?: IOpenApiSchemaProperty;
435
+ allOf?: ReadonlyArray<OpenApiSchemaRef>;
436
+ oneOf?: ReadonlyArray<OpenApiSchemaRef>;
437
+ items?: OpenApiSchemaProperty;
409
438
  enum?: string[];
410
439
  [key: string]: any;
411
440
  }
412
- export interface IOpenApiSchema {
441
+ export interface OpenApiSchema {
413
442
  properties: {
414
- [name: string]: IOpenApiSchemaProperty;
443
+ [name: string]: OpenApiSchemaProperty;
415
444
  };
416
445
  required: string[];
417
446
  }
418
- export interface IOpenApiSchemas {
419
- [name: string]: IOpenApiSchema;
447
+ export interface OpenApiSchemas {
448
+ [name: string]: OpenApiSchema;
420
449
  }
421
450
  export type TableFilterType = "text" | "enum" | "checkbox";
422
451
  export interface ITableOrders {
@@ -21,6 +21,7 @@ import { StateService } from "./services/state.service";
21
21
  import { StaticLanguageService } from "./services/static-language.service";
22
22
  import { StorageService } from "./services/storage.service";
23
23
  import { BaseToasterService } from "./services/base-toaster.service";
24
+ import { CacheService } from "./services/cache.service";
24
25
  import { ComponentLoaderService } from "./services/component-loader.service";
25
26
  import { TranslatedUrlSerializer } from "./services/translated-url.serializer";
26
27
  import { UniversalService } from "./services/universal.service";
@@ -67,7 +68,7 @@ import { UploadComponent } from "./components/upload/upload.component";
67
68
  export declare const pipes: (typeof FilterPipe | typeof FormatNumberPipe | typeof GlobalTemplatePipe | typeof IncludesPipe | typeof ReducePipe | typeof RoundPipe | typeof SafeHtmlPipe | typeof TranslatePipe)[];
68
69
  export declare const directives: (typeof AsyncMethodBase | typeof AsyncMethodTargetDirective | typeof BackgroundDirective | typeof ComponentLoaderDirective | typeof DynamicTableTemplateDirective | typeof GlobalTemplateDirective | typeof IconDirective | typeof NgxTemplateOutletDirective | typeof PaginationDirective | typeof PaginationItemDirective | typeof ResourceIfDirective | typeof StickyDirective | typeof StickyClassDirective | typeof DropdownDirective | typeof DropdownContentDirective | typeof TabsItemDirective | typeof UnorderedListItemDirective | typeof UnorderedListTemplateDirective)[];
69
70
  export declare const components: (typeof ChipsComponent | typeof DropListComponent | typeof DynamicTableComponent | typeof FakeModuleComponent | typeof InteractiveCanvasComponent | typeof InteractiveCircleComponent | typeof InteractiveRectComponent | typeof PaginationMenuComponent | typeof UnorderedListComponent | typeof UploadComponent)[];
70
- export declare const providers: (typeof UniversalService | typeof StateService | typeof AuthGuard | typeof BaseHttpClient | typeof StorageService | typeof BaseHttpService | typeof WasmService | typeof AclService | typeof StaticAuthService | typeof ConfigService | typeof BaseDialogService | typeof ErrorHandlerService | typeof EventsService | typeof FormatterService | typeof GlobalTemplateService | typeof IconService | typeof StaticLanguageService | typeof OpenApiService | typeof BaseToasterService | typeof ComponentLoaderService | typeof TranslatedUrlSerializer | typeof PromiseService | typeof SocketService | typeof FilterPipe | typeof FormatNumberPipe | typeof GlobalTemplatePipe | typeof IncludesPipe | typeof ReducePipe | typeof RoundPipe | typeof SafeHtmlPipe | typeof TranslatePipe | typeof DeviceDetectorService | {
71
+ export declare const providers: (typeof CacheService | typeof UniversalService | typeof StateService | typeof AuthGuard | typeof BaseHttpClient | typeof StorageService | typeof EventsService | typeof BaseHttpService | typeof WasmService | typeof AclService | typeof StaticAuthService | typeof ConfigService | typeof BaseDialogService | typeof ErrorHandlerService | typeof FormatterService | typeof GlobalTemplateService | typeof IconService | typeof StaticLanguageService | typeof OpenApiService | typeof BaseToasterService | typeof ComponentLoaderService | typeof TranslatedUrlSerializer | typeof PromiseService | typeof SocketService | typeof FilterPipe | typeof FormatNumberPipe | typeof GlobalTemplatePipe | typeof IncludesPipe | typeof ReducePipe | typeof RoundPipe | typeof SafeHtmlPipe | typeof TranslatePipe | typeof DeviceDetectorService | {
71
72
  provide: import("@angular/core").InjectionToken<import("@angular/platform-browser").EventManagerPlugin[]>;
72
73
  useClass: typeof DragDropEventPlugin;
73
74
  multi: boolean;
@@ -1,13 +1,14 @@
1
1
  import { Injector } from "@angular/core";
2
2
  import { StateService } from "./state.service";
3
- import { IAuthService, IRouteStateInfo } from "../common-types";
3
+ import { IRouteStateInfo } from "../common-types";
4
+ import { EventsService } from "./events.service";
4
5
  import * as i0 from "@angular/core";
5
6
  export declare class AclService {
6
7
  readonly injector: Injector;
7
8
  readonly state: StateService;
8
- readonly auth: IAuthService;
9
+ readonly events: EventsService;
9
10
  protected components: IRouteStateInfo[];
10
- constructor(injector: Injector, state: StateService, auth: IAuthService);
11
+ constructor(injector: Injector, state: StateService, events: EventsService);
11
12
  protected getStateInfo(): IRouteStateInfo;
12
13
  static ɵfac: i0.ɵɵFactoryDeclaration<AclService, never>;
13
14
  static ɵprov: i0.ɵɵInjectableDeclaration<AclService>;
@@ -1,17 +1,16 @@
1
- import { IApiService, IHttpParams, IRequestOptions, ProgressListener } from "../common-types";
1
+ import { HttpRequestOptions, HttpRequestQuery, IApiService, IPaginationData, ProgressListener, UploadData } from "../common-types";
2
2
  import { BaseHttpService } from "./base-http.service";
3
- import { IPaginationData } from "../common-types";
4
3
  import * as i0 from "@angular/core";
5
4
  export declare class ApiService extends BaseHttpService implements IApiService {
6
5
  get name(): string;
7
6
  url(url: string): string;
8
- get(url: string, options?: IRequestOptions, body?: any): Promise<any>;
9
- delete(url: string, options?: IRequestOptions, body?: any): Promise<any>;
10
- post(url: string, body?: any, options?: IRequestOptions): Promise<any>;
11
- put(url: string, body?: any, options?: IRequestOptions): Promise<any>;
12
- patch(url: string, body?: any, options?: IRequestOptions): Promise<any>;
13
- upload(url: string, body: any, listener?: ProgressListener, options?: IRequestOptions): Promise<any>;
14
- list(url: string, params: IHttpParams, options?: IRequestOptions): Promise<IPaginationData>;
7
+ get(url: string, options?: HttpRequestOptions, body?: any): Promise<any>;
8
+ delete(url: string, options?: HttpRequestOptions, body?: any): Promise<any>;
9
+ post(url: string, body?: any, options?: HttpRequestOptions): Promise<any>;
10
+ put(url: string, body?: any, options?: HttpRequestOptions): Promise<any>;
11
+ patch(url: string, body?: any, options?: HttpRequestOptions): Promise<any>;
12
+ upload(url: string, body: UploadData, listener?: ProgressListener, options?: HttpRequestOptions): Promise<any>;
13
+ list(url: string, params: HttpRequestQuery, options?: HttpRequestOptions): Promise<IPaginationData>;
15
14
  static ɵfac: i0.ɵɵFactoryDeclaration<ApiService, never>;
16
15
  static ɵprov: i0.ɵɵInjectableDeclaration<ApiService>;
17
16
  }
@@ -1,8 +1,6 @@
1
- import { EventEmitter } from "@angular/core";
2
1
  import { IRoute, IAuthService } from "../common-types";
3
2
  export declare class StaticAuthService implements IAuthService {
4
3
  isAuthenticated: boolean;
5
- userChanged: EventEmitter<any>;
6
4
  checkAuthenticated(): Promise<boolean>;
7
5
  getReturnState(route: IRoute): string[];
8
6
  }
@@ -1,14 +1,14 @@
1
1
  import { HttpClient, HttpHandler, HttpHeaders, HttpParams } from "@angular/common/http";
2
- import { IHttpHeaders, IHttpParams } from "../common-types";
2
+ import { HttpRequestHeaders, HttpRequestQuery } from "../common-types";
3
3
  import * as i0 from "@angular/core";
4
4
  export declare class BaseHttpClient extends HttpClient {
5
- requestHeaders: IHttpHeaders;
6
- requestParams: IHttpParams;
5
+ requestHeaders: HttpRequestHeaders;
6
+ requestParams: HttpRequestQuery;
7
7
  renewTokenFunc: () => void;
8
- protected extraRequestParams: IHttpParams;
8
+ protected extraRequestParams: HttpRequestQuery;
9
9
  constructor(handler: HttpHandler);
10
- makeHeaders(headers?: IHttpHeaders, withCredentials?: boolean): HttpHeaders;
11
- makeParams(params?: IHttpParams): HttpParams;
10
+ makeHeaders(headers?: HttpRequestHeaders, withCredentials?: boolean): HttpHeaders;
11
+ makeParams(params?: HttpRequestQuery): HttpParams;
12
12
  setExtraRequestParam(name: string, value?: any): void;
13
13
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseHttpClient, never>;
14
14
  static ɵprov: i0.ɵɵInjectableDeclaration<BaseHttpClient>;
@@ -1,15 +1,18 @@
1
1
  import { Injector } from "@angular/core";
2
2
  import { HttpHeaders, HttpParams } from "@angular/common/http";
3
3
  import { Request } from "express";
4
- import { HttpPromise, IConfigService, IHttpHeaders, IHttpParams, IHttpService, IIssueContext, ILanguageService, IPaginationData, IRequestOptions, IToasterService, ProgressListener } from "../common-types";
4
+ import { CacheExpireMode, IConfigService, HttpRequestHeaders, HttpRequestQuery, IHttpService, IIssueContext, ILanguageService, IPaginationData, HttpClientRequestOptions, IToasterService, ProgressListener, HttpRequestOptions, UploadData } from "../common-types";
5
5
  import { BaseHttpClient } from "./base-http.client";
6
6
  import { UniversalService } from "./universal.service";
7
7
  import { StorageService } from "./storage.service";
8
+ import { Observable } from "rxjs";
9
+ import { CacheService } from "./cache.service";
8
10
  import * as i0 from "@angular/core";
9
11
  export declare class BaseHttpService implements IHttpService {
10
12
  readonly injector: Injector;
11
13
  readonly client: BaseHttpClient;
12
14
  readonly storage: StorageService;
15
+ readonly caches: CacheService;
13
16
  readonly language: ILanguageService;
14
17
  readonly toaster: IToasterService;
15
18
  readonly configs: IConfigService;
@@ -17,37 +20,37 @@ export declare class BaseHttpService implements IHttpService {
17
20
  protected static failedRequests: Array<() => void>;
18
21
  get name(): string;
19
22
  protected get withCredentials(): boolean;
20
- requestHeaders: IHttpHeaders;
21
- requestParams: IHttpParams;
22
- cache: any;
23
+ requestHeaders: HttpRequestHeaders;
24
+ requestParams: HttpRequestQuery;
23
25
  protected static retryFailedRequests(): void;
24
26
  get universal(): UniversalService;
25
- constructor(injector: Injector, client: BaseHttpClient, storage: StorageService, language: ILanguageService, toaster: IToasterService, configs: IConfigService, request?: Request);
27
+ constructor(injector: Injector, client: BaseHttpClient, storage: StorageService, caches: CacheService, language: ILanguageService, toaster: IToasterService, configs: IConfigService, request?: Request);
26
28
  protected initService(): void;
29
+ cached(mode: CacheExpireMode): Observable<any>;
27
30
  url(url: string): string;
28
- createUrl(url: string, params: IHttpParams): string;
29
- makeListParams(page: number, itemsPerPage: number, orderBy?: string, orderDescending?: boolean, filter?: string): IHttpParams;
30
- protected getPromise(url: string, options?: IRequestOptions, body?: any): HttpPromise;
31
- protected deletePromise(url: string, options?: IRequestOptions, body?: any): HttpPromise;
32
- protected postPromise(url: string, body?: any, options?: IRequestOptions): HttpPromise;
33
- protected putPromise(url: string, body?: any, options?: IRequestOptions): HttpPromise;
34
- protected patchPromise(url: string, body?: any, options?: IRequestOptions): HttpPromise;
35
- protected uploadPromise(url: string, body: any, listener?: ProgressListener, options?: IRequestOptions): HttpPromise;
36
- protected listPromise(url: string, options?: IRequestOptions): Promise<IPaginationData>;
37
- protected handleUnauthorizedError(absoluteUrl: string, options: IRequestOptions, reject: () => void): void;
38
- protected toastWarning(message: string, issueContext: IIssueContext, reason: any, options: IRequestOptions): void;
39
- protected toastError(message: string, issueContext: IIssueContext, reason: any, options: IRequestOptions): void;
40
- protected toPromise(url: string, options: IRequestOptions, listener?: ProgressListener): HttpPromise;
31
+ createUrl(url: string, params: HttpRequestQuery): string;
32
+ makeListParams(page: number, itemsPerPage: number, orderBy?: string, orderDescending?: boolean, filter?: string): HttpRequestQuery;
33
+ protected getPromise(url: string, options?: HttpRequestOptions, body?: any): Promise<any>;
34
+ protected deletePromise(url: string, options?: HttpRequestOptions, body?: any): Promise<any>;
35
+ protected postPromise(url: string, body?: any, options?: HttpRequestOptions): Promise<any>;
36
+ protected putPromise(url: string, body?: any, options?: HttpRequestOptions): Promise<any>;
37
+ protected patchPromise(url: string, body?: any, options?: HttpRequestOptions): Promise<any>;
38
+ protected uploadPromise(url: string, body: UploadData, listener?: ProgressListener, options?: HttpRequestOptions): Promise<any>;
39
+ protected listPromise(url: string, options?: HttpClientRequestOptions): Promise<IPaginationData>;
40
+ protected handleUnauthorizedError(absoluteUrl: string, options: HttpClientRequestOptions, reject: () => void): void;
41
+ protected toastWarning(message: string, issueContext: IIssueContext, reason: any, options: HttpClientRequestOptions): void;
42
+ protected toastError(message: string, issueContext: IIssueContext, reason: any, options: HttpClientRequestOptions): void;
43
+ protected toPromise(url: string, requestOptions: HttpRequestOptions, listener?: ProgressListener): Promise<any>;
41
44
  protected getUserTokenTime(): number;
42
- protected pushFailedRequest(url: string, options: IRequestOptions, req: () => void): boolean;
45
+ protected pushFailedRequest(url: string, options: HttpClientRequestOptions, req: () => void): boolean;
43
46
  protected checkHeaders(headers: any): boolean;
44
- protected makeOptions(options?: IRequestOptions, method?: string, body?: any): IRequestOptions;
45
- protected makeHeaders(options: IRequestOptions): HttpHeaders;
46
- protected makeParams(options: IRequestOptions): HttpParams;
47
- protected parseResponse(response: any, url: string, options: IRequestOptions): any;
47
+ protected makeOptions(options?: HttpRequestOptions, method?: string, body?: any, cache?: Observable<any>): HttpClientRequestOptions;
48
+ protected makeHeaders(options: HttpClientRequestOptions): HttpHeaders;
49
+ protected makeParams(options: HttpClientRequestOptions): HttpParams;
50
+ protected parseResponse(response: any, url: string, options: HttpClientRequestOptions, read: string): any;
48
51
  protected parseUrl(url: string): string;
49
- protected absoluteUrl(url: string, options: IRequestOptions): Promise<string>;
52
+ protected absoluteUrl(url: string, options: HttpClientRequestOptions): string;
50
53
  protected expressRequestUrl(url: string): string;
51
- static ɵfac: i0.ɵɵFactoryDeclaration<BaseHttpService, [null, null, null, null, null, null, { optional: true; }]>;
54
+ static ɵfac: i0.ɵɵFactoryDeclaration<BaseHttpService, [null, null, null, null, null, null, null, { optional: true; }]>;
52
55
  static ɵprov: i0.ɵɵInjectableDeclaration<BaseHttpService>;
53
56
  }
@@ -0,0 +1,17 @@
1
+ import { Observable } from "rxjs";
2
+ import { DurationUnit } from "../common-types";
3
+ import { EventsService } from "./events.service";
4
+ import * as i0 from "@angular/core";
5
+ export declare class CacheService {
6
+ protected events: EventsService;
7
+ get userChanged(): Observable<any>;
8
+ readonly ignore: Observable<any>;
9
+ readonly permanent: Observable<any>;
10
+ private caches;
11
+ constructor(events: EventsService);
12
+ expiresIn(amount?: number, unit?: DurationUnit): Observable<any>;
13
+ expiresAt(when: Date): Observable<any>;
14
+ use<T>(key: string, valueCb: () => T, expires?: Observable<any>): T;
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<CacheService, never>;
16
+ static ɵprov: i0.ɵɵInjectableDeclaration<CacheService>;
17
+ }
@@ -1,12 +1,15 @@
1
- import { EventEmitter } from "@angular/core";
1
+ import { Subject } from "rxjs";
2
2
  import * as i0 from "@angular/core";
3
3
  export declare class EventsService {
4
- readonly eventForwarded: EventEmitter<Event>;
5
- readonly stickyUpdated: EventEmitter<boolean>;
6
- readonly languageChanged: EventEmitter<string>;
7
- readonly translationsEnabled: EventEmitter<boolean>;
4
+ readonly eventForwarded: Subject<Event>;
5
+ readonly stickyUpdated: Subject<boolean>;
6
+ readonly languageChanged: Subject<string>;
7
+ readonly translationsEnabled: Subject<boolean>;
8
+ readonly userChanged: Subject<any>;
8
9
  private sticky;
10
+ private user;
9
11
  get isSticky(): boolean;
12
+ get isAuthenticated(): boolean;
10
13
  constructor();
11
14
  event(e: Event): void;
12
15
  updateSticky(sticky: boolean): void;
@@ -1,13 +1,14 @@
1
- import { IRequestOptions } from "../common-types";
1
+ import { HttpClientRequestOptions, IConfiguration } from "../common-types";
2
2
  import { BaseHttpService } from "./base-http.service";
3
3
  import * as i0 from "@angular/core";
4
4
  export declare class LocalHttpService extends BaseHttpService {
5
5
  private images;
6
6
  get name(): string;
7
+ get config(): IConfiguration;
7
8
  protected get withCredentials(): boolean;
8
9
  protected initService(): void;
9
10
  url(url: string): string;
10
- get(url: string, options?: IRequestOptions): Promise<any>;
11
+ get(url: string, options?: HttpClientRequestOptions, body?: any): Promise<any>;
11
12
  getImage(url: string): Promise<HTMLImageElement>;
12
13
  static ɵfac: i0.ɵɵFactoryDeclaration<LocalHttpService, never>;
13
14
  static ɵprov: i0.ɵɵInjectableDeclaration<LocalHttpService>;
@@ -1,11 +1,17 @@
1
- import { IApiService, IOpenApiSchema, IOpenApiSchemas } from "../common-types";
1
+ import { DynamicSchemaRef, IApiService, OpenApiSchema, OpenApiSchemaProperty, OpenApiSchemas } from "../common-types";
2
2
  import * as i0 from "@angular/core";
3
3
  export declare class OpenApiService {
4
4
  readonly api: IApiService;
5
- private schemasPromise;
5
+ private apiDocs;
6
+ private schemas;
7
+ private readonly dynamicSchemas;
6
8
  constructor(api: IApiService);
7
- getSchemas(): Promise<IOpenApiSchemas>;
8
- getSchema(name: string): Promise<IOpenApiSchema>;
9
+ isDynamicSchema(value: any): value is Required<DynamicSchemaRef>;
10
+ getSchemas(): Promise<OpenApiSchemas>;
11
+ getReferences(property: OpenApiSchemaProperty, schema: OpenApiSchema): Promise<OpenApiSchema[]>;
12
+ getSchema(name: string): Promise<OpenApiSchema>;
13
+ protected getDynamicSchema(definition: DynamicSchemaRef): Promise<OpenApiSchema>;
14
+ protected extractSchemas(res: any): OpenApiSchemas;
9
15
  static ɵfac: i0.ɵɵFactoryDeclaration<OpenApiService, never>;
10
16
  static ɵprov: i0.ɵɵInjectableDeclaration<OpenApiService>;
11
17
  }
@@ -1,17 +1,18 @@
1
1
  import { OnDestroy } from "@angular/core";
2
2
  import { BehaviorSubject, Subscription } from "rxjs";
3
- import { IApiService, IAuthService } from "../common-types";
3
+ import { IApiService } from "../common-types";
4
4
  import { ExtraHeaders, SocketClient, SocketData, SocketDataObj } from "../utils/socket-client";
5
+ import { EventsService } from "./events.service";
5
6
  import * as i0 from "@angular/core";
6
7
  export declare class SocketService implements OnDestroy {
7
- readonly auth: IAuthService;
8
8
  readonly api: IApiService;
9
9
  protected ioPath: string;
10
+ protected events: EventsService;
10
11
  protected client: SocketClient;
11
- protected authSub: Subscription;
12
+ protected userSub: Subscription;
12
13
  get status(): BehaviorSubject<boolean>;
13
14
  get id(): string;
14
- constructor(auth: IAuthService, api: IApiService, ioPath: string);
15
+ constructor(api: IApiService, ioPath: string, events: EventsService);
15
16
  withAuth(extraHeaders?: ExtraHeaders): void;
16
17
  ngOnDestroy(): void;
17
18
  connect(extraHeaders?: ExtraHeaders): void;
@@ -1,6 +1,12 @@
1
1
  import { Type, ValueProvider, ɵComponentDef as ComponentDef } from "@angular/core";
2
2
  import { CssSelector, CssSelectorList } from "../common-types";
3
3
  export declare function isBrowser(): boolean;
4
+ /**
5
+ * Returns a hash code from anything
6
+ * @param {string} obj The object to hash.
7
+ * @return {number} A 32bit integer
8
+ */
9
+ export declare function hashCode(obj: any): number;
4
10
  export declare function switchClass(elem: HTMLElement, className: string, status?: boolean): void;
5
11
  export declare function getCssVariables(elem: HTMLElement): Record<string, string>;
6
12
  export declare function checkTransitions(el: HTMLElement, cb: () => any): void;
@@ -1,3 +1,4 @@
1
+ import { MaybeArray } from "../helper-types";
1
2
  export type FilterPredicate = (value: any, key?: any, target?: any, source?: any) => boolean;
2
3
  export type IterateCallback = (value: any, key: any) => void;
3
4
  export type IterateRecursiveCallback = (value: any, key: any, path: string, obj: any) => void;
@@ -22,12 +23,13 @@ export declare class ObjectUtils {
22
23
  static isDefined(value: any): boolean;
23
24
  static isNullOrUndefined(value: any): boolean;
24
25
  static isString(value: any): value is string;
26
+ static isStringWithValue(value: any): value is string;
25
27
  static isFunction(value: any): value is Function;
26
28
  static isDate(value: any): value is Date;
27
29
  static isBlob(value: any): value is Blob;
28
30
  static isBoolean(value: any): value is boolean;
29
31
  static isNumber(value: any): value is number;
30
- static isArray(value: any): value is Array<any>;
32
+ static isArray<T, U>(value: MaybeArray<T> | ReadonlyArray<T> | U): value is T[];
31
33
  static isSet(value: any): value is Set<any>;
32
34
  static isConstructor(value: any): boolean;
33
35
  static checkInterface(obj: any, interFaceObject: any): boolean;
@@ -7,10 +7,3 @@ export declare class StringUtils {
7
7
  static isObjectId(id: string): boolean;
8
8
  static parseDomain(baseUrl: string): string;
9
9
  }
10
- /**
11
- * Returns a hash code from a string
12
- * @param {String} str The string to hash.
13
- * @return {Number} A 32bit integer
14
- * @see http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
15
- */
16
- export declare function hashCode(str: string): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stemy/ngx-utils",
3
- "version": "19.5.25",
3
+ "version": "19.6.0",
4
4
  "license": "MIT",
5
5
  "public": true,
6
6
  "repository": "https://github.com/stemyke/ngx-utils.git",
package/public_api.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import "zone.js";
2
2
  export { MaybePromise, MaybeArray, KeysOfType, ObjOfType, StringKeys, CapitalizeFirst, CamelJoin, PrefixedPick } from "./ngx-utils/helper-types";
3
- export { DurationUnit, TypedFactoryProvider, TypedValueProvider, CachedProvider, CachedFactory, IResolveFactory, CanvasColor, IIconService, ITranslation, ITranslations, ILanguageSetting, ILanguageSettings, ILanguageService, IAuthService, RouteValidator, IRouteData, IRoute, IAclComponent, IDialogButtonConfig, IDialogConfig, IConfirmDialogConfig, IDialogService, IPromiseService, IWasi, IWasmExports, IWasm, IWasmAsync, IRouteStateInfo, NavigationUrlParam, StorageMode, ToastType, IToasterService, IAsyncMessage, AsyncMethod, IconMap, IconProps, ButtonType, ButtonSize, ButtonProps, TabValue, TabOption, ChipValue, ChipStatus, ChipOption, DropdownAttachTo, UnorderedListTemplate, UnorderedListTemplates, UnorderedListStyle, UploadType, IFileUploadResult, IFileUploadProcess, IAjaxRequestDetails, AjaxRequestCallback, ScriptType, ILoadableElement, ILoaderPromises, ISearchObservable, FactoryDependencies, ObjectType, ITimer, IExtraProperties, IGroupMap, TranslationQuery, IPageInfo, IPaginationData, PaginationDataLoader, PaginationItemContext, IPoint, IShape, CanvasItemShape, CanvasItemDirection, InteractiveCanvas, InteractiveCanvasItem, InteractiveDrawFn, InteractivePanEvent, InteractiveCanvasPointer, IHttpHeaders, IHttpParams, IRequestOptions, IIssueContext, IProgress, ProgressListener, PromiseExecutor, HttpPromise, IHttpService, IApiService, IOpenApiSchemaProperty, IOpenApiSchema, IOpenApiSchemas, TableFilterType, ITableOrders, ITableColumn, ITableColumns, TableColumns, ITableTemplate, ITableTemplates, ITableDataQuery, TableDataLoader, DragDropEvent, DragEventHandler, ITableDragEvent, DynamicTableDragHandler, ResourceIfContext, CssSelector, CssSelectorList, DynamicComponentLocation, DynamicModuleInfo, DynamicEntryComponents, IConfiguration, IConfigService, ResizeEventStrategy, ErrorHandlerCallback, GlobalComponentModifier, AppInitializerFunc, IModuleConfig, ValuedPromise } from "./ngx-utils/common-types";
3
+ export { DurationUnit, TypedFactoryProvider, TypedValueProvider, CachedProvider, CachedFactory, IResolveFactory, CanvasColor, IIconService, ITranslation, ITranslations, ILanguageSetting, ILanguageSettings, ILanguageService, IUserData, IAuthService, RouteValidator, IRouteData, IRoute, IAclComponent, IDialogButtonConfig, IDialogConfig, IConfirmDialogConfig, IDialogService, IPromiseService, IWasi, IWasmExports, IWasm, IWasmAsync, IRouteStateInfo, NavigationUrlParam, StorageMode, ToastType, IToasterService, IAsyncMessage, AsyncMethod, IconMap, IconProps, ButtonType, ButtonSize, ButtonProps, TabValue, TabOption, ChipValue, ChipStatus, ChipOption, DropdownAttachTo, UnorderedListTemplate, UnorderedListTemplates, UnorderedListStyle, UploadType, IFileUploadResult, IFileUploadProcess, IAjaxRequestDetails, AjaxRequestCallback, ScriptType, ILoadableElement, ILoaderPromises, ISearchObservable, FactoryDependencies, ObjectType, ITimer, IExtraProperties, IGroupMap, TranslationQuery, IPageInfo, IPaginationData, PaginationDataLoader, PaginationItemContext, IPoint, IShape, CanvasItemShape, CanvasItemDirection, InteractiveCanvas, InteractiveCanvasItem, InteractiveDrawFn, InteractivePanEvent, InteractiveCanvasPointer, HttpRequestHeaders, HttpRequestQuery, HttpClientRequestOptions, HttpRequestOptions, UploadData, IIssueContext, IProgress, ProgressListener, CacheExpireMode, IHttpService, IApiService, DynamicSchemaRef, OpenApiSchemaProperty, OpenApiSchema, OpenApiSchemas, TableFilterType, ITableOrders, ITableColumn, ITableColumns, TableColumns, ITableTemplate, ITableTemplates, ITableDataQuery, TableDataLoader, DragDropEvent, DragEventHandler, ITableDragEvent, DynamicTableDragHandler, ResourceIfContext, CssSelector, CssSelectorList, DynamicComponentLocation, DynamicModuleInfo, DynamicEntryComponents, IConfiguration, IConfigService, ResizeEventStrategy, ErrorHandlerCallback, GlobalComponentModifier, AppInitializerFunc, IModuleConfig, ValuedPromise } from "./ngx-utils/common-types";
4
4
  export { ICON_TYPE, ICON_MAP, BUTTON_TYPE, ERROR_HANDLER, RESIZE_STRATEGY, RESIZE_DELAY, ROOT_ELEMENT, SCRIPT_PARAMS, BASE_CONFIG, CONFIG_SERVICE, APP_BASE_URL, API_SERVICE, EXPRESS_REQUEST, WASI_IMPLEMENTATION, PROMISE_SERVICE, DIALOG_SERVICE, TOASTER_SERVICE, AUTH_SERVICE, LANGUAGE_SERVICE, ICON_SERVICE, OPTIONS_TOKEN } from "./ngx-utils/tokens";
5
5
  export { AjaxRequestHandler } from "./ngx-utils/utils/ajax-request-handler";
6
6
  export { ArrayUtils } from "./ngx-utils/utils/array.utils";
@@ -18,11 +18,11 @@ export { JSONfn } from "./ngx-utils/utils/jsonfn";
18
18
  export { ReflectUtils } from "./ngx-utils/utils/reflect.utils";
19
19
  export { LoaderUtils } from "./ngx-utils/utils/loader.utils";
20
20
  export { MathUtils } from "./ngx-utils/utils/math.utils";
21
- export { isBrowser, switchClass, getCssVariables, checkTransitions, getComponentDef, parseSelector, selectorMatchesList, provideEntryComponents } from "./ngx-utils/utils/misc";
21
+ export { isBrowser, hashCode, switchClass, getCssVariables, checkTransitions, getComponentDef, parseSelector, selectorMatchesList, provideEntryComponents } from "./ngx-utils/utils/misc";
22
22
  export { ObjectUtils } from "./ngx-utils/utils/object.utils";
23
23
  export { ObservableUtils, ISubscriberInfo } from "./ngx-utils/utils/observable.utils";
24
24
  export { CancelablePromise, cancelablePromise, impatientPromise } from "./ngx-utils/utils/promise.utils";
25
- export { StringUtils, hashCode } from "./ngx-utils/utils/string.utils";
25
+ export { StringUtils } from "./ngx-utils/utils/string.utils";
26
26
  export { SetUtils } from "./ngx-utils/utils/set.utils";
27
27
  export { computedPrevious, cssStyles, cssVariables } from "./ngx-utils/utils/signal-utils";
28
28
  export { SocketFactory, SocketData, SocketDataValue, SocketDataObj, SocketClient } from "./ngx-utils/utils/socket-client";
@@ -51,6 +51,7 @@ export { IStateInfo, StateService } from "./ngx-utils/services/state.service";
51
51
  export { StaticLanguageService } from "./ngx-utils/services/static-language.service";
52
52
  export { StorageService } from "./ngx-utils/services/storage.service";
53
53
  export { BaseToasterService } from "./ngx-utils/services/base-toaster.service";
54
+ export { CacheService } from "./ngx-utils/services/cache.service";
54
55
  export { ComponentLoaderService } from "./ngx-utils/services/component-loader.service";
55
56
  export { IUrlDictionary, TranslatedUrlSerializer } from "./ngx-utils/services/translated-url.serializer";
56
57
  export { PromiseService } from "./ngx-utils/services/promise.service";