UNPKG

wacom

Version:

Module which has common services and components which can be used on all projects.

1,282 lines (1,250 loc) 78.8 kB
import * as i0 from '@angular/core'; import { Signal, Type, InjectionToken, AfterViewInit, ElementRef, WritableSignal, OnInit, PipeTransform, ComponentRef, EnvironmentProviders, ModuleWithProviders } from '@angular/core'; import { Router, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import * as _angular_platform_browser from '@angular/platform-browser'; import { Meta, Title } from '@angular/platform-browser'; import { Observable } from 'rxjs'; import { HttpErrorResponse, HttpClient } from '@angular/common/http'; import * as i1 from '@angular/common'; import { DatePipe } from '@angular/common'; import * as i2 from '@angular/forms'; /** * Possible alert variants that control styling and default icons. */ declare const ALERT_TYPES: string[]; type AlertType = (typeof ALERT_TYPES)[number]; /** * Possible screen positions where alerts can be placed. */ declare const ALERT_POSITIONS: string[]; type AlertPosition = (typeof ALERT_POSITIONS)[number]; /** * Configuration for a button rendered inside an alert. */ interface AlertButton { /** Text displayed on the button. */ text: string; /** Optional click handler invoked when the button is pressed. */ callback?: () => void; } /** * Base options that can be supplied when showing an alert. */ interface AlertConfig { /** Message text displayed to the user. */ text?: string; /** One of {@link ALERT_TYPES} determining alert style. */ type?: AlertType; /** Location on screen where the alert should appear. */ position?: AlertPosition; /** Optional action buttons displayed within the alert. */ buttons?: AlertButton[]; /** Optional icon name to show with the message. */ icon?: string; /** Custom CSS class applied to the alert container. */ class?: string; /** Identifier used to ensure only one alert with this key exists. */ unique?: string; /** Whether to show a progress bar. */ progress?: boolean; /** Milliseconds before auto dismissal. */ timeout?: number; /** Callback executed when the alert is closed. */ close?: () => void; closable?: boolean; } interface Alert extends AlertConfig { /** Unique identifier for the alert instance. */ id?: number; /** Reactive signal tracking progress bar value. */ progressPercentage?: Signal<number>; /** Handler executed when the alert closes. */ onClose?: () => void; /** Component rendered inside the alert body. */ component?: Type<unknown>; [x: string]: unknown; } /** * Default values applied when an alert is shown without specific options. */ declare const DEFAULT_ALERT_CONFIG: Alert; type HttpHeaderType = string | number | (string | number)[]; /** * Configuration values used by the HTTP service when * issuing requests to a backend API. */ interface HttpConfig { /** Map of default headers appended to each request. */ headers?: Record<string, HttpHeaderType>; /** Base URL for all HTTP requests. */ url?: string; } /** * Configuration for a button rendered inside an Loader. */ interface LoaderButton { /** Text displayed on the button. */ text: string; /** Optional click handler invoked when the button is pressed. */ callback?: () => void; } /** * Base options that can be supplied when showing an Loader. */ interface LoaderConfig { /** Message text displayed to the user. */ text?: string; /** Optional action buttons displayed within the Loader. */ buttons?: LoaderButton[]; /** Custom CSS class applied to the Loader container. */ class?: string; /** Identifier used to ensure only one Loader with this key exists. */ unique?: string; /** Whether to show a progress bar. */ progress?: boolean; /** Milliseconds before auto dismissal. */ timeout?: number; /** Callback executed when the Loader is closed. */ close?: () => void; closable?: boolean; } interface Loader extends LoaderConfig { /** Unique identifier for the loader instance. */ id?: number; /** Signal emitting the current progress percentage. */ progressPercentage?: Signal<number>; /** Called when the loader is dismissed. */ onClose?: () => void; /** Element to which the loader should be appended. */ append?: HTMLElement; /** Component used to render custom loader content. */ component?: Type<unknown>; [x: string]: unknown; } /** * Default metadata values applied to every route. */ interface MetaDefaults { /** Base document title. */ title?: string; /** Suffix appended to titles when {@link MetaConfig.useTitleSuffix} is true. */ titleSuffix?: string; /** Map of link tags (e.g. canonical URLs). */ links?: Record<string, string>; [key: string]: string | Record<string, string> | undefined; } /** * Options controlling the behavior of the meta service. */ interface MetaConfig { /** Whether to append the configured titleSuffix to page titles. */ useTitleSuffix?: boolean; /** Emit console warnings when routes are missing a guard. */ warnMissingGuard?: boolean; /** Default metadata applied to all routes. */ defaults?: MetaDefaults; } declare const MODAL_SIZES: string[]; type ModalSizes = (typeof MODAL_SIZES)[number]; /** * Configuration for a button rendered inside an modal. */ interface ModalButton { /** Text displayed on the button. */ text: string; /** Optional click handler invoked when the button is pressed. */ callback?: () => void; } interface ModalConfig { /** Size of the modal window. */ size?: ModalSizes; /** Optional action buttons displayed within the Modal. */ buttons?: ModalButton[]; /** Custom CSS class applied to the Modal container. */ class?: string; /** Identifier used to ensure only one Modal with this key exists. */ unique?: string; /** Whether to show a progress bar. */ progress?: boolean; /** Milliseconds before auto dismissal. */ timeout?: number; /** Callback executed when the Modal is closed. */ close?: () => void; /** Allow closing the modal via UI controls. */ closable?: boolean; } interface Modal extends ModalConfig { /** Component used to render the modal content. */ component: Type<unknown>; /** Unique identifier for the modal instance. */ id?: number; /** Signal emitting the current progress percentage. */ progressPercentage?: Signal<number>; /** Handler called when the user clicks outside the modal. */ onClickOutside?: () => void; /** Callback executed when the modal closes. */ onClose?: () => void; /** Callback executed when the modal opens. */ onOpen?: () => void; [x: string]: unknown; } declare const DEFAULT_MODAL_CONFIG: ModalConfig; /** * Configuration for the storage abstraction used by the library. */ interface StoreConfig { /** Key prefix applied to all stored values. */ prefix?: string; /** Persist a value under the given field name. */ set?: (field: string, value: string | number, cb?: () => void, errCb?: (err: unknown) => void) => Promise<boolean>; /** Retrieve a value by field name. */ get?: (field: string, cb?: (value: string) => void, errCb?: (err: unknown) => void) => Promise<string>; /** Remove a stored value. */ remove?: (field: string, cb?: () => void, errCb?: (err: unknown) => void) => Promise<boolean>; /** Clear all stored values created by the library. */ clear?: (cb?: () => void, errCb?: (err: unknown) => void) => Promise<boolean>; } /** * Root configuration object used to initialize the library. * Each property allows consumers to override the default * behavior of the corresponding service. */ interface Config { /** Options for the key‑value storage service. */ store?: StoreConfig; /** Defaults applied to page metadata handling. */ meta?: MetaConfig; /** Global settings for the alert service. */ alert?: AlertConfig; /** Default options for loader overlays. */ loader?: LoaderConfig; /** Configuration for modal dialogs. */ modal?: ModalConfig; /** Base HTTP settings such as API URL and headers. */ http?: HttpConfig; /** Optional socket connection configuration. */ socket?: any; /** Raw Socket.IO client instance, if used. */ io?: any; theme?: { primary: string; secondary: string; info: string; error: string; success: string; warning: string; question: string; }; } declare const CONFIG_TOKEN: InjectionToken<Config>; declare const DEFAULT_CONFIG: Config; /** * Basic fields expected on a document managed by the CRUD service. */ interface CrudDocument { /** Unique identifier of the document. */ _id: string; /** Optional application identifier to which the document belongs. */ appId?: string; /** Numerical position used for manual ordering. */ order?: number; /** Flag indicating the document was freshly created client‑side. */ __created?: boolean; /** Flag set when the document has been modified locally. */ __modified?: boolean; } /** * Options that can be supplied to CRUD operations. */ interface CrudOptions<Document> { /** Logical name of the collection or resource. */ name?: string; /** Message to display when the operation completes. */ alert?: string; /** Callback invoked with the server response. */ callback?: (resp: Document | Document[]) => void; /** Callback invoked if the request fails. */ errCallback?: (resp: unknown) => void; } /** * Contract implemented by services performing CRUD requests. */ interface CrudServiceInterface<Document> { /** Retrieve a page of documents from the server. */ get: (params: { page: number; }, options: CrudOptions<Document>) => any; /** Return the current in‑memory documents. */ getDocs: () => Document[]; /** Create a new document. */ create: (doc: Document) => any; /** Update an existing document. */ update: (doc: Document) => any; /** Delete the provided document. */ delete: (doc: Document) => any; /** Change the number of documents retrieved per page. */ setPerPage?: (count: number) => void; /** Resolves when the initial data load has completed. */ loaded: Promise<unknown>; } /** * Configuration describing how a CRUD table should behave. */ interface TableConfig<Document> { /** Callback to paginate to a given page. */ paginate?: (page?: number) => void; /** Number of documents shown per page. */ perPage?: number; /** Function used to update the page size. */ setPerPage?: ((count: number) => void) | undefined; /** When true, fetch all documents instead of paginating. */ allDocs?: boolean; /** Handler invoked to create a new record. */ create: (() => void) | null; /** Handler invoked to edit a record. */ update: ((doc: Document) => void) | null; /** Handler invoked to delete a record. */ delete: ((doc: Document) => void) | null; /** Row‑level action buttons. */ buttons: ({ icon?: string; click?: (doc: Document) => void; hrefFunc?: (doc: Document) => string; } | null)[]; /** Buttons displayed in the table header. */ headerButtons: ({ icon?: string; click?: () => void; hrefFunc?: (doc: Document) => string; class?: string; } | null)[]; } declare class MetaService { private config; private router; private meta; private titleService; private _meta; constructor(config: Config, router: Router, meta: Meta, titleService: Title); /** * Sets the default meta tags. * * @param defaults - The default meta tags. */ setDefaults(defaults: MetaDefaults): void; /** * Sets the title and optional title suffix. * * @param title - The title to set. * @param titleSuffix - The title suffix to append. * @returns The MetaService instance. */ setTitle(title?: string, titleSuffix?: string): MetaService; /** * Sets link tags. * * @param links - The links to set. * @returns The MetaService instance. */ setLink(links: { [key: string]: string; }): MetaService; /** * Sets a meta tag. * * @param tag - The meta tag name. * @param value - The meta tag value. * @param prop - The meta tag property. */ setTag(tag: string, value: string, prop?: string): void; /** * Updates a meta tag. * * @param tag - The meta tag name. * @param value - The meta tag value. * @param prop - The meta tag property. */ private _updateMetaTag; /** * Removes a meta tag. * * @param tag - The meta tag name. * @param prop - The meta tag property. */ removeTag(tag: string, prop?: string): void; /** * Warns about missing meta guards in routes. */ private _warnMissingGuard; static ɵfac: i0.ɵɵFactoryDeclaration<MetaService, [{ optional: true; }, null, null, null]>; static ɵprov: i0.ɵɵInjectableDeclaration<MetaService>; } declare class MetaGuard { private metaService; private config; static IDENTIFIER: string; private _meta; constructor(metaService: MetaService, config: Config); canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean; private _processRouteMetaTags; static ɵfac: i0.ɵɵFactoryDeclaration<MetaGuard, [null, { optional: true; }]>; static ɵprov: i0.ɵɵInjectableDeclaration<MetaGuard>; } declare class AlertComponent implements AfterViewInit { /** Reference to the DOM element hosting the alert. */ alertRef: ElementRef<HTMLDivElement>; /** Callback invoked to remove the alert from the DOM. */ close: () => void; /** Text content displayed inside the alert. */ text: string; /** Additional CSS classes applied to the alert container. */ class: string; /** Type of alert which determines styling and icon. */ type: AlertType; /** Position on the screen where the alert appears. */ position: AlertPosition; /** Whether a progress bar indicating remaining time is shown. */ progress: boolean; /** Icon name displayed alongside the message. */ icon: string; /** Time in milliseconds before the alert auto closes. */ timeout: number; /** Determines if a manual close button is visible. */ closable: boolean; /** Flag used to trigger the deletion animation. */ delete_animation: boolean; /** Optional action buttons rendered within the alert. */ buttons: AlertButton[]; /** * Starts the auto‑dismiss timer and pauses it while the alert is * hovered, resuming when the mouse leaves. */ ngAfterViewInit(): void; /** * Triggers the closing animation and invokes the provided close * callback once finished. */ remove(callback?: () => void): void; private _removed; static ɵfac: i0.ɵɵFactoryDeclaration<AlertComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AlertComponent, "alert", never, {}, {}, never, never, true, never>; } /** * BaseComponent is an abstract class that provides basic functionality for managing the current timestamp. */ declare abstract class BaseComponent { /** * The current timestamp in milliseconds since the Unix epoch. */ now: number; /** * Refreshes the `now` property with the current timestamp. */ refreshNow(): void; } /** * Abstract reusable base class for CRUD list views. * It encapsulates pagination, modals, and document handling logic. * * @template Service - A service implementing CrudServiceInterface for a specific document type * @template Document - The data model extending CrudDocument */ declare abstract class CrudComponent<Service extends CrudServiceInterface<Document>, Document extends CrudDocument, FormInterface> { protected formService: unknown; protected translateService: { translate: (key: string) => string; }; /** Service responsible for data fetching, creating, updating, deleting */ protected crudService: Service; /** The array of documents currently loaded and shown */ protected documents: WritableSignal<Signal<Document>[]>; /** The reactive form instance generated from the provided config */ protected form: any; /** Current pagination page */ protected page: number; /** CoreService handles timing and copying helpers */ private __core; /** AlertService handles alerts */ private __alert; /** ChangeDetectorRef handles on push strategy */ private __cdr; /** Internal reference to form service matching FormServiceInterface */ private __form; /** * Constructor * * @param formConfig - Object describing form title and its component structure * @param formService - Any service that conforms to FormServiceInterface (usually casted) * @param translateService - An object providing a translate() method for i18n * @param crudService - CRUD service implementing get/create/update/delete */ constructor(formConfig: unknown, formService: unknown, translateService: { translate: (key: string) => string; }, crudService: Service, module?: string); /** * Loads documents for a given page. */ protected setDocuments(page?: number): Promise<void>; /** Fields considered when performing bulk updates. */ protected updatableFields: string[]; /** * Clears temporary metadata before document creation. */ protected preCreate(doc: Document): void; /** * Funciton which controls whether the create functionality is available. */ protected allowCreate(): boolean; /** * Funciton which controls whether the update and delete functionality is available. */ protected allowMutate(): boolean; /** * Funciton which controls whether the unique url functionality is available. */ protected allowUrl(): boolean; /** Determines whether manual sorting controls are available. */ protected allowSort(): boolean; /** * Funciton which prepare get crud options. */ protected getOptions(): CrudOptions<Document>; /** * Handles bulk creation and updating of documents. * In creation mode, adds new documents. * In update mode, syncs changes and deletes removed entries. */ protected bulkManagement(create?: boolean): () => void; /** Opens a modal to create a new document. */ protected create(): void; /** Displays a modal to edit an existing document. */ protected update(doc: Document): void; /** Requests confirmation before deleting the provided document. */ protected delete(doc: Document): void; /** Opens a modal to edit the document's unique URL. */ protected mutateUrl(doc: Document): void; /** Moves the given document one position up and updates ordering. */ protected moveUp(doc: Document): void; /** Data source mode used for document retrieval. */ protected configType: 'server' | 'local'; /** Number of documents fetched per page when paginating. */ protected perPage: number; /** * Configuration object used by the UI for rendering table and handling actions. */ protected getConfig(): TableConfig<Document>; /** Name of the collection or module used for contextual actions. */ private _module; } declare class LoaderComponent implements OnInit { close: () => void; text: string; class: string; progress: boolean; progressPercentage?: Signal<number>; timeout: number; closable: boolean; ngOnInit(): void; static ɵfac: i0.ɵɵFactoryDeclaration<LoaderComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<LoaderComponent, "ng-component", never, {}, {}, never, never, true, never>; } declare class ModalComponent implements OnInit { closable: boolean; close: any; onOpen: any; timestart: any; timeout: any; allowClose: boolean; onClickOutside: any; ngOnInit(): void; ngOnDestroy(): void; popStateListener(e: Event): void; static ɵfac: i0.ɵɵFactoryDeclaration<ModalComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<ModalComponent, "lib-modal", never, {}, {}, never, never, true, never>; } /** * Stand-alone “click outside” directive (zoneless-safe). * * Usage: * <div (clickOutside)="close()">…</div> */ declare class ClickOutsideDirective { readonly clickOutside: i0.OutputEmitterRef<MouseEvent>; constructor(); private _host; private _cdr; private _dref; private handler; static ɵfac: i0.ɵɵFactoryDeclaration<ClickOutsideDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<ClickOutsideDirective, "[clickOutside]", never, {}, { "clickOutside": "clickOutside"; }, never, never, true, never>; } declare class ArrPipe implements PipeTransform { transform(data: any, type?: any, refresh?: any): any; static ɵfac: i0.ɵɵFactoryDeclaration<ArrPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<ArrPipe, "arr", true>; } declare class MongodatePipe implements PipeTransform { transform(_id: any): Date; static ɵfac: i0.ɵɵFactoryDeclaration<MongodatePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<MongodatePipe, "mongodate", true>; } declare class NumberPipe implements PipeTransform { transform(value: unknown): number; static ɵfac: i0.ɵɵFactoryDeclaration<NumberPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<NumberPipe, "number", true>; } declare class PaginationPipe implements PipeTransform { transform(arr: any, config: any, sort: any, search?: string): any; static ɵfac: i0.ɵɵFactoryDeclaration<PaginationPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<PaginationPipe, "page", true>; } declare class SafePipe { transform(html: any): _angular_platform_browser.SafeResourceUrl; private _sanitizer; static ɵfac: i0.ɵɵFactoryDeclaration<SafePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<SafePipe, "safe", true>; } type Query = string | string[] | Record<string, unknown> | Signal<string | string[] | Record<string, unknown> | undefined>; type Field = string | string[] | number | Signal<string | string[] | number | undefined>; declare class SearchPipe implements PipeTransform { transform<T>(items: T[] | Record<string, T>, query?: Query, fields?: Field, limit?: number, ignore?: boolean, _reload?: unknown): T[]; static ɵfac: i0.ɵɵFactoryDeclaration<SearchPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<SearchPipe, "search", true>; } declare class SplicePipe implements PipeTransform { transform(from: any, which: any, refresh?: number): any; static ɵfac: i0.ɵɵFactoryDeclaration<SplicePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<SplicePipe, "splice", true>; } declare class SplitPipe implements PipeTransform { transform(value: string, index?: number, devider?: string): unknown; static ɵfac: i0.ɵɵFactoryDeclaration<SplitPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<SplitPipe, "split", true>; } /** * Representation of a component that has been dynamically added to the DOM. * * @template T - Type of the attached component instance. */ interface DomComponent<T> { /** The root DOM element of the created component. */ nativeElement: HTMLElement; /** Angular reference to the created component. */ componentRef: ComponentRef<T>; /** * Removes the component from the DOM and cleans up associated resources. */ remove: () => void; } declare class DomService { /** * Appends a component to a specified element by ID. * * @param component - The component to append. * @param options - The options to project into the component. * @param id - The ID of the element to append the component to. * @returns An object containing the native element and the component reference. */ appendById<T>(component: Type<T>, options: Partial<T> | undefined, id: string): DomComponent<T>; /** * Appends a component to a specified element or to the body. * * @param component - The component to append. * @param options - The options to project into the component. * @param element - The element to append the component to. Defaults to body. * @returns An object containing the native element and the component reference. */ appendComponent<T>(component: Type<T>, options?: Partial<T & { providedIn?: string; }>, element?: HTMLElement): DomComponent<T> | void; /** * Gets a reference to a dynamically created component. * * @param component - The component to create. * @param options - The options to project into the component. * @returns The component reference. */ getComponentRef<T>(component: Type<T>, options?: Partial<T>): ComponentRef<T>; /** * Projects the inputs onto the component. * * @param component - The component reference. * @param options - The options to project into the component. * @returns The component reference with the projected inputs. */ private projectComponentInputs; /** * Removes a previously attached component and optionally clears its * unique `providedIn` flag. * * @param componentRef - Reference to the component to be removed. * @param providedIn - Optional key used to track unique instances. */ removeComponent<T>(componentRef: ComponentRef<T>, providedIn?: string): void; /** Reference to the root application used for view attachment. */ private _appRef; /** Injector utilized when creating dynamic components. */ private _injector; /** * Flags to ensure components with a specific `providedIn` key are only * instantiated once at a time. */ private _providedIn; static ɵfac: i0.ɵɵFactoryDeclaration<DomService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<DomService>; } declare class AlertService { private _dom; /** * Creates a new alert service. * * @param config Optional global configuration provided via the * `CONFIG_TOKEN` injection token. * @param _dom Service responsible for DOM manipulation and dynamic * component creation. */ constructor(config: Config, _dom: DomService); /** * Displays an alert. Accepts either an options object or a simple string * which will be used as the alert text. * * @returns Reference to the created alert or embedded component * element. */ show(opts: Alert | string): Alert; /** * Convenience alias for `show`. */ open(opts: Alert): void; /** * Displays an informational alert. */ info(opts: Alert): void; /** * Displays a success alert. */ success(opts: Alert): void; /** * Displays a warning alert. */ warning(opts: Alert): void; /** * Displays an error alert. */ error(opts: Alert): void; /** * Displays a question alert. */ question(opts: Alert): void; /** * Removes all alert elements from the document. */ destroy(): void; private _alerts; /** Merged configuration applied to new alerts. */ private _config; /** Wrapper component that contains all alert placeholders. */ private _container; /** Mapping of alert positions to wrapper child indexes. */ private _positionNumber; private _opts; static ɵfac: i0.ɵɵFactoryDeclaration<AlertService, [{ optional: true; }, null]>; static ɵprov: i0.ɵɵInjectableDeclaration<AlertService>; } declare class BaseService { now: number; refreshNow(): void; static ɵfac: i0.ɵɵFactoryDeclaration<BaseService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<BaseService>; } /** * Simple representation of an option used by select controls. */ interface Selectitem { /** Display name of the option. */ name: string; /** Associated unique identifier. */ _id: string; } declare global { interface String { capitalize(): string; } } declare class CoreService { private platformId; deviceID: string; constructor(platformId: boolean); /** * Generates a UUID (Universally Unique Identifier) version 4. * * This implementation uses `Math.random()` to generate random values, * making it suitable for general-purpose identifiers, but **not** for * cryptographic or security-sensitive use cases. * * The format follows the UUID v4 standard: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` * where: * - `x` is a random hexadecimal digit (0–f) * - `4` indicates UUID version 4 * - `y` is one of 8, 9, A, or B * * Example: `f47ac10b-58cc-4372-a567-0e02b2c3d479` * * @returns A string containing a UUID v4. */ UUID(): string; /** * Converts an object to an array. Optionally holds keys instead of values. * * @param {any} obj - The object to be converted. * @param {boolean} [holder=false] - If true, the keys will be held in the array; otherwise, the values will be held. * @returns {any[]} The resulting array. */ ota(obj: any, holder?: boolean): any[]; /** * Removes elements from `fromArray` that are present in `removeArray` based on a comparison field. * * @param {any[]} removeArray - The array of elements to remove. * @param {any[]} fromArray - The array from which to remove elements. * @param {string} [compareField='_id'] - The field to use for comparison. * @returns {any[]} The modified `fromArray` with elements removed. */ splice(removeArray: any[], fromArray: any[], compareField?: string): any[]; /** * Unites multiple _id values into a single unique _id. * The resulting _id is unique regardless of the order of the input _id values. * * @param {...string[]} args - The _id values to be united. * @returns {string} The unique combined _id. */ ids2id(...args: string[]): string; private _afterWhile; /** * Delays the execution of a callback function for a specified amount of time. * If called again within that time, the timer resets. * * @param {string | object | (() => void)} doc - A unique identifier for the timer, an object to host the timer, or the callback function. * @param {() => void} [cb] - The callback function to execute after the delay. * @param {number} [time=1000] - The delay time in milliseconds. */ afterWhile(doc: string | object | (() => void), cb?: () => void, time?: number): void; /** * Recursively copies properties from one object to another. * Handles nested objects, arrays, and Date instances appropriately. * * @param from - The source object from which properties are copied. * @param to - The target object to which properties are copied. */ copy(from: any, to: any): void; device: string; /** * Detects the device type based on the user agent. */ detectDevice(): void; /** * Checks if the device is a mobile device. * @returns {boolean} - Returns true if the device is a mobile device. */ isMobile(): boolean; /** * Checks if the device is a tablet. * @returns {boolean} - Returns true if the device is a tablet. */ isTablet(): boolean; /** * Checks if the device is a web browser. * @returns {boolean} - Returns true if the device is a web browser. */ isWeb(): boolean; /** * Checks if the device is an Android device. * @returns {boolean} - Returns true if the device is an Android device. */ isAndroid(): boolean; /** * Checks if the device is an iOS device. * @returns {boolean} - Returns true if the device is an iOS device. */ isIos(): boolean; version: string; appVersion: string; dateVersion: string; /** * Sets the combined version string based on appVersion and dateVersion. */ setVersion(): void; /** * Sets the app version and updates the combined version string. * * @param {string} appVersion - The application version to set. */ setAppVersion(appVersion: string): void; /** * Sets the date version and updates the combined version string. * * @param {string} dateVersion - The date version to set. */ setDateVersion(dateVersion: string): void; private _signals; /** * Emits a signal, optionally passing data to the listeners. * @param signal - The name of the signal to emit. * @param data - Optional data to pass to the listeners. */ emit(signal: string, data?: any): void; /** * Returns an Observable that emits values when the specified signal is emitted. * Multiple components or services can subscribe to this Observable to be notified of the signal. * @param signal - The name of the signal to listen for. * @returns An Observable that emits when the signal is emitted. */ on(signal: string): Observable<any>; /** * Completes the Subject for a specific signal, effectively stopping any future emissions. * This also unsubscribes all listeners for the signal. * @param signal - The name of the signal to stop. */ off(signal: string): void; private _completed; private _completeResolvers; /** * Marks a task as complete. * @param task - The task to mark as complete, identified by a string. */ complete(task: string, document?: unknown): void; /** * Waits for one or more tasks to be marked as complete. * * @param {string | string[]} tasks - The task or array of tasks to wait for. * @returns {Promise<unknown>} A promise that resolves when all specified tasks are complete. * - If a single task is provided, resolves with its completion result. * - If multiple tasks are provided, resolves with an array of results in the same order. * * @remarks * If any task is not yet completed, a resolver is attached. The developer is responsible for managing * resolver cleanup if needed. Resolvers remain after resolution and are not removed automatically. */ onComplete(tasks: string | string[]): Promise<unknown>; /** * Returns a resolver function that checks if all given tasks are completed, * and if so, calls the provided resolve function with their results. * * @param {string[]} tasks - The list of task names to monitor for completion. * @param {(value: unknown) => void} resolve - The resolver function to call once all tasks are complete. * @returns {(doc: unknown) => void} A function that can be registered as a resolver for each task. * * @remarks * This function does not manage or clean up resolvers. It assumes the developer handles any potential duplicates or memory concerns. */ private _allCompleted; /** * Checks whether all specified tasks have been marked as completed. * * @param {string[]} tasks - The array of task names to check. * @returns {boolean} `true` if all tasks are completed, otherwise `false`. */ private _isCompleted; /** * Checks if a task is completed. * @param task - The task to check, identified by a string. * @returns True if the task is completed, false otherwise. */ completed(task: string): unknown; /** * Clears the completed state for a specific task. * * This removes the task from the internal `_completed` store, * allowing it to be awaited again in the future if needed. * It does not affect pending resolvers or trigger any callbacks. * * @param task - The task identifier to clear from completed state. */ clearCompleted(task: string): void; private _locked; private _unlockResolvers; /** * Locks a resource to prevent concurrent access. * @param which - The resource to lock, identified by a string. */ lock(which: string): void; /** * Unlocks a resource, allowing access. * @param which - The resource to unlock, identified by a string. */ unlock(which: string): void; /** * Returns a Promise that resolves when the specified resource is unlocked. * @param which - The resource to watch for unlocking, identified by a string. * @returns A Promise that resolves when the resource is unlocked. */ onUnlock(which: string): Promise<void>; /** * Checks if a resource is locked. * @param which - The resource to check, identified by a string. * @returns True if the resource is locked, false otherwise. */ locked(which: string): boolean; linkCollections: string[]; linkRealCollectionName: Record<string, string>; linkIds: Record<string, Selectitem[]>; addLink(name: string, reset: () => Selectitem[], realName?: string): void; /** * Converts a plain object into a signal-wrapped object. * Optionally wraps specific fields of the object as individual signals, * and merges them into the returned signal for fine-grained reactivity. * * @template Document - The type of the object being wrapped. * @param {Document} document - The plain object to wrap into a signal. * @param {Record<string, (doc: Document) => unknown>} [signalFields={}] - * Optional map where each key is a field name and the value is a function * to extract the initial value for that field. These fields will be wrapped * as separate signals and embedded in the returned object. * * @returns {Signal<Document>} A signal-wrapped object, possibly containing * nested field signals for more granular control. * * @example * const user = { _id: '1', name: 'Alice', score: 42 }; * const sig = toSignal(user, { score: (u) => u.score }); * console.log(sig().name); // 'Alice' * console.log(sig().score()); // 42 — field is now a signal */ toSignal<Document>(document: Document, signalFields?: Record<string, (doc: Document) => unknown>): Signal<Document>; /** * Converts an array of objects into an array of Angular signals. * Optionally wraps specific fields of each object as individual signals. * * @template Document - The type of each object in the array. * @param {Document[]} arr - Array of plain objects to convert into signals. * @param {Record<string, (doc: Document) => unknown>} [signalFields={}] - * Optional map where keys are field names and values are functions that extract the initial value * from the object. These fields will be turned into separate signals. * * @returns {Signal<Document>[]} An array where each item is a signal-wrapped object, * optionally with individual fields also wrapped in signals. * * @example * toSignalsArray(users, { * name: (u) => u.name, * score: (u) => u.score, * }); */ toSignalsArray<Document>(arr: Document[], signalFields?: Record<string, (doc: Document) => unknown>): Signal<Document>[]; /** * Adds a new object to the signals array. * Optionally wraps specific fields of the object as individual signals before wrapping the whole object. * * @template Document - The type of the object being added. * @param {Signal<Document>[]} signals - The signals array to append to. * @param {Document} item - The object to wrap and push as a signal. * @param {Record<string, (doc: Document) => unknown>} [signalFields={}] - * Optional map of fields to be wrapped as signals within the object. * * @returns {void} */ pushSignal<Document>(signals: Signal<Document>[], item: Document, signalFields?: Record<string, (doc: Document) => unknown>): void; /** * Removes the first signal from the array whose object's field matches the provided value. * @template Document * @param {WritableSignal<Document>[]} signals - The signals array to modify. * @param {unknown} value - The value to match. * @param {string} [field='_id'] - The object field to match against. * @returns {void} */ removeSignalByField<Document extends Record<string, unknown>>(signals: WritableSignal<Document>[], value: unknown, field?: string): void; /** * Returns a generic trackBy function for *ngFor, tracking by the specified object field. * @template Document * @param {string} field - The object field to use for tracking (e.g., '_id'). * @returns {(index: number, sig: Signal<Document>) => unknown} TrackBy function for Angular. */ trackBySignalField<Document extends Record<string, unknown>>(field: string): (_: number, sig: Signal<Document>) => unknown; /** * Finds the first signal in the array whose object's field matches the provided value. * @template Document * @param {Signal<Document>[]} signals - Array of signals to search. * @param {unknown} value - The value to match. * @param {string} [field='_id'] - The object field to match against. * @returns {Signal<Document> | undefined} The found signal or undefined if not found. */ findSignalByField<Document extends Record<string, unknown>>(signals: Signal<Document>[], value: unknown, field?: string): Signal<Document> | undefined; /** * Updates the first writable signal in the array whose object's field matches the provided value. * @template Document * @param {WritableSignal<Document>[]} signals - Array of writable signals to search. * @param {unknown} value - The value to match. * @param {(val: Document) => Document} updater - Function to produce the updated object. * @param {string} field - The object field to match against. * @returns {void} */ updateSignalByField<Document extends Record<string, unknown>>(signals: WritableSignal<Document>[], value: unknown, updater: (val: Document) => Document, field: string): void; static ɵfac: i0.ɵɵFactoryDeclaration<CoreService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<CoreService>; } declare class HttpService { private _http; errors: ((err: HttpErrorResponse, retry?: () => void) => {})[]; url: string; locked: boolean; awaitLocked: ReturnType<typeof setTimeout>[]; private _config; private _headers; private _http_headers; constructor(config: Config, _http: HttpClient); setUrl(url: string): void; removeUrl(): void; set(key: any, value: any): void; header(key: any): HttpHeaderType; remove(key: any): void; private _httpMethod; /** * Internal method to handle HTTP requests for various methods (POST, PUT, PATCH, DELETE, GET). * * Features: * - **Request Locking**: Manages request locking to prevent simultaneous requests. * - **Acceptance Check**: Validates the server response against a user-defined `acceptance` function. * If the check fails, the response is rejected with an error. * - **Replace Logic**: Allows modification of specific parts of the response object, determined by a user-defined `replace` function. * Can handle both objects and arrays within the response. * - **Field Filtering**: Supports extracting specific fields from response objects or arrays. * - **Legacy Support**: Compatible with callback-based usage alongside Observables. * - **ReplaySubject**: Ensures that the response can be shared across multiple subscribers. * * @param url - The endpoint to send the HTTP request to (relative to the base URL). * @param doc - The request payload for methods like POST, PUT, and PATCH. * @param callback - A legacy callback function to handle the response. * @param opts - Additional options: * - `err`: Error handling callback. * - `acceptance`: Function to validate the server response. Should return `true` for valid responses. * - `replace`: Function to modify specific parts of the response data. * - `fields`: Array of fields to extract from the response object(s). * - `data`: Path in the response where the data resides for `replace` and `fields` operations. * - `skipLock`: If `true`, bypasses request locking. * - `url`: Overrides the base URL for this request. * @param method - The HTTP method (e.g., 'post', 'put', 'patch', 'delete', 'get'). * @returns An Observable that emits the processed HTTP response or an error. */ private _post; /** * Public method to perform a POST request. * - Supports legacy callback usage. * - Returns an Observable for reactive programming. */ post(url: string, doc: any, callback?: (resp: any) => void, opts?: any): Observable<any>; /** * Public method to perform a PUT request. * - Supports legacy callback usage. * - Returns an Observable for reactive programming. */ put(url: string, doc: any, callback?: (resp: any) => void, opts?: any): Observable<any>; /** * Public method to perform a PATCH request. * - Supports legacy callback usage. * - Returns an Observable for reactive programming. */ patch(url: string, doc: any, callback?: (resp: any) => void, opts?: any): Observable<any>; /** * Public method to perform a DELETE request. * - Supports legacy callback usage. * - Returns an Observable for reactive programming. */ delete(url: string, callback?: (resp: any) => void, opts?: any): Observable<any>; /** * Public method to perform a GET request. * - Supports legacy callback usage. * - Returns an Observable for reactive programming. */ get(url: string, callback?: (resp: any) => void, opts?: any): Observable<any>; clearLocked(): void; lock(): void; unlock(): void; /** * Handles HTTP errors. * - Calls provided error callback and retries the request if needed. */ private handleError; /** * Internal method to trigger error handling callbacks. */ private err_handle; private prepare_handle; private response_handle; /** * Retrieves a nested object or property from the response based on a dot-separated path. * * @param resp - The response object to retrieve data from. * @param base - A dot-separated string indicating the path to the desired property within the response. * - Example: `'data.items'` will navigate through `resp.data.items`. * - If empty, the entire response is returned. * @returns The object or property located at the specified path within the response. */ private _getObjectToReplace; /** * Sets or replaces a nested object or property in the response based on a dot-separated path. * * @param resp - The response object to modify. * @param base - A dot-separated string indicating the path to the property to replace. * - Example: `'data.items'` will navigate through `resp.data.items`. * @param doc - The new data or object to set at the specified path. * @returns `void`. */ private _setObjectToReplace; /** * Creates a new object containing only specified fields from the input item. * * @param item - The input object to extract fields from. * @param fields - An array of field names to include in the new object. * - Example: `['id', 'name']` will create a new object with only the `id` and `name` properties from `item`. * @returns A new object containing only the specified fields. */ private _newDoc; static ɵfac: i0.ɵɵFactoryDeclaration<HttpService, [{ optional: true; }, null]>; static ɵprov: i0.ɵɵInjectableDeclaration<HttpService>; } declare class StoreService { constructor(config: Config); /** * Sets the prefix for storage keys. * * @param prefix - The prefix to set. */ setPrefix(prefix: string): void; /** * Sets a value in storage asynchronously. * * @param key - The storage key. * @param value - The value to store. * @returns A promise that resolves to a boolean indicating success. */ set(key: string, value: string, callback?: () => void, errCallback?: (err: unknown) => void): Promise<boolean>; /** * Gets a value from storage asynchronously. * * @param key - The storage key. * @returns A promise that resolves to the retrieved value or `null` if the key is missing. */ get(key: string, callback?: (value: string | null) => void, errCallback?: (err: unknown) => void): Promise<string | null>; /** * Sets a JSON value in storage asynchronously. * * @param key - The storage key. * @param value - The value to store. * @returns A promise that resolves to a boolean indicating success. */ setJson<T>(key: string, value: T, callback?: () => void, errCallback?: (err: unknown) => void): Promise<boolean>; /** * Gets a JSON value from storage asynchronously. * * @param key - The storage key. * @returns A promise that resolves to the retrieved value. */ getJson<T = any>(key: string, callback?: (value: string | null) => void, errCallback?: (err: unknown) => void): Promise<T | null>; /** * Removes a value from storage. * * @param key - The storage key. * @param callback - The callback to execute on success. * @param errCallback - The callback to execute on error. * @returns A promise that resolves to a boolean indicating success. */ remove(key: string, callback?: () => void,