@o3r/core
Version:
Core of the Otter Framework
955 lines (924 loc) • 35.9 kB
TypeScript
import { InputSignal, Signal, EventEmitter } from '@angular/core';
import { Observable, OperatorFunction } from 'rxjs';
import { FormControl } from '@angular/forms';
import * as _ngrx_entity from '@ngrx/entity';
import { EntityAdapter, EntityState } from '@ngrx/entity';
import { Action } from '@ngrx/store';
/**
* Library build time properties
*/
interface BuildTimeProperties {
/**
* True if the application in launch in debug mode
*/
DEBUG_MODE: boolean;
/**
* True if the webStorage option is enabled
*/
ENABLE_WEBSTORAGE: boolean;
/**
* Name of the current environment
*/
ENVIRONMENT: string;
/**
* Boolean that can be used to activate API calls mocks for development or mock-up purpose.
*/
USE_MOCKS: boolean;
/**
* Maximum size of the dev tool history
*/
DEVTOOL_HISTORY_SIZE: number | undefined;
/**
* path to bundles in published folder
*/
LOCALIZATION_BUNDLES_OUTPUT: string;
/**
* The name of the bundle generated with the default localization components keys
*/
DEFAULT_LOC_BUNDLE_NAME: string;
/**
* Indicates the default server prefix to be used in case no dynamic is found
*/
APP_BASE_HREF: string | undefined;
/**
* Version of the App based on the package.json
*/
APP_VERSION: string;
/**
* Determine if the ghosting is activated on the app
*/
ENABLE_GHOSTING: boolean;
}
/**
* Library build time default properties
*/
declare const DEFAULT_BUILD_PROPERTIES: Readonly<BuildTimeProperties>;
interface BootstrapConfig {
/**
* App environment
*
*/
environment: 'prod' | 'dev';
}
/** Data set injected to the page from the DGP web-server */
interface Dataset {
/**
* Bootstrap configuration
* @example
* ```typescript
* '{ environment: 'prod' }'
* ```
*/
bootstrapconfig?: string;
/**
* Dynamic content path
* @example
* ```typescript
* 'my/dynamic/path'
* ```
*/
dynamiccontentpath?: string;
/**
* Application basehref url
* @example
* ```typescript
* '/my/base/href'
* ```
*/
appbasehref?: string;
}
/**
* Types available for configuration
*/
type ConfigurationValueType = string | number | boolean;
/**
* Nested configuration allowing one level only
* Object should only contain primitive types
*/
interface NestedConfiguration {
[]: ConfigurationValueType;
}
/**
* Interface of configuration that is supported by the cms
*/
interface Configuration {
[]: ConfigurationValueType | (string | NestedConfiguration)[];
}
/** Configuration model exported by the CMS */
interface CustomConfig<T extends Partial<Configuration> = Partial<Configuration>> {
/** Component name */
name: string;
/** Component's library name; No library name for global config */
library?: string;
/** Component configuration as key value pairs */
config: T;
}
/**
* Dynamically Configurable item
*/
interface DynamicConfigurable<T extends Configuration> {
/**
* Configuration override by Angular input mechanism
*/
config: Partial<T> | undefined;
/**
* Configuration stream based on the input and the stored configuration
*/
config$: Observable<T>;
}
/**
* Dynamically Configurable item working with signal
*/
interface DynamicConfigurableWithSignal<T extends Configuration> {
/**
* Configuration override by Angular input mechanism
*/
config: InputSignal<Partial<T> | undefined>;
/**
* Configuration signal based on the input and the stored configuration
*/
configSignal: Signal<T>;
}
/**
* Configurable item
*/
interface Configurable<T extends {}> {
/**
* Configuration
*/
config: T;
}
/**
* Description of a configuration property extracted to the CMS
*/
interface CategoryDescription {
/** Category name */
name: string;
/** Category description */
label: string;
}
/** Types of components config */
type ConfigType = 'Block' | 'Page' | 'AppRuntimeConfiguration' | 'AppBuildConfiguration' | 'ExposedComponent';
/**
* Interface to define widget parameter to be used on CMS side
*/
interface ConfigPropertyWidgetParameters {
[]: string | boolean | number | string[] | boolean[] | number[];
}
/**
* Interface to define the widget to be used on CMS side
*/
interface ConfigPropertyWidget {
/** Type of the CMS widget */
type: string;
/** Parameters provided to the CMS widget */
parameters?: ConfigPropertyWidgetParameters;
}
/**
* Application config
* Application config should implement this to be identified by CMS extractor as a 'runtime' config
*/
interface AppRuntimeConfiguration extends Configuration {
}
/**
* Application config
* Application config should implement this to be identified by CMS extractor as a 'build time' config
*/
interface AppBuildConfiguration extends Configuration {
}
/**
* Type expert to extend only public fields of a class
*/
type InterfaceOf<T> = {
[]: T[P];
};
/**
* Interface used to define an object of two elements: label & value
*/
interface LabelValue<T> {
label: string;
value: T;
}
/** Interface extending Window with Otter Devtools accessor */
interface WindowWithDevtools extends Window {
/** Otter Devtools accessor */
_OTTER_DEVTOOLS_?: Record<string, any>;
}
/** Common option used by the different DevKit services */
interface DevtoolsCommonOptions {
/**
* Activated on the application bootstrap
* @default false
*/
isActivatedOnBootstrap: boolean;
}
/** Common option used by the different Contextualization DevKit services */
interface ContextualizationDevtoolsCommonOptions {
/**
* Activated on the application bootstrap when integrated in CMS context
* @default true
*/
isActivatedOnBootstrapWhenCMSContext: boolean;
}
/**
* Dataset injected on the page when in CMS context
*/
interface ContextualizationDataset {
/** `"true"` when in CMS context */
cmscontext?: string;
}
/** Interface describing an Otter Devtools service */
interface DevtoolsServiceInterface {
/** Activate the devtools service */
activate(): void;
}
/**
* Generic translation
*/
interface Translation {
[]: string;
}
/**
* Inputs of the component
*/
interface ContextInput {
[]: any;
}
/**
* Base outputs of the components
*/
interface BaseContextOutput {
[]: any;
}
/**
* Type helper to generate the interface of component outputs
*/
type EventEmitterify<T extends BaseContextOutput> = {
[]: EventEmitter<T[P]>;
};
/**
* Context of the component
*/
type Context<T extends ContextInput = {}, U extends BaseContextOutput = {}> = {
[]: T[P];
} & {
[]: EventEmitterify<U>[P];
};
/**
* Type helper to generate the template context outputs
*/
type Functionify<T extends BaseContextOutput> = {
[]: (value: T[P]) => void;
};
/**
* Interface for a context of a child component
*/
interface TemplateContext<N extends {}, S extends ContextInput = Record<string, unknown>, F extends BaseContextOutput = Record<string, unknown>, W extends Translation = Translation> {
/** Component configuration */
config?: Partial<N>;
/** Component inputs context */
inputs: S & {
[]: any;
};
/** Component outputs context */
outputs: Functionify<F & {
[]: any;
}>;
/** Component translation */
translations?: Partial<W>;
/** Parent Component Id */
parentId?: string;
/** Form control object to be applied to the form */
formControl?: FormControl;
}
/**
* Unique identifier of an item in the extracted metadata
*/
interface ItemIdentifier {
/**
* Name of the library where the item is originally from
*/
library: string;
/**
* Name of the item
*/
name: string;
}
/** Type of component */
type ComponentType = 'Block' | 'Page' | 'ExposedComponent' | 'Component';
/**
* Information about an Otter component to provide
*/
interface OtterComponentInfoToProvide {
/** Type of component */
componentType: ComponentType;
}
/**
* Information about an Otter component
*/
interface OtterComponentInfo extends OtterComponentInfoToProvide {
/** Configuration ID */
configId?: string;
/** Translation keys */
translations?: Translation;
/** Component Name */
componentName: string;
}
/**
* Private field where Otter component information are stored
*/
declare const otterComponentInfoPropertyName = "__otter-info__";
/**
* Decorates an Angular component to provide Otter information
* @param info Information to define the Otter component
* @returns the component with the information
*/
declare function O3rComponent(info: OtterComponentInfoToProvide): <T extends new (...args: any[]) => object>(constructor: T) => T;
/**
* Compute the name of the component with the library's name to generate unique component identifier used in metadata and different modules
* @param componentName Name of the component to get the configuration
* @param libraryName Name of the library the component is coming from
*/
declare function computeItemIdentifier<C extends string, L extends string>(componentName: C, libraryName?: L): `${L extends string ? `${L}
/**
* Represents an output generated by an Extractor
*/
interface Output {
/** Name of the output entity */
name: string;
/** Filepath of the entity */
path: string;
}
/**
* Minimum action field
*/
interface RulesEngineAction<A extends string = string, V = any> {
/** Type of the action */
actionType: A;
/** Generic value of the action */
value: V;
}
/**
* Action handler executed by the rules engine
*/
interface RulesEngineActionHandler<T extends RulesEngineAction = RulesEngineAction> {
/**
* Execute the actions resulting of the rules engine
* @param actions List of actions executed by the rules engine
*/
executeActions(actions: T[]): void | Promise<void>;
/**
* Actions supported by the handler
*/
supportingActions: readonly T['actionType'][];
}
/**
* Logger Client interface.
*/
interface Logger {
/**
* Log an error.
* @param message Message to log
* @param optionalParams Optional parameters to log
*/
error(message?: any, ...optionalParams: any[]): void;
/**
* Log a warning.
* @param message Message to log
* @param optionalParams Optional parameters to log
*/
warn(message?: any, ...optionalParams: any[]): void;
/**
* Log a message.
* @param message Message to log
* @param optionalParams Optional parameters to log
*/
info?(message?: any, ...optionalParams: any[]): void;
/**
* Log a message.
* @param message Message to log
* @param optionalParams Optional parameters to log
*/
log(message?: any, ...optionalParams: any[]): void;
/**
* Log a debug message.
* @param message Message to log
* @param optionalParams Optional parameters to log
*/
debug?(message?: any, ...optionalParams: any[]): void;
}
/** Type of a message exchanged within the Otter Framework */
declare const otterMessageType = "otter";
/** Target of a message that should be handled by the application */
declare const applicationMessageTarget = "app";
interface OtterMessageContent<DataType extends string = string> {
/** Type of data */
dataType: DataType;
}
interface OtterMessage<Content extends OtterMessageContent = OtterMessageContent, Target extends string | undefined = undefined | string> {
/** Type of the message */
type: typeof otterMessageType;
/** Version of the message (default to the @o3r/core version ) */
version?: string;
/** Target of the message */
to: Target;
/** Message content */
content: Content;
}
/** Type helper to retrieve the data types of a union of MessageContent */
type MessageDataTypes<T extends OtterMessageContent> = T['dataType'];
/** Type helper to filter the message that can be received by the application */
type FilterMessageToApplication<T extends OtterMessage> = T extends {
to: infer U;
} ? U extends (typeof applicationMessageTarget | undefined) ? T : never : never;
type ContentMessageData<T extends OtterMessageContent> = T extends any ? Omit<T, 'dataType'> : never;
/** Extension connection notification message content */
interface ConnectContentMessage extends OtterMessageContent<'connect'> {
}
/** Script Injection message content */
interface InjectContentMessage extends OtterMessageContent<'inject'> {
/** Path to the extension script to inject to the web application */
scriptToInject: string;
}
/** Requested messages Message Content */
interface RequestMessagesContentMessage<AvailableMessageDataTypes extends string = string> extends OtterMessageContent<'requestMessages'> {
/** If specified, only the listed messages will be re-emitted */
only?: AvailableMessageDataTypes[];
}
/** List of common Otter content messages */
type CommonContentMessages = ConnectContentMessage | InjectContentMessage | RequestMessagesContentMessage;
/**
* Determine if a message should be handle by the application
* @param message Message to analyze
*/
declare const isToAppOtterMessage: <T extends OtterMessage>(message?: T) => message is FilterMessageToApplication<T & {
to: "app";
}>;
/**
* Determine if a message is emitted by an Otter tool
* @param message Message to analyze
*/
declare const isOtterMessage: <T extends OtterMessageContent>(message: any) => message is OtterMessage<T>;
/**
* Send an Otter Message
* @param dataType Type of the message
* @param content content of the message
* @param preStringify determine if the message should JSON.stringify before being send (will use the default mechanism otherwise)
*/
declare const sendOtterMessage: <T extends OtterMessageContent>(dataType: T["dataType"], content: ContentMessageData<T>, preStringify?: boolean) => void;
declare function filterMessageContent<T extends Event | MessageEvent>(): (source$: Observable<T>) => Observable<OtterMessageContent<string>>;
declare function filterMessageContent<T extends Event | MessageEvent, S extends OtterMessageContent>(predicate: (message: any) => message is S): (source$: Observable<T>) => Observable<S>;
/**
* Object that define how to serialize a specific state
*/
interface Serializer<T> {
serialize?: (obj: T) => any;
deserialize?: (data?: any) => T;
reviver?: (key: string, value: any) => any;
replacer?: (key: string, value: any) => any;
initialState?: T;
}
declare class StateSerializer<T> implements Serializer<T> {
serialize?: (obj: T) => any;
deserialize?: (data?: any) => T;
replacer?: (key: string, value: any) => any;
initialState?: T;
constructor(serializer: Serializer<T>);
reviver: (_: string, value: any) => any;
}
interface LocalStateModel {
/**
* Temporary ID of the model in the dictionary
*/
tid: string;
}
/**
* Adds an `id` to the given type
*/
type Idfy<T> = T & {
id: string | number;
};
/**
* Payload to update actions
*/
interface UpdateActionPayload<T> {
stateDetails: Partial<T>;
}
/**
* Payload to set actions
*/
interface SetActionPayload<T> {
stateDetails: T;
}
/**
* Payload to set state actions
*/
interface SetStateActionPayload<T> {
state: T;
}
/**
* Payload to fail actions
*/
interface FailActionPayload<T> {
error?: T;
}
type Keep<T, K extends keyof T> = Partial<T> & Pick<T, K>;
/** Payload to update entities actions */
interface UpdateEntitiesActionPayload<T, K extends keyof T> {
entities: Keep<T, K>[];
}
/** Payload to update entities actions with a field ID */
interface UpdateEntitiesActionPayloadWithId<T extends {
id: string | number;
}> {
entities: Keep<T, 'id'>[];
}
/** Payload to update entities actions */
interface UpdateEntityActionPayload<T, K extends keyof T> {
entity: Keep<T, K>;
}
/** Payload to update entities actions with a field ID */
interface UpdateEntityActionPayloadWithId<T extends {
id: string | number;
}> {
entity: Keep<T, 'id'>;
}
/** Payload to set entities and upsert entities actions */
interface SetEntitiesActionPayload<T> {
entities: T[];
}
/** Payload to set entity and upsert entity actions */
interface SetEntityActionPayload<T> {
entity: T;
}
/** Payload to fail entities actions */
interface FailEntitiesActionPayload<T> extends FailActionPayload<T> {
ids?: (string | number)[];
}
/**
* Payload to clear the store in case of failure
*/
interface ClearOnFailurePayload {
/** Clear store on failure */
clearOnFailure?: boolean;
}
type RequestId = string;
/**
* Interface representing an asynchronous request
*/
interface AsyncRequest {
/** ID of the request */
requestId: RequestId;
}
/**
* Represents a store item that can be manipulated via asynchronous calls
*/
interface AsyncStoreItem {
/**
* IDs of the active asynchronous requests for this item.
*/
requestIds: RequestId[];
/**
* Has a recent call failed.
* This is reset back to false the next time a new async process is started and there are no active requests.
*/
isFailure?: boolean;
/**
* Is an asynchronous process ongoing on that item
*/
isPending?: boolean;
}
/**
* Payload for actions relying on asynchronous requests
*/
interface FromApiActionPayload<T> extends Partial<AsyncRequest> {
/** Promise call from API */
call: Promise<T>;
}
/**
* Unwraps the type of a FromApiActionPayload
*/
type ExtractFromApiActionPayloadType<T extends FromApiActionPayload<any>> = T['call'] extends Promise<infer U> ? U : never;
/**
* Payload for actions relying on asynchronous requests
*/
interface FromApiActionPayloadWithEntityId<T> extends FromApiActionPayload<T> {
/** ID of the entity affected by the call */
id?: string;
}
/** Add an optional request ID to the given object */
type WithRequestId<T> = T & Partial<AsyncRequest>;
/** Payload to set entities actions from async */
interface SetAsyncStoreItemActionPayload<T> extends SetActionPayload<T>, Partial<AsyncRequest> {
}
/** Payload to update entities actions from async */
interface UpdateAsyncStoreItemEntitiesActionPayload<T extends object, K extends keyof T> extends UpdateEntitiesActionPayload<T, K>, Partial<AsyncRequest> {
}
/** Payload to update entities actions from async with a field ID */
interface UpdateAsyncStoreItemEntitiesActionPayloadWithId<T extends {
id: string | number;
}> extends UpdateEntitiesActionPayloadWithId<T>, Partial<AsyncRequest> {
}
/** Payload to update entity actions from async */
interface UpdateAsyncStoreItemEntityActionPayload<T extends object, K extends keyof T> extends UpdateEntityActionPayload<T, K>, Partial<AsyncRequest> {
}
/** Payload to update entity actions from async with a field ID */
interface UpdateAsyncStoreItemEntityActionPayloadWithId<T extends {
id: string | number;
}> extends UpdateEntityActionPayloadWithId<T>, Partial<AsyncRequest> {
}
/** Payload to set/upsert entities actions from async */
interface SetAsyncStoreItemEntitiesActionPayload<T extends object> extends SetEntitiesActionPayload<T>, Partial<AsyncRequest> {
}
/** Payload to set/upsert entity actions from async */
interface SetAsyncStoreItemEntityActionPayload<T extends object> extends SetEntityActionPayload<T>, Partial<AsyncRequest> {
}
/** Payload to fail entity actions from async */
interface FailAsyncStoreItemEntityActionPayload<T extends object> extends FailActionPayload<T>, Partial<AsyncRequest> {
}
/** Payload to fail entities actions from async */
interface FailAsyncStoreItemEntitiesActionPayload<T extends object> extends FailEntitiesActionPayload<T>, Partial<AsyncRequest> {
}
/** Status for all the elements inside a cart */
type EntityStatus<T, U extends keyof T = never> = {
[]?: AsyncStoreItem;
};
/**
* Extends an Entity model with a status property that holds async information for each of its sub-resources
*/
type EntityWithStatus<T> = T & {
status: EntityStatus<T>;
};
/** Modifies the given type that extends AsyncStoreItem to remove those properties */
type EntityWithoutAsyncStoreItem<T extends AsyncStoreItem> = Omit<T, keyof AsyncStoreItem>;
/** Adapter for Asynchronous Entity Store */
interface EntityAsyncRequestAdapter<T extends AsyncStoreItem> extends EntityAdapter<T> {
/**
* Updates the AsyncStoreItem properties of each entity matching an id from the list of given ids, when a request has failed.
* @param state Actual state
* @param ids Ids of the entity to be updated with AsyncStoreItem properties
* @param requestId Id of request which has failed
*/
failRequestMany<V extends EntityState<T> & AsyncStoreItem>(state: V, ids?: (string | number)[], requestId?: string): V;
/**
* Adds AsyncStoreItem property to the global store, or the entity if it already exists, when a request is triggered.
* @param state Actual state
* @param id Id of the entity to update
* @param requestId Id of the request which is triggered
*/
addRequestOne<V extends EntityState<T> & AsyncStoreItem>(state: V, id: string | number | null | undefined, requestId: string): V;
/**
* Adds AsyncStoreItem properties for each entity matching the given ids, when a request is triggered
* @param state Actual state
* @param ids Ids of the entity to be updated with AsyncStoreItem properties
* @param requestId Id of request which is triggered
*/
addRequestMany<V extends EntityState<T>>(state: V, ids: (string | number)[], requestId: string): V;
/**
* Updates the state with the given entity. Update the global or the current entity's status if it exists.
* @param state Actual state
* @param entity Payload item;
* @param requestId Id of request which has resolved if any
*/
resolveRequestOne<V extends EntityState<T> & AsyncStoreItem>(state: V, entity: EntityWithoutAsyncStoreItem<T> & Record<'id', string | number>, requestId?: string): V;
/**
* Updates the state with the given entity. Update the global or the current entity's status if it exists.
* @param state Actual state
* @param entity Payload item;
* @param requestId Id of request which has resolved if any
* @param idProperty Property of the entity containing its unique identifier
*/
resolveRequestOne<V extends EntityState<T> & AsyncStoreItem, W extends keyof T>(state: V, entity: EntityWithoutAsyncStoreItem<T> & Record<W, string | number>, requestId?: string, idProperty?: W): V;
/**
* Updates the state with the given entities. Updates also AsyncStoreItem properties of each entity, when a request is resolved.
* @param state Actual state
* @param entities Payload items;
* @param requestId Id of request which has resolved if any
*/
resolveRequestMany<V extends EntityState<T>>(state: V, entities: (Partial<T> & Record<'id', string | number>)[], requestId?: string): V;
/**
* Updates the state with the given entities. Updates also AsyncStoreItem properties of each entity, when a request is resolved.
* @param state Actual state
* @param entities Payload items;
* @param requestId Id of request which has resolved if any
* @param idProperty Property of the entity containing its unique identifier
*/
resolveRequestMany<V extends EntityState<T>, W extends keyof T>(state: V, entities: (Partial<T> & Record<W, string | number>)[], requestId?: string, idProperty?: W): V;
}
/**
* Create an Asynchronous Request Entity Adapter
* @param adapter Entity Adapter
*/
declare function createEntityAsyncRequestAdapter<T extends AsyncStoreItem>(adapter: EntityAdapter<T>): EntityAsyncRequestAdapter<T>;
/**
* Adapter to help manipulate AsyncStoreItems to register new request and update the status when they fail or resolve.
*/
interface AsyncStoreItemAdapter {
/**
* Adds a request to an AsyncStoreItem.
* If the item had a failure and no ongoing requests, sets it's failure status back to false
* @param item
* @param requestId
*/
addRequest<T extends AsyncStoreItem>(item: T, requestId: string): T;
/**
* Updates an AsyncStoreItem when a request has resolved.
* Removes it from its requestIds array.
* If no requestId provided, the method returns the current status of the AsyncStoreItem
* @param item
* @param requestId
*/
resolveRequest<T extends AsyncStoreItem>(item: T, requestId?: string): T;
/**
* Updates an AsyncStoreItem when a request has failed.
* Removes it from its requestIds array and set its failure status.
* @param item
* @param requestId
*/
failRequest<T extends AsyncStoreItem>(item: T, requestId?: string): T;
/**
* Add AsyncStoreItem properties (with initial values) to the given entity
* @param entityItem
* @returns Given item improved with AsyncStoreItem properties
*/
initialize<T extends object>(entityItem: T): T & AsyncStoreItem;
/**
* Extract only AsyncStoreItem properties from the given entity
* @param entityItem A model containing AsyncStoreItem properties
* @returns Object containing only AsyncStoreItem properties
*/
extractAsyncStoreItem<T extends AsyncStoreItem>(entityItem: T): AsyncStoreItem;
/**
* Clear AsyncStoreItem properties from the given entity
* @param entityItem A model containing AsyncStoreItem properties
*/
clearAsyncStoreItem<T extends AsyncStoreItem>(entityItem: T): T;
/**
* Merges an AsyncStoreItem collection into one item that gives an overall status.
* @param items
*/
merge(...items: (AsyncStoreItem | undefined)[]): AsyncStoreItem;
/**
* Add a request to the given subResource of an EntityStatus object
* @param status
* @param subResource
* @param requestId
*/
entityStatusAddRequest<T extends EntityStatus<T>>(status: T, subResource: keyof T, requestId: string): T;
/**
* Resolve a request on the given subResource of an EntityStatus object
* @param status
* @param subResource
* @param requestId
*/
entityStatusResolveRequest<T extends EntityStatus<T>>(status: T, subResource: keyof T, requestId?: string): T;
/**
* Fail a request to the given subResource of an EntityStatus object
* @param status
* @param subResource
* @param requestId
*/
entityStatusFailRequest<T extends EntityStatus<T>>(status: T, subResource: keyof T, requestId?: string): T;
/**
* Reset the failure status of the given subResource of an EntityStatus object
* @param status
* @param subResource
*/
entityStatusResetFailure<T extends EntityStatus<T>>(status: T, subResource: keyof T): T;
/**
* Reset the failure status of the given AsyncStoreItem to false
* @param entityItem
* @returns AsyncStoreItem with the updated failure status
*/
resetFailureStatus<T extends AsyncStoreItem>(entityItem: T): T;
/**
* Set the pending status of the given AsyncStoreItem to true
* @param entityItem
* @returns AsyncStoreItem with the updated pending status
*/
setLoadingStatus<T extends AsyncStoreItem>(entityItem: T): T;
}
declare const asyncStoreItemAdapter: AsyncStoreItemAdapter;
/**
* Determine if the action is an AsyncRequest action
* @param action Redux Action
*/
declare function isCallAction<T = any>(action?: any): action is FromApiActionPayload<T>;
/**
* Determine if the action is an AsyncRequest action with a Request ID
* @param action Redux Action
*/
declare function isIdentifiedCallAction<T = any>(action?: any): action is FromApiActionPayload<T> & AsyncRequest;
/**
* Determine if the given item implements the AsyncRequest interface
* @param item
*/
declare function isAsyncRequest<T>(item: any): item is T & AsyncRequest;
/**
* Custom operator to use instead of SwitchMap with effects based on FromApi actions.
* It makes sure to emit an action when the inner subscription is unsubscribed in order to keep the store up-to-date with pending information.
* @param successHandler function that returns the action to emit in case the FromApi call is a success
* @param errorHandler function that returns the action to emit in case the FromApi call fails
* @param cancelRequestActionFactory function that returns the action to emit in case the FromApi action is 'cancelled' because a new action was received by the switchMap
*/
declare function fromApiEffectSwitchMap<T extends FromApiActionPayload<any>, S extends ExtractFromApiActionPayloadType<T>, U extends Action, V extends Action, W extends Action>(successHandler: (result: S, action: T) => U | Observable<U> | Promise<U>, errorHandler?: (error: any, action: T) => Observable<V>, cancelRequestActionFactory?: (props: AsyncRequest, action: T) => W): OperatorFunction<T, U | V | W>;
/**
* Same as {@link fromApiEffectSwitchMap}, instead one inner subscription is kept by id.
* @param successHandler
* @param errorHandler
* @param cancelRequestActionFactory
* @param cleanUpTimer
*/
declare function fromApiEffectSwitchMapById<T extends FromApiActionPayload<any> & {
id: string;
}, S extends ExtractFromApiActionPayloadType<T>, U extends Action, V extends Action, W extends Action>(successHandler: (result: S, action: T) => U | Observable<U> | Promise<U>, errorHandler?: (error: any, action: T) => Observable<V>, cancelRequestActionFactory?: (props: AsyncRequest, action: T) => W, cleanUpTimer?: number): OperatorFunction<T, U | V | W>;
/**
* Returns a creator that makes sure that requestId is defined in the action's properties by generating one
* if needed.
*/
declare const asyncProps: <P extends object>() => (props: P) => P & AsyncRequest;
/**
* Serializer for asynchronous store.
* @param state State of an asynchronous store to serialize
* @returns a plain json object to pass to json.stringify
*/
declare function asyncSerializer<T extends AsyncStoreItem>(state: T): T;
/**
* Serializer for asynchronous entity store.
* @param state State of an asynchronous entity store to serialize
* @returns a plain json object to pass to json.stringify
*/
declare function asyncEntitySerializer<T extends AsyncStoreItem & EntityState<AsyncStoreItem>>(state: T): T & {
entities: _ngrx_entity.Dictionary<AsyncStoreItem>;
};
/**
* Serializer for asynchronous entity store with status.
* @param state State of an asynchronous entity store with status to serialize
* @returns a plain json object to pass to json.stringify
*/
declare function asyncEntityWithStatusSerializer<T extends AsyncStoreItem & EntityState<AsyncStoreItem & {
status: EntityStatus<T['entities']['status']>;
}>>(state: T): T & {
entities: _ngrx_entity.Dictionary<AsyncStoreItem & {
status: EntityStatus<T["entities"]["status"]>;
}>;
};
/**
* Pad number
* @param val
* @param digits
*/
declare function padNumber(val: number, digits?: number): string;
/**
* Returns TRUE if bootstrap config environment is production FALSE otherwise
* @param dataset
* @returns TRUE if bootstrap config environment is production FALSE otherwise
*/
declare function isProductionEnvironment(dataset: Dataset): boolean;
/** Reviver Mapper to detect and create object on deepFill */
interface PrimitiveReviverMapper<T = any> {
/** Condition to fill to be determine as */
condition: (data: any) => boolean;
/**
* Construct the primitive type if needed
* @param data to be constructed
* @default {@see defaultConstruct}
*/
construct?: (data: any) => T;
}
/**
* Check if an object is not an array or a date
* @param obj
* @param additionalMappers
*/
declare function isObject(obj: any, additionalMappers?: PrimitiveReviverMapper[]): boolean;
/**
* Return a new reference of the given object
* @param obj
* @param additionalMappers
*/
declare function immutablePrimitive(obj: any, additionalMappers?: PrimitiveReviverMapper[]): any;
/**
* Deep fill of base object using source
* It will do a deep merge of the objects, overriding arrays
* All properties not present in source, but present in base, will remain
* @param base
* @param source
* @param additionalMappers Map of conditions of type mapper
*/
declare function deepFill<T extends {
[x: string]: any;
}>(base: T, source?: {
[x: string]: any;
}, additionalMappers?: PrimitiveReviverMapper[]): T;
/**
* Buffers and emits data for lazy/progressive rendering of big lists
* That could solve issues with long-running tasks when trying to render an array
* of similar components.
* @param delayMs Delay between data emits
* @param concurrency Amount of elements that should be emitted at once
*/
declare function lazyArray<T>(delayMs?: number, concurrency?: number): (source$: Observable<T[]>) => Observable<T[]>;
export { DEFAULT_BUILD_PROPERTIES, O3rComponent, StateSerializer, applicationMessageTarget, asyncEntitySerializer, asyncEntityWithStatusSerializer, asyncProps, asyncSerializer, asyncStoreItemAdapter, computeItemIdentifier, createEntityAsyncRequestAdapter, deepFill, filterMessageContent, fromApiEffectSwitchMap, fromApiEffectSwitchMapById, immutablePrimitive, isAsyncRequest, isCallAction, isIdentifiedCallAction, isObject, isOtterMessage, isProductionEnvironment, isToAppOtterMessage, lazyArray, otterComponentInfoPropertyName, otterMessageType, padNumber, sendOtterMessage };
export type { AppBuildConfiguration, AppRuntimeConfiguration, AsyncRequest, AsyncStoreItem, AsyncStoreItemAdapter, BaseContextOutput, BootstrapConfig, BuildTimeProperties, CategoryDescription, ClearOnFailurePayload, CommonContentMessages, ComponentType, ConfigPropertyWidget, ConfigPropertyWidgetParameters, ConfigType, Configurable, Configuration, ConfigurationValueType, ConnectContentMessage, ContentMessageData, Context, ContextInput, ContextualizationDataset, ContextualizationDevtoolsCommonOptions, CustomConfig, Dataset, DevtoolsCommonOptions, DevtoolsServiceInterface, DynamicConfigurable, DynamicConfigurableWithSignal, EntityAsyncRequestAdapter, EntityStatus, EntityWithStatus, EntityWithoutAsyncStoreItem, EventEmitterify, ExtractFromApiActionPayloadType, FailActionPayload, FailAsyncStoreItemEntitiesActionPayload, FailAsyncStoreItemEntityActionPayload, FailEntitiesActionPayload, FilterMessageToApplication, FromApiActionPayload, FromApiActionPayloadWithEntityId, Functionify, Idfy, InjectContentMessage, InterfaceOf, ItemIdentifier, Keep, LabelValue, LocalStateModel, Logger, MessageDataTypes, NestedConfiguration, OtterComponentInfo, OtterComponentInfoToProvide, OtterMessage, OtterMessageContent, Output, PrimitiveReviverMapper, RequestId, RequestMessagesContentMessage, RulesEngineAction, RulesEngineActionHandler, Serializer, SetActionPayload, SetAsyncStoreItemActionPayload, SetAsyncStoreItemEntitiesActionPayload, SetAsyncStoreItemEntityActionPayload, SetEntitiesActionPayload, SetEntityActionPayload, SetStateActionPayload, TemplateContext, Translation, UpdateActionPayload, UpdateAsyncStoreItemEntitiesActionPayload, UpdateAsyncStoreItemEntitiesActionPayloadWithId, UpdateAsyncStoreItemEntityActionPayload, UpdateAsyncStoreItemEntityActionPayloadWithId, UpdateEntitiesActionPayload, UpdateEntitiesActionPayloadWithId, UpdateEntityActionPayload, UpdateEntityActionPayloadWithId, WindowWithDevtools, WithRequestId };
//# sourceMappingURL=index.d.ts.map