Comparing version 0.9.12 to 0.10.0
@@ -1,4 +0,4 @@ | ||
import { IRawModel } from 'datx-utils'; | ||
import { Collection } from './Collection'; | ||
import { CompatModel } from './CompatModel'; | ||
import { IRawCollection } from './interfaces/IRawCollection'; | ||
export declare class CompatCollection extends Collection { | ||
@@ -8,3 +8,3 @@ static types: (typeof CompatModel)[]; | ||
readonly static: typeof CompatCollection; | ||
toJS(): IRawModel[]; | ||
toJS(): IRawCollection; | ||
} |
@@ -16,3 +16,6 @@ export declare const UNDEFINED_TYPE = "The type needs to be defined if the object is not an instance of the model."; | ||
export declare const MODEL_REQUIRED = "The model type is a required parameter. Do you maybe have a circular dependency?"; | ||
export declare const SORTED_NO_WRITE = "New models can't be added directly to a sorted view list"; | ||
export declare const UNIQUE_MODEL = "The models in this view need to be unique"; | ||
export declare const VIEW_NAME_TAKEN = "The name is already taken"; | ||
export declare const DECORATE_MODEL = "This mixin can only decorate models"; | ||
export declare const DECORATE_COLLECTION = "This mixin can only decorate collections"; |
@@ -0,3 +1,7 @@ | ||
import { ICollectionConstructor } from '../interfaces/ICollectionConstructor'; | ||
import { IModelConstructor } from '../interfaces/IModelConstructor'; | ||
import { IViewConstructor } from '../interfaces/IViewConstructor'; | ||
import { PureCollection } from '../PureCollection'; | ||
import { PureModel } from '../PureModel'; | ||
import { View } from '../View'; | ||
/** | ||
@@ -10,3 +14,3 @@ * Check if a class is a model | ||
*/ | ||
export declare function isModel(obj: typeof PureModel): true; | ||
export declare function isModel(obj: typeof PureModel | IModelConstructor<any>): true; | ||
export declare function isModel(obj: any): false; | ||
@@ -20,3 +24,12 @@ /** | ||
*/ | ||
export declare function isCollection(obj: typeof PureCollection): true; | ||
export declare function isCollection(obj: typeof PureCollection | ICollectionConstructor<any>): true; | ||
export declare function isCollection(obj: any): false; | ||
/** | ||
* Check if a class is a collection | ||
* | ||
* @export | ||
* @param {any} obj Class to check | ||
* @returns {boolean} Class is a collection | ||
*/ | ||
export declare function isView(obj: typeof View | IViewConstructor<any, any>): true; | ||
export declare function isView(obj: any): false; |
export { Collection } from './Collection'; | ||
export { Model } from './Model'; | ||
export { View } from './View'; | ||
export { PureCollection } from './PureCollection'; | ||
@@ -10,3 +11,3 @@ export { PureModel } from './PureModel'; | ||
export { assignModel, cloneModel, getModelCollection, getModelId, getModelMetaKey, getModelType, getOriginalModel, modelToJSON, setModelMetaKey, updateModel } from './helpers/model/utils'; | ||
export { isCollection, isModel } from './helpers/mixin'; | ||
export { isCollection, isModel, isView } from './helpers/mixin'; | ||
export { IRawModel } from 'datx-utils'; | ||
@@ -17,2 +18,3 @@ export { ICollectionConstructor } from './interfaces/ICollectionConstructor'; | ||
export { IType } from './interfaces/IType'; | ||
export { IViewConstructor } from './interfaces/IViewConstructor'; | ||
export { IActionsMixin } from './interfaces/IActionsMixin'; | ||
@@ -19,0 +21,0 @@ export { IMetaMixin } from './interfaces/IMetaMixin'; |
@@ -1,8 +0,15 @@ | ||
import { IRawModel } from 'datx-utils'; | ||
import { IDictionary, IRawModel } from 'datx-utils'; | ||
import { PureCollection } from '../PureCollection'; | ||
import { PureModel } from '../PureModel'; | ||
import { IModelConstructor } from './IModelConstructor'; | ||
import { IType } from './IType'; | ||
export interface ICollectionConstructor<T = PureCollection> { | ||
types: Array<typeof PureModel | IModelConstructor<PureModel>>; | ||
views: IDictionary<{ | ||
modelType: IType | PureModel; | ||
sortMethod?: string | ((PureModel) => any); | ||
unique?: boolean; | ||
mixins?: Array<(view: any) => any>; | ||
}>; | ||
new (data?: Array<IRawModel>): T; | ||
} |
import { IDictionary, IRawModel } from 'datx-utils'; | ||
import { IIdentifier } from './interfaces/IIdentifier'; | ||
import { IModelConstructor } from './interfaces/IModelConstructor'; | ||
import { IRawCollection } from './interfaces/IRawCollection'; | ||
import { IType } from './interfaces/IType'; | ||
@@ -16,7 +17,14 @@ import { TFilterFn } from './interfaces/TFilterFn'; | ||
static types: Array<typeof PureModel | IModelConstructor<PureModel>>; | ||
static views: IDictionary<{ | ||
modelType: IType | PureModel; | ||
sortMethod?: string | ((PureModel) => any); | ||
unique?: boolean; | ||
mixins?: Array<(view: any) => any>; | ||
}>; | ||
static defaultModel?: typeof PureModel; | ||
private __data; | ||
private __views; | ||
private __dataMap; | ||
private __dataList; | ||
constructor(data?: Array<IRawModel>); | ||
constructor(data?: Array<IRawModel> | IRawCollection); | ||
/** | ||
@@ -142,7 +150,7 @@ * Function for inserting raw models into the collection. Used when hydrating the collection | ||
* | ||
* @returns {Array<IRawModel>} Pure JS value of the collection | ||
* @returns {IRawCollection} Pure JS value of the collection | ||
* @memberof Collection | ||
*/ | ||
toJSON(): Array<IRawModel>; | ||
readonly snapshot: IRawModel[]; | ||
toJSON(): IRawCollection; | ||
readonly snapshot: IRawCollection; | ||
/** | ||
@@ -155,2 +163,23 @@ * Reset the collection (remove all models) | ||
getAllModels(): PureModel[]; | ||
/** | ||
* Add a view to the collection | ||
* | ||
* @template T Model type of the view | ||
* @param {string} name View name | ||
* @param {(IModelConstructor<T>|IType)} type Model type the view will represent | ||
* @param {({ | ||
* sortMethod?: string|((item: T) => any), | ||
* models?: Array<IIdentifier|PureModel>, | ||
* unique?: boolean, | ||
* mixins?: Array<(view: any) => any>, | ||
* })} [{sortMethod, models, unique, mixins}={}] View options | ||
* @returns {View} The created view | ||
* @memberof PureCollection | ||
*/ | ||
addView<T extends PureModel = PureModel>(name: string, type: IModelConstructor<T> | IType, {sortMethod, models, unique, mixins}?: { | ||
sortMethod?: string | ((item: T) => any); | ||
models?: Array<IIdentifier | T>; | ||
unique?: boolean; | ||
mixins?: Array<(view: any) => any>; | ||
}): any; | ||
private __addArray<T>(data); | ||
@@ -157,0 +186,0 @@ private __addArray<T>(data, model?); |
{ | ||
"name": "datx", | ||
"version": "0.9.12", | ||
"version": "0.10.0", | ||
"description": "A MobX data store", | ||
"main": "dist/index.js", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"typings": "dist/index.d.ts", | ||
@@ -20,12 +21,12 @@ "sideEffects": false, | ||
"@infinumjs/tslint-config": "^1.1.1", | ||
"@types/jest": "^22.2.0", | ||
"@types/node": "^9.4.7", | ||
"jest": "^22.4.2", | ||
"mobx": "^4.1.0", | ||
"@types/jest": "^22.2.2", | ||
"@types/node": "^9.6.1", | ||
"jest": "^22.4.3", | ||
"mobx": "^4.1.1", | ||
"rollup": "^0.57.1", | ||
"rollup-plugin-typescript2": "^0.12.0", | ||
"rollup-plugin-uglify": "^3.0.0", | ||
"ts-jest": "^22.4.1", | ||
"ts-jest": "^22.4.2", | ||
"tslint": "^5.9.1", | ||
"typescript": "^2.7.2" | ||
"typescript": "^2.8.1" | ||
}, | ||
@@ -60,4 +61,4 @@ "peerDependencies": { | ||
"dependencies": { | ||
"datx-utils": "^0.9.10" | ||
"datx-utils": "^0.10.0" | ||
} | ||
} |
@@ -50,2 +50,9 @@ # datx | ||
### Polyfilling | ||
The lib makes use of the following features that are not yet available everywhere. Based on your browser support, you might want to polyfill them: | ||
* [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) | ||
* [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) | ||
## Concepts | ||
@@ -74,2 +81,3 @@ | ||
* [Model](https://github.com/infinum/datx/wiki/Model) | ||
* [View](https://github.com/infinum/datx/wiki/View) | ||
* [prop](https://github.com/infinum/datx/wiki/prop) | ||
@@ -76,0 +84,0 @@ * [PureModel](https://github.com/infinum/datx/wiki/PureModel) |
import typescript from 'rollup-plugin-typescript2'; | ||
import uglify from 'rollup-plugin-uglify'; | ||
import pkg from './package.json'; | ||
export default { | ||
input: './src/index.ts', | ||
output: { | ||
file: './dist/index.js', | ||
format: 'umd', | ||
name: 'datx', | ||
}, | ||
output: [ | ||
{ file: pkg.main, format: 'cjs' }, | ||
{ file: pkg.module, format: 'es' }, | ||
], | ||
plugins: [ | ||
@@ -13,0 +13,0 @@ typescript({ |
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 not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1659501
411
2170
109
+ Addeddatx-utils@0.10.6(transitive)
- Removeddatx-utils@0.9.10(transitive)
Updateddatx-utils@^0.10.0