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

@pinia-orm/normalizr

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pinia-orm/normalizr - npm Package Compare versions

Comparing version 1.7.0 to 1.9.0

38

index.d.ts
declare namespace schema {
export type StrategyFunction<T> = (value: any, parent: any, key: string) => T;
export type SchemaFunction = (value: any, parent: any, key: string) => string;
export type MergeFunction = (entityA: any, entityB: any) => any;
export type StrategyFunction<T> = (value: any, parent: any, key: string) => T
export type SchemaFunction = (value: any, parent: any, key: string) => string
export type MergeFunction = (entityA: any, entityB: any) => any
export class Array<T = any> {
constructor(definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
define(definition: Schema): void
constructor (definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
define (definition: Schema): void
}

@@ -18,4 +18,4 @@

export class Entity<T = any> {
constructor(key: string | symbol, definition?: Schema, options?: EntityOptions<T>)
define(definition: Schema): void
constructor (key: string | symbol, definition?: Schema, options?: EntityOptions<T>)
define (definition: Schema): void
key: string

@@ -27,14 +27,14 @@ getId: SchemaFunction

export class Object<T = any> {
constructor(definition: SchemaObject<T>)
define(definition: Schema): void
constructor (definition: SchemaObject<T>)
define (definition: Schema): void
}
export class Union<T = any> {
constructor(definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
define(definition: Schema): void
constructor (definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
define (definition: Schema): void
}
export class Values<T = any> {
constructor(definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
define(definition: Schema): void
constructor (definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
define (definition: Schema): void
}

@@ -49,6 +49,6 @@ }

| SchemaObject<T>
| SchemaArray<T>;
| SchemaArray<T>
export type SchemaValueFunction<T> = (t: T) => Schema<T>;
export type SchemaValue<T> = Schema<T> | SchemaValueFunction<T>;
export type SchemaValueFunction<T> = (t: T) => Schema<T>
export type SchemaValue<T> = Schema<T> | SchemaValueFunction<T>

@@ -61,7 +61,7 @@ export interface SchemaObject<T> {

export type NormalizedSchema<E, R> = { entities: E, result: R };
export type NormalizedSchema<E, R> = { entities: E, result: R }
export function normalize<T = any, E = { [key:string]: { [key:string]: T } | undefined}, R = any>(
export function normalize<T = any, E = { [key: string]: { [key: string]: T } | undefined }, R = any> (
data: any,
schema: Schema<T>
): NormalizedSchema<E, R>;
): NormalizedSchema<E, R>
{
"name": "@pinia-orm/normalizr",
"version": "1.7.0",
"version": "1.9.0",
"description": "Normalizes JSON according to schema for Redux and Flux applications",

@@ -48,8 +48,9 @@ "bugs": {

"devDependencies": {
"@nuxt/eslint-config": "^0.3.10",
"@nuxtjs/eslint-config-typescript": "^12.1.0",
"@size-limit/preset-small-lib": "^9.0.0",
"eslint": "^8.49.0",
"immutable": "^4.3.4",
"size-limit": "^9.0.0",
"typescript": "^5.2.2",
"@size-limit/preset-small-lib": "^11.1.2",
"eslint": "^9.2.0",
"immutable": "^4.3.5",
"size-limit": "^11.1.2",
"typescript": "^5.4.5",
"unbuild": "^2.0.0"

@@ -69,5 +70,5 @@ },

"flow:ci": "flow check",
"lint": "eslint . --ext .js",
"lint:fix": "eslint . --fix --ext .js"
"lint": "eslint . --cache",
"lint:fix": "eslint . --cache --fix"
}
}

@@ -1,4 +0,96 @@

# normalizr
[![Pinia ORM banner](./.github/assets/banner.png)](https://github.com/storm-tail/pinia-orm)
This is a reduced version of [Normalizr](https://github.com/paularmstrong/normalizr) by Paul Armstrong.
Removed `denomalize` and `Schema.Values`.
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions CI][github-actions-ci-src]][github-actions-ci-href]
[![Coverage][code-coverage-src]][code-coverage-href]
[![License][license-src]][license-href]
# Welcome to pinia-orm
> Intuitive, type safe and flexible ORM for Pinia based on [Vuex ORM Next](https://github.com/vuex-orm/vuex-orm-next)
- [✨ &nbsp;Release Notes](https://pinia-orm.codedredd.de/changelog)
- [📖 &nbsp;Documentation](https://pinia-orm.codedredd.de)
- [👾 &nbsp;Playground](https://pinia-orm-play.codedredd.de)
## Migration from vuex-orm
You want to migrate from vuex to pinia and with it vuex-orm to pinia-orm but you don't know yet?
Well maybe this table will help you to decide. This comparison is just about facts and current state.
| Features | pinia-orm@v1.4.0 | @vuex-orm/core@0.36.4 | @vuex-orm/core@1.0.0-draft.16 |
|------------------------------------------------------------------------|------------------------------------------------------------| ----------------------------------------------------------------- | ------------------------------------------------------------------------- |
| Bundle Size (Min + GZIP) | [9.9 KB](https://bundlephobia.com/package/pinia-orm@1.4.0) | [16.7 KB](https://bundlephobia.com/package/@vuex-orm/core@0.36.4) | [12.6 KB](https://bundlephobia.com/package/@vuex-orm/core@1.0.0-draft.16) |
| Relations (hasMany, belongsTo, morphOne, hasManyBy, hasOne, morphTo) | ✅ | ✅ | ✅ |
| Relations (morphMany, belongsToMany, hasManyThrough) | ✅ | ✅ | ❌ |
| Relations (morphToMany, morphedByMany) | ❌ | ✅ | ❌ |
| Mutators | ✅ | ✅ | ❌ |
| Casts | ✅ | ❌ | ❌ |
| Decorators | ✅ | ❌ | ✅ |
| Single Table Inheritance | ✅ | ✅ | ❌ |
| Lifecycle Hooks | ✅ | ✅ | ❌ |
| Aggregates | ✅ | ✅ | ❌ |
| Query (orHas, doesntHave, orDoesntHave, whereHas, orWhereHas, groupBy) | ✅ | ❌ | ❌ |
| Collection Helpers | ✅ | (✅) can use pinia-orm helpers too | (✅) can use pinia-orm helpers too |
| Hidden Fields | ✅ | ❌ | ❌ |
| Metadata field | ✅ | ❌ | ❌ |
| Caching of queries with gc | ✅ | (✅) with plugin | ❌ |
If you decide to migrate then there are some breaking changes. A guide how to migrate will be written.
Small overview:
- Fields are by default `null`
- Renamed some functions aligning more with laravel naming
- Code is based on `vuex-orm-next` and not on `vuex-orm` !
## Help me keep working on this project 💚
- [Become a Sponsor on GitHub](https://github.com/sponsors/codedredd)
- [One-time donation via PayPal](https://paypal.me/dredd1984)
<p align="center">
<a href="https://pinia-orm.codedredd.de/sponsorkit/sponsors.png">
<img src='https://pinia-orm.codedredd.de/sponsorkit/sponsors.svg'/>
</a>
</p>
---
## 💻 Development
- Clone this repository
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10)
- Install dependencies using `pnpm install`
- Build normalizr package: `pnpm build`
- Run interactive tests using `cd packages/pinia-orm && pnpm test:ui`
## Credits
- [Kia King Ishii](https://github.com/kiaking)
- [Cuebit](https://github.com/cuebit)
- [Posva](https://github.com/posva)
## Related projects
- [Vuex ORM](https://github.com/vuex-orm/vuex-orm)
- [Vuex ORM Next](https://github.com/vuex-orm/vuex-orm-next)
## License
Made with ❤️
Published under [MIT License](./LICENCE).
<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/pinia-orm/latest.svg
[code-coverage-src]: https://img.shields.io/codecov/c/github/CodeDredd/pinia-orm?logo=Codecov&logoColor=white&token=BYLAJJOOLS
[code-coverage-href]: https://app.codecov.io/gh/CodeDredd/pinia-orm
[npm-version-href]: https://npmjs.com/package/pinia-orm
[npm-downloads-src]: https://img.shields.io/npm/dm/pinia-orm.svg
[npm-downloads-href]: https://npmjs.com/package/pinia-orm
[github-actions-ci-src]: https://github.com/codedredd/pinia-orm/actions/workflows/ci.yml/badge.svg
[github-actions-ci-href]: https://github.com/codedredd/pinia-orm/actions?query=workflow%3Aci
[license-src]: https://img.shields.io/npm/l/pinia-orm.svg
[license-href]: https://npmjs.com/package/pinia-orm
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