New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@inglorious/store

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inglorious/store - npm Package Compare versions

Comparing version
9.3.1
to
9.4.0
+37
types/api.d.ts
import type {
BaseEntity,
EntitiesState,
EntityType,
Event,
Store,
TypesConfig,
} from "./store"
/**
* API object exposed to handlers
*/
export interface Api<
TEntity extends BaseEntity = BaseEntity,
TState extends EntitiesState<TEntity> = EntitiesState<TEntity>,
> {
getTypes: () => TypesConfig<TEntity>
getType: (typeName: string) => EntityType<TEntity>
setType: (typeName: string, type: EntityType<TEntity>) => void
getEntities: () => TState
getEntity: (id: string) => TEntity | undefined
select: <TResult>(selector: (state: TState) => TResult) => TResult
dispatch: (event: Event) => void
notify: (type: string, payload?: any) => void
[key: string]: any // For middleware extras
}
/**
* Creates an API object
*/
export function createApi<
TEntity extends BaseEntity = BaseEntity,
TState extends EntitiesState<TEntity> = EntitiesState<TEntity>,
>(
store: Store<TEntity, TState>,
extras?: Record<string, any>,
): Api<TEntity, TState>
+1
-1
{
"name": "@inglorious/store",
"version": "9.3.1",
"version": "9.4.0",
"description": "A state manager for real-time, collaborative apps, inspired by game development patterns and compatible with Redux.",

@@ -5,0 +5,0 @@ "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",

@@ -210,2 +210,3 @@ # Inglorious Store

api.getEntity(id) // access some other entity in read-only mode
api.select(selector) // run a selector against the whole state
api.notify(type, payload) // similar to dispatch. Yes, you can dispatch inside of a reducer!

@@ -495,2 +496,3 @@ api.dispatch(action) // optional, if you prefer Redux-style dispatching

- **`api.getEntity(id)`** - read one entity
- **`api.select(selector)`** - run a selector against the state
- **`api.notify(type, payload)`** - trigger other events (queued, not immediate)

@@ -753,2 +755,3 @@ - **`api.dispatch(action)`** - optional, if you prefer Redux-style dispatching

- `getEntity(id)`: Returns a specific entity by ID (frozen).
- `select(selector)`: Runs a selector against the entities.
- `dispatch(event)`: Records an event for later assertions.

@@ -886,3 +889,3 @@ - `notify(type, payload)`: A convenience wrapper around `dispatch`.

```js
const result = selectResult(api.getEntities())
const result = api.select(selectResult)
```

@@ -1108,2 +1111,3 @@

- `getEntity(id)` - single entity (read-only)
- `select(selector)` - run a selector against the state
- `notify(type, payload)` - trigger other events

@@ -1110,0 +1114,0 @@ - `dispatch(action)` - optional, if you prefer Redux-style dispatching

export function createApi(store, extras) {
return {
/**
* Retrieves all registered type definitions.
* @returns {Object}
*/
getTypes: store.getTypes,
/**
* Retrieves a specific type definition by name.
* @param {string} typeName
* @returns {Object}
*/
getType: store.getType,
/**
* Replaces a type definition at runtime.
* @param {string} typeName
* @param {Object} type
* @returns {void}
*/
setType: store.setType,
/**
* Retrieves the full entities state.
* @returns {Object}
*/
getEntities: store.getState,
/**
* Retrieves a single entity by ID.
* @param {string} id
* @returns {Object | undefined}
*/
getEntity: (id) => store.getState()[id],
/**
* Runs a selector against the current state.
*
* @template TResult
* @param {(state: object) => TResult} selector
* @returns {TResult}
*/
select: (selector) => selector(store.getState()),
/**
* Dispatches an event object to the store.
* @param {{ type: string, payload?: any }} event
* @returns {void}
*/
dispatch: store.dispatch,
/**
* Notifies the store of an event type and optional payload.
* @param {string} type
* @param {any} [payload]
* @returns {void}
*/
notify: store.notify,

@@ -10,0 +53,0 @@ ...extras,

@@ -16,2 +16,3 @@ import { create } from "mutative"

* - `getEntity(id)`: Returns a specific entity by ID (frozen)
* - `select(selector)`: Runs a selector against the entities
* - `dispatch(event)`: Records an event (for assertions)

@@ -46,2 +47,5 @@ * - `notify(type, payload)`: Convenience method that calls dispatch

},
select(selector) {
return selector(frozenEntities)
},
dispatch(event) {

@@ -48,0 +52,0 @@ events.push(event)

@@ -1,2 +0,3 @@

import { Api, BaseEntity } from "./store"
import { Api } from "./api"
import { BaseEntity } from "./store"

@@ -3,0 +4,0 @@ /**

@@ -0,1 +1,2 @@

export * from "./api"
export * from "./async"

@@ -2,0 +3,0 @@ export * from "./select"

@@ -0,1 +1,3 @@

import type { Api } from "./api"
/**

@@ -71,19 +73,2 @@ * Base entity structure

/**
* API object exposed to handlers
*/
export interface Api<
TEntity extends BaseEntity = BaseEntity,
TState extends EntitiesState<TEntity> = EntitiesState<TEntity>,
> {
getTypes: () => TypesConfig<TEntity>
getType: (typeName: string) => EntityType<TEntity>
setType: (typeName: string, type: EntityType<TEntity>) => void
getEntities: () => TState
getEntity: (id: string) => TEntity | undefined
dispatch: (event: Event) => void
notify: (type: string, payload?: any) => void
[key: string]: any // For middleware extras
}
/**
* Base store interface

@@ -139,24 +124,1 @@ */

>(config: StoreConfig<TEntity, TState>): Store<TEntity, TState>
/**
* Creates an API object
*/
export function createApi<
TEntity extends BaseEntity = BaseEntity,
TState extends EntitiesState<TEntity> = EntitiesState<TEntity>,
>(
store: Store<TEntity, TState>,
extras?: Record<string, any>,
): Api<TEntity, TState>
/**
* Helper to create a set of handlers for an async operation
*/
export function handleAsync<
TEntity extends BaseEntity = BaseEntity,
TPayload = any,
TResult = any,
>(
type: string,
handlers: AsyncHandlers<TEntity, TPayload, TResult>,
): EntityType<TEntity>

@@ -0,1 +1,3 @@

import type { BaseEntity, EntitiesState } from "./store"
/**

@@ -10,2 +12,3 @@ * Mock API for testing (subset of full API)

getEntity: (id: string) => TEntity | undefined
select: <TResult>(selector: (state: TState) => TResult) => TResult
dispatch: (event: Event) => void

@@ -12,0 +15,0 @@ notify: (type: string, payload?: any) => void