Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mobx-keystone

Package Overview
Dependencies
Maintainers
1
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-keystone - npm Package Compare versions

Comparing version 0.58.0 to 0.58.1

4

CHANGELOG.md
# Change Log
## 0.58.1
- Fixed an issue where `idProp` on the base was not being picked up by `ExtendedModel`.
## 0.58.0

@@ -4,0 +8,0 @@

2

dist/model/BaseModel.d.ts

@@ -23,3 +23,3 @@ import type { O } from "ts-toolbelt";

[k: string]: any;
}, ModelIdPropertyName extends string = never> {
}, ModelIdPropertyName extends string = typeof modelIdKey> {
[dataTypeSymbol]: Data;

@@ -26,0 +26,0 @@ [creationDataTypeSymbol]: CreationData;

import type { AbstractModelClass } from "../modelShared/BaseModelShared";
import { idProp, ModelProps, ModelPropsToCreationData, ModelPropsToData, ModelPropsToSetter } from "../modelShared/prop";
import type { AnyModel, BaseModel, BaseModelKeys } from "./BaseModel";
import type { AnyModel, BaseModel, BaseModelKeys, ModelIdPropertyName } from "./BaseModel";
export declare type _ComposedCreationData<SuperModel, TProps extends ModelProps> = SuperModel extends BaseModel<any, infer CD, any> ? ModelPropsToCreationData<TProps> & CD : ModelPropsToCreationData<TProps>;
export declare type _ModelId<SuperModel, TProps extends ModelProps> = SuperModel extends AnyModel ? ModelIdPropertyName<SuperModel> : ExtractModelIdProp<TProps> & string;
export interface _Model<SuperModel, TProps extends ModelProps> {
new (data: _ComposedCreationData<SuperModel, TProps>): SuperModel & BaseModel<ModelPropsToData<TProps>, ModelPropsToCreationData<TProps>, ExtractModelIdProp<TProps> & string> & Omit<ModelPropsToData<TProps>, BaseModelKeys> & ModelPropsToSetter<TProps>;
new (data: _ComposedCreationData<SuperModel, TProps>): SuperModel & BaseModel<ModelPropsToData<TProps>, ModelPropsToCreationData<TProps>, _ModelId<SuperModel, TProps>> & Omit<ModelPropsToData<TProps>, BaseModelKeys> & ModelPropsToSetter<TProps>;
}

@@ -33,3 +34,3 @@ /**

props: TProps;
}, modelOptions?: ModelOptions): _Model<TModel, AddModelIdPropIfNeeded<TProps>>;
}, modelOptions?: ModelOptions): _Model<TModel, TProps>;
/**

@@ -45,3 +46,3 @@ * Base abstract class for models that extends another model.

*/
export declare function ExtendedModel<TProps extends ModelProps, TModel extends AnyModel>(baseModel: AbstractModelClass<TModel>, modelProps: TProps, modelOptions?: ModelOptions): _Model<TModel, AddModelIdPropIfNeeded<TProps>>;
export declare function ExtendedModel<TProps extends ModelProps, TModel extends AnyModel>(baseModel: AbstractModelClass<TModel>, modelProps: TProps, modelOptions?: ModelOptions): _Model<TModel, TProps>;
/**

@@ -48,0 +49,0 @@ * Base abstract class for models.

{
"name": "mobx-keystone",
"version": "0.58.0",
"version": "0.58.1",
"description": "A MobX powered state management solution based on data trees with first class support for Typescript, snapshots, patches and much more",

@@ -5,0 +5,0 @@ "keywords": [

@@ -40,3 +40,3 @@ import { observable } from "mobx"

CreationData extends { [k: string]: any },
ModelIdPropertyName extends string = never
ModelIdPropertyName extends string = typeof modelIdKey
> {

@@ -43,0 +43,0 @@ // just to make typing work properly

@@ -10,3 +10,3 @@ import type { AbstractModelClass, ModelClass } from "../modelShared/BaseModelShared"

} from "../modelShared/prop"
import type { AnyModel, BaseModel, BaseModelKeys } from "./BaseModel"
import type { AnyModel, BaseModel, BaseModelKeys, ModelIdPropertyName } from "./BaseModel"
import { assertIsModelClass, isModelClass } from "./utils"

@@ -21,2 +21,6 @@

export type _ModelId<SuperModel, TProps extends ModelProps> = SuperModel extends AnyModel
? ModelIdPropertyName<SuperModel>
: ExtractModelIdProp<TProps> & string
export interface _Model<SuperModel, TProps extends ModelProps> {

@@ -27,3 +31,3 @@ new (data: _ComposedCreationData<SuperModel, TProps>): SuperModel &

ModelPropsToCreationData<TProps>,
ExtractModelIdProp<TProps> & string
_ModelId<SuperModel, TProps>
> &

@@ -68,3 +72,3 @@ Omit<ModelPropsToData<TProps>, BaseModelKeys> &

modelOptions?: ModelOptions
): _Model<TModel, AddModelIdPropIfNeeded<TProps>>
): _Model<TModel, TProps>

@@ -85,3 +89,3 @@ /**

modelOptions?: ModelOptions
): _Model<TModel, AddModelIdPropIfNeeded<TProps>>
): _Model<TModel, TProps>

@@ -91,3 +95,3 @@ // base

...args: any[]
): _Model<TModel, AddModelIdPropIfNeeded<TProps>> {
): _Model<TModel, TProps> {
let baseModel

@@ -94,0 +98,0 @@ let modelProps

@@ -88,2 +88,6 @@ import { applySet } from "../action/applySet"

const idGenerator = () => getGlobalConfig().modelIdGenerator()
const tPropForId = tProp(typesString, idGenerator)
const propForId = prop(idGenerator)
export function sharedInternalModel<

@@ -131,3 +135,6 @@ TProps extends ModelProps,

// look for id keys
const idKeys = Object.keys(composedModelProps).filter((k) => composedModelProps[k] === idProp)
const idKeys = Object.keys(composedModelProps).filter((k) => {
const p = composedModelProps[k]
return p === idProp || p === propForId || p === tPropForId
})
if (type === "class") {

@@ -163,6 +170,3 @@ if (idKeys.length > 1) {

idKey = idKeys[0]
const idGenerator = () => getGlobalConfig().modelIdGenerator()
composedModelProps[idKey] = needsTypeChecker
? tProp(typesString, idGenerator)
: prop(idGenerator)
composedModelProps[idKey] = needsTypeChecker ? tPropForId : propForId
}

@@ -169,0 +173,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc