Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@acoustic-content-sdk/redux-utils
Advanced tools
Implementation of utility functions that help working with redux state.
One of the core principals of the redux pattern is to keep all state immutable. This implies that when updating a value we need to make a copy of the affected objects. The following functions help to limit the size of these copies.
The createUpdater
creates an wrapper around an object. This wrapper allows to set or remove (deep) properties of the wrapped object without mutating it. The updater makes sure to only create the minimum set of shallow copies.
Example:
const myObject={...};
const updater = createUpdater(myObject);
updater.set('elements.text.value', 'newValue');
const newObject = updater.get();
The updater works similar to immer but without the overhead.
During development it is important to verify that objects are not getting mutated. Use the invariance checker to test this, but make sure to not include these checks in production builds for performance reasons.
Example:
const inv = invarianceChecker(myObject);
// do some operations
// validate that myObject has not been mutated
assert(inv());
Home > @acoustic-content-sdk/redux-utils
Implementation of utility functions that help working with redux state.
Function | Description |
---|---|
createBreadcrumb(aId, aSelParent, aSelId) | Constructs a breadcrumb trail starting at a particular ID |
createUpdater(aValue, aLogSvc) | Constructs a function that updates one or more values in a json object. |
equalsByRevision(aLeft, aRight) | |
getNavSelectors(aJson$, aLogSvc) | Returns selectors that access parent and child nodes from a navigation structure |
invarianceChecker(aValue) | Creates a function that validates that an object has not changed. Note that this should only be used for debugging purposes, since it makes a deep copy of the value to test for the invariance |
isDraftId(aAuthoringId) | Tests if the authoring ID has a draft suffix |
isNotFromDataBase(aValue) | Tests if a value is not from a database |
isNotRoot(aId) | |
markAsFromDataBase(aValue) | Adds a key to the item marking it as coming from the local data base |
removeArrayItemByAccessor(aAccessor, aItem, aUser) | |
removeDataBaseMarker(aValue) | Removes the database marker from the object |
removeRecord() | Creates a reducer that removes a key from a record |
rxElementType(aTypeResolver, aLogSvc, aScheduler) | Resolves the element type, either directly from the element or from the authoring type |
rxLogDiff(aLogger) | |
rxResolveAuthoringItems(idOrItem, resolveItem, resolveAsset, aLogSvc, scheduler) | Resolves the item and all referenced items and assets |
selectByDeliveryId(aId) | Constructs a selector that validates that the ID is a delivery ID (not a draft ID) and selects based on that ID from the state |
serializeDiff(aOld, aNew, aSameStyle, aNewStyle, aDeletedStyle) | Serializes the differences between two JSON objects |
sortAuthoringItems(aResult) | Performs a topological sort on a set of resolved items |
updateGenericProperties(aItem, aUser) | Updates properties of the item that depend on the environment |
updateImageElement(aAccessor, aItem, aAsset) | |
updateRecord(aKey, aPredicate) | Creates a reducer that adds an item to a record |
updateSingleItem(aPredicate) | |
updateValueByAccessor(aAccessor, aValue, aItem, aUser) | Updates a single property based on the accessor expression. |
Interface | Description |
---|---|
ItemWithId | |
ItemWithLinkedDocId | |
ItemWithRevision | |
NavigationJson | |
NavSelectors | Interface that exposes selectors to the navigation structure |
ResolvedNode | |
Updater | Facade that offers the modification functions for a json object. The original JSON object will not be modified and the modified object will only contain the minimum number of modifications. |
Variable | Description |
---|---|
addToSetEpic | Constructs an epic that convers an ADD action to a SET action |
cloneAuthoringItems | Basically a re-export of the clone functionality to have it all clean inside this one function |
DB_KEY | |
DB_VALUE | |
ensureDraftId | Makes sure to end the ID with a draft suffix |
getDeliveryId | Returns the delivery ID from an authoring ID, i.e. strips off the ':draft' suffix from the ID |
getDeliveryIdFromAuthoringItem | Returns the delivery ID from an authoring item. |
getValueByAccessor | Retrieves a property value by accessor |
keyById | Extract the delivery ID of the draft |
ROOT_ID | |
selectClassification | Extracts the classification property |
updateItemsWithRevision |
Type Alias | Description |
---|---|
AddRecordReducer | Reducer function that adds an item to a record |
AuthoringItem | |
ItemReducer | Reducer function that updates an item |
RemoveRecordReducer | Reducer function that adds an item to a record |
ResolutionResult | |
ResolveAuthoringAsset | |
ResolveAuthoringContentItem |
Home > @acoustic-content-sdk/redux-utils > createBreadcrumb
Constructs a breadcrumb trail starting at a particular ID
Signature:
export declare function createBreadcrumb<T>(aId: string, aSelParent: UnaryFunction<string, Observable<T>>, aSelId: UnaryFunction<T, string>): Observable<T[]>;
Parameter | Type | Description |
---|---|---|
aId | string | the start ID |
aSelParent | UnaryFunction<string, Observable<T>> | selector function for the parent node |
aSelId | UnaryFunction<T, string> | selector function for the ID from a parent node |
Returns:
Observable<T[]>
the breadcrumb trail
Home > @acoustic-content-sdk/redux-utils > createUpdater
Constructs a function that updates one or more values in a json object.
Signature:
export declare function createUpdater<T>(aValue: T, aLogSvc?: LoggerService): Updater<T>;
Parameter | Type | Description |
---|---|---|
aValue | T | the JSON structure to update |
aLogSvc | LoggerService |
Returns:
Updater<T>
updater functions
Home > @acoustic-content-sdk/redux-utils > equalsByRevision
Signature:
export declare function equalsByRevision(aLeft: ItemWithRevision, aRight: ItemWithRevision): boolean;
Parameter | Type | Description |
---|---|---|
aLeft | ItemWithRevision | |
aRight | ItemWithRevision |
Returns:
boolean
Home > @acoustic-content-sdk/redux-utils > getNavSelectors
Returns selectors that access parent and child nodes from a navigation structure
Signature:
export declare function getNavSelectors(aJson$: Observable<NavigationJson>, aLogSvc?: LoggerService): NavSelectors;
Parameter | Type | Description |
---|---|---|
aJson$ | Observable<NavigationJson> | the JSON that represents the navigation |
aLogSvc | LoggerService | optional logger service |
Returns:
NavSelectors
the selectors
Home > @acoustic-content-sdk/redux-utils > invarianceChecker
Creates a function that validates that an object has not changed. Note that this should only be used for debugging purposes, since it makes a deep copy of the value to test for the invariance
Signature:
export declare function invarianceChecker(aValue: any): Generator<boolean>;
Parameter | Type | Description |
---|---|---|
aValue | any | the value to test |
Returns:
Generator<boolean>
the validator
Home > @acoustic-content-sdk/redux-utils > isDraftId
Tests if the authoring ID has a draft suffix
Signature:
export declare function isDraftId(aAuthoringId: string): boolean;
Parameter | Type | Description |
---|---|---|
aAuthoringId | string | the ID |
Returns:
boolean
true if we have a draft suffix, else false
Home > @acoustic-content-sdk/redux-utils > isNotFromDataBase
Tests if a value is not from a database
Signature:
export declare function isNotFromDataBase(aValue: any): boolean;
Parameter | Type | Description |
---|---|---|
aValue | any | the value |
Returns:
boolean
true if the value exists and if it is not from the database, else false
Home > @acoustic-content-sdk/redux-utils > isNotRoot
Signature:
export declare function isNotRoot(aId: string): boolean;
Parameter | Type | Description |
---|---|---|
aId | string |
Returns:
boolean
Home > @acoustic-content-sdk/redux-utils > markAsFromDataBase
Adds a key to the item marking it as coming from the local data base
Signature:
export declare function markAsFromDataBase<T>(aValue: T): T;
Parameter | Type | Description |
---|---|---|
aValue | T | the value to work with |
Returns:
T
a value with the marker
Home > @acoustic-content-sdk/redux-utils > removeArrayItemByAccessor
Signature:
export declare function removeArrayItemByAccessor<T extends BaseAuthoringItem>(aAccessor: AccessorType, aItem: T, aUser?: User): Updater<T>;
Parameter | Type | Description |
---|---|---|
aAccessor | AccessorType | |
aItem | T | |
aUser | User |
Returns:
Updater<T>
Home > @acoustic-content-sdk/redux-utils > removeDataBaseMarker
Removes the database marker from the object
Signature:
export declare function removeDataBaseMarker<T>(aValue: T): T;
Parameter | Type | Description |
---|---|---|
aValue | T | the value to work with |
Returns:
T
a value without the marker
Home > @acoustic-content-sdk/redux-utils > removeRecord
Creates a reducer that removes a key from a record
Signature:
export declare function removeRecord<T>(): RemoveRecordReducer<T>;
Returns:
RemoveRecordReducer<T>
the reducer
Home > @acoustic-content-sdk/redux-utils > rxElementType
Resolves the element type, either directly from the element or from the authoring type
Signature:
export declare function rxElementType(aTypeResolver: UnaryFunction<string, Observable<AuthoringType>>, aLogSvc?: LoggerService, aScheduler?: SchedulerLike): UnaryFunction<AccessorType, OperatorFunction<RenderingContext, ELEMENT_TYPE>>;
Parameter | Type | Description |
---|---|---|
aTypeResolver | UnaryFunction<string, Observable<AuthoringType>> | |
aLogSvc | LoggerService | logger service |
aScheduler | SchedulerLike | optional scheduler |
Returns:
UnaryFunction<AccessorType, OperatorFunction<RenderingContext, ELEMENT_TYPE>>
the resolved type or undefined if the type could not be determined
Home > @acoustic-content-sdk/redux-utils > rxLogDiff
Signature:
export declare function rxLogDiff<T>(aLogger: Logger): MonoTypeOperatorFunction<T>;
Parameter | Type | Description |
---|---|---|
aLogger | Logger |
Returns:
MonoTypeOperatorFunction<T>
Home > @acoustic-content-sdk/redux-utils > rxResolveAuthoringItems
Resolves the item and all referenced items and assets
Signature:
export declare function rxResolveAuthoringItems(idOrItem: IdOrItem, resolveItem: ResolveAuthoringContentItem, resolveAsset: ResolveAuthoringAsset, aLogSvc?: LoggerService, scheduler?: SchedulerLike): Observable<ResolutionResult>;
Parameter | Type | Description |
---|---|---|
idOrItem | IdOrItem | |
resolveItem | ResolveAuthoringContentItem | callback to resolve a content item |
resolveAsset | ResolveAuthoringAsset | callback to resolve an asset |
aLogSvc | LoggerService | |
scheduler | SchedulerLike | scheduler for recursive calls |
Returns:
Observable<ResolutionResult>
the observable containing the resolution result
Home > @acoustic-content-sdk/redux-utils > selectByDeliveryId
Constructs a selector that validates that the ID is a delivery ID (not a draft ID) and selects based on that ID from the state
Signature:
export declare function selectByDeliveryId<T>(aId?: string): UnaryFunction<Record<string, T>, T>;
Parameter | Type | Description |
---|---|---|
aId | string | the ID |
Returns:
UnaryFunction<Record<string, T>, T>
a selector for that ID based on some state
Home > @acoustic-content-sdk/redux-utils > serializeDiff
Serializes the differences between two JSON objects
Signature:
export declare function serializeDiff(aOld: any, aNew: any, aSameStyle?: UnaryFunction<string, string>, aNewStyle?: UnaryFunction<string, string>, aDeletedStyle?: UnaryFunction<string, string>): string;
Parameter | Type | Description |
---|---|---|
aOld | any | old object |
aNew | any | new objects |
aSameStyle | UnaryFunction<string, string> | styling callback for identical style |
aNewStyle | UnaryFunction<string, string> | styling callback for new style |
aDeletedStyle | UnaryFunction<string, string> | styling callback for deleted style |
Returns:
string
the serialized string
Home > @acoustic-content-sdk/redux-utils > sortAuthoringItems
Performs a topological sort on a set of resolved items
Signature:
export declare function sortAuthoringItems(aResult: ResolutionResult): AuthoringItem[];
Parameter | Type | Description |
---|---|---|
aResult | ResolutionResult | the resolution result, basically a graph of nodes |
Returns:
AuthoringItem[]
the items in toplogical order, i.e. parents before children
Home > @acoustic-content-sdk/redux-utils > updateGenericProperties
Updates properties of the item that depend on the environment
Signature:
export declare function updateGenericProperties<T extends BaseAuthoringItem>(aItem: Updater<T>, aUser?: User): Updater<T>;
Parameter | Type | Description |
---|---|---|
aItem | Updater<T> | updater for the item |
aUser | User | optionally the current user |
Returns:
Updater<T>
the updater after the item has been modified
Home > @acoustic-content-sdk/redux-utils > updateImageElement
Signature:
export declare function updateImageElement(aAccessor: AccessorType, aItem: Updater<AuthoringContentItem>, aAsset: AuthoringAsset): Updater<AuthoringContentItem>;
Parameter | Type | Description |
---|---|---|
aAccessor | AccessorType | |
aItem | Updater<AuthoringContentItem> | |
aAsset | AuthoringAsset |
Returns:
Updater<AuthoringContentItem>
Home > @acoustic-content-sdk/redux-utils > updateRecord
Creates a reducer that adds an item to a record
Signature:
export declare function updateRecord<T>(aKey: UnaryFunction<T, string>, aPredicate?: EqualsPredicate<T>): AddRecordReducer<T>;
Parameter | Type | Description |
---|---|---|
aKey | UnaryFunction<T, string> | function to extract the key from the item |
aPredicate | EqualsPredicate<T> | predicate to check if two items are equal |
Returns:
AddRecordReducer<T>
the reducer
Home > @acoustic-content-sdk/redux-utils > updateSingleItem
Signature:
export declare function updateSingleItem<T>(aPredicate?: EqualsPredicate<T>): ItemReducer<T>;
Parameter | Type | Description |
---|---|---|
aPredicate | EqualsPredicate<T> |
Returns:
ItemReducer<T>
Home > @acoustic-content-sdk/redux-utils > updateValueByAccessor
Updates a single property based on the accessor expression.
Signature:
export declare function updateValueByAccessor<T extends BaseAuthoringItem>(aAccessor: AccessorType, aValue: any, aItem: T, aUser?: User): Updater<T>;
Parameter | Type | Description |
---|---|---|
aAccessor | AccessorType | the accessor expression that points |
aValue | any | the new value |
aItem | T | the item to update |
aUser | User |
Returns:
Updater<T>
a copy of the item with the modified value
Home > @acoustic-content-sdk/redux-utils > ItemWithId
Signature:
export interface ItemWithId
Property | Type | Description |
---|---|---|
id | string |
Home > @acoustic-content-sdk/redux-utils > ItemWithLinkedDocId
Signature:
export interface ItemWithLinkedDocId
Property | Type | Description |
---|---|---|
id | string | |
linkedDocId | string |
Home > @acoustic-content-sdk/redux-utils > ItemWithRevision
Signature:
export interface ItemWithRevision extends ItemWithId
Property | Type | Description |
---|---|---|
rev | string |
Home > @acoustic-content-sdk/redux-utils > NavigationJson
Signature:
export interface NavigationJson
Property | Type | Description |
---|---|---|
children | NavigationJson[] | |
id | string |
Home > @acoustic-content-sdk/redux-utils > NavSelectors
Interface that exposes selectors to the navigation structure
Signature:
export interface NavSelectors
Property | Type | Description |
---|---|---|
root | string | ID of the (virtual) root item of the navigation |
selectChildren | UnaryFunction<string, Observable<string[]>> | Selects the children of a particular item |
selectParent | UnaryFunction<string, Observable<string>> | Selects the parent of a particular item |
Home > @acoustic-content-sdk/redux-utils > ResolvedNode
Signature:
export interface ResolvedNode<T>
Property | Type | Description |
---|---|---|
id | string | |
item | T | |
parentId | string |
Home > @acoustic-content-sdk/redux-utils > Updater
Facade that offers the modification functions for a json object. The original JSON object will not be modified and the modified object will only contain the minimum number of modifications.
Signature:
export interface Updater<T>
Property | Type | Description |
---|---|---|
add | BiFunction<string, any, T> | Inserts a new value into an array pointed to by the accessor. All values across the parent path will be cloned (shallow) if they do not have a clone, yet.Pass undefined as the new value to delete the value.Returns the modified version of the top level object. |
del | UnaryFunction<string, T> | Removes the value pointed to by the accessor. All values across the parent path will be cloned (shallow) if they do not have a clone, yet.Returns the modified version of the top level object. |
get | Generator<T> | Returns the top level, modified object |
set | BiFunction<string, any, T> | Replaces the value pointed to by the accessor with a new value. All values across the parent path will be cloned (shallow) if they do not have a clone, yet.Pass undefined as the new value to delete the value.Returns the modified version of the top level object. |
Home > @acoustic-content-sdk/redux-utils > addToSetEpic
Constructs an epic that convers an ADD
action to a SET
action
Signature:
addToSetEpic: <T>(aAddAction: string, aSetAction: string) => Epic<any, any, any, any>
Home > @acoustic-content-sdk/redux-utils > cloneAuthoringItems
Basically a re-export of the clone functionality to have it all clean inside this one function
Signature:
cloneAuthoringItems: UnaryFunction<AuthoringItem[], AuthoringItem[]>
Home > @acoustic-content-sdk/redux-utils > DB_KEY
Signature:
DB_KEY = "ecec4405-7fb1-4b86-8d27-7338eea45683"
Home > @acoustic-content-sdk/redux-utils > DB_VALUE
Signature:
DB_VALUE = "e3257dbc-1ca8-4d57-94a2-37934960f39f"
Home > @acoustic-content-sdk/redux-utils > ensureDraftId
Makes sure to end the ID with a draft suffix
Signature:
ensureDraftId: (aAuthoringId: string) => string
Home > @acoustic-content-sdk/redux-utils > getDeliveryId
Returns the delivery ID from an authoring ID, i.e. strips off the ':draft' suffix from the ID
Signature:
getDeliveryId: UnaryFunction<string, string>
Home > @acoustic-content-sdk/redux-utils > getDeliveryIdFromAuthoringItem
Returns the delivery ID from an authoring item.
Signature:
getDeliveryIdFromAuthoringItem: UnaryFunction<ItemWithLinkedDocId | BaseAuthoringItem, string>
Home > @acoustic-content-sdk/redux-utils > getValueByAccessor
Retrieves a property value by accessor
Signature:
getValueByAccessor: <T>(aItem: BaseAuthoringItem, aAccessor: string) => T
Home > @acoustic-content-sdk/redux-utils > keyById
Extract the delivery ID of the draft
Signature:
keyById: UnaryFunction<ItemWithLinkedDocId, string>
Home > @acoustic-content-sdk/redux-utils > ROOT_ID
Signature:
ROOT_ID: string
Home > @acoustic-content-sdk/redux-utils > selectClassification
Extracts the classification property
Signature:
selectClassification: UnaryFunction<BaseAuthoringItem | ContentItem, string>
Home > @acoustic-content-sdk/redux-utils > updateItemsWithRevision
Signature:
updateItemsWithRevision: <T extends ItemWithRevision>(aState: Record<string, T>, aItem: T) => Record<string, T>
Home > @acoustic-content-sdk/redux-utils > AddRecordReducer
Reducer function that adds an item to a record
Signature:
export declare type AddRecordReducer<T> = BiFunction<Record<string, T>, T, Record<string, T>>;
Home > @acoustic-content-sdk/redux-utils > AuthoringItem
Signature:
export declare type AuthoringItem = AuthoringContentItem | AuthoringAsset;
Home > @acoustic-content-sdk/redux-utils > ItemReducer
Reducer function that updates an item
Signature:
export declare type ItemReducer<T> = BiFunction<T, T, T>;
Home > @acoustic-content-sdk/redux-utils > RemoveRecordReducer
Reducer function that adds an item to a record
Signature:
export declare type RemoveRecordReducer<T> = BiFunction<Record<string, T>, string, Record<string, T>>;
Home > @acoustic-content-sdk/redux-utils > ResolutionResult
Signature:
export declare type ResolutionResult = Record<string, ResolvedNode<AuthoringItem>>;
Home > @acoustic-content-sdk/redux-utils > ResolveAuthoringAsset
Signature:
export declare type ResolveAuthoringAsset = UnaryFunction<string, Observable<AuthoringAsset>>;
Home > @acoustic-content-sdk/redux-utils > ResolveAuthoringContentItem
Signature:
export declare type ResolveAuthoringContentItem = UnaryFunction<string, Observable<AuthoringContentItem>>;
Home > @acoustic-content-sdk/redux-utils > ItemWithId > id
Signature:
id?: string;
Home > @acoustic-content-sdk/redux-utils > NavigationJson > children
Signature:
children?: NavigationJson[];
Home > @acoustic-content-sdk/redux-utils > NavigationJson > id
Signature:
id: string;
Home > @acoustic-content-sdk/redux-utils > ItemWithRevision > rev
Signature:
rev?: string;
Home > @acoustic-content-sdk/redux-utils > ItemWithLinkedDocId > id
Signature:
readonly id?: string;
Home > @acoustic-content-sdk/redux-utils > ItemWithLinkedDocId > linkedDocId
Signature:
readonly linkedDocId?: string;
Home > @acoustic-content-sdk/redux-utils > ResolvedNode > id
Signature:
id: string;
Home > @acoustic-content-sdk/redux-utils > ResolvedNode > item
Signature:
item: T;
Home > @acoustic-content-sdk/redux-utils > ResolvedNode > parentId
Signature:
parentId?: string;
Home > @acoustic-content-sdk/redux-utils > NavSelectors > root
ID of the (virtual) root item of the navigation
Signature:
root: string;
Home > @acoustic-content-sdk/redux-utils > NavSelectors > selectChildren
Selects the children of a particular item
Signature:
selectChildren: UnaryFunction<string, Observable<string[]>>;
Home > @acoustic-content-sdk/redux-utils > NavSelectors > selectParent
Selects the parent of a particular item
Signature:
selectParent: UnaryFunction<string, Observable<string>>;
Home > @acoustic-content-sdk/redux-utils > Updater > add
Inserts a new value into an array pointed to by the accessor. All values across the parent path will be cloned (shallow) if they do not have a clone, yet.
Pass undefined
as the new value to delete the value.
Returns the modified version of the top level object.
Signature:
add: BiFunction<string, any, T>;
Home > @acoustic-content-sdk/redux-utils > Updater > del
Removes the value pointed to by the accessor. All values across the parent path will be cloned (shallow) if they do not have a clone, yet.
Returns the modified version of the top level object.
Signature:
del: UnaryFunction<string, T>;
Home > @acoustic-content-sdk/redux-utils > Updater > get
Returns the top level, modified object
Signature:
get: Generator<T>;
Home > @acoustic-content-sdk/redux-utils > Updater > set
Replaces the value pointed to by the accessor with a new value. All values across the parent path will be cloned (shallow) if they do not have a clone, yet.
Pass undefined
as the new value to delete the value.
Returns the modified version of the top level object.
Signature:
set: BiFunction<string, any, T>;
FAQs
> TODO: description
We found that @acoustic-content-sdk/redux-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.