@ngrx-traits/core 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/bundles/ngrx-traits-core-testing.umd.js +52 -0
- package/bundles/ngrx-traits-core-testing.umd.js.map +1 -0
- package/bundles/ngrx-traits-core.umd.js +1212 -0
- package/bundles/ngrx-traits-core.umd.js.map +1 -0
- package/cache/cache.actions.d.ts +29 -0
- package/cache/cache.models.d.ts +20 -0
- package/cache/cache.module.d.ts +7 -0
- package/cache/cache.reducer.d.ts +3 -0
- package/cache/cache.selectors.d.ts +3 -0
- package/cache/cache.service.d.ts +65 -0
- package/cache/index.d.ts +17 -0
- package/create-entity-feature.d.ts +59 -0
- package/esm2015/cache/cache.actions.js +6 -0
- package/esm2015/cache/cache.actions.js.map +1 -0
- package/esm2015/cache/cache.models.js +31 -0
- package/esm2015/cache/cache.models.js.map +1 -0
- package/esm2015/cache/cache.module.js +18 -0
- package/esm2015/cache/cache.module.js.map +1 -0
- package/esm2015/cache/cache.reducer.js +141 -0
- package/esm2015/cache/cache.reducer.js.map +1 -0
- package/esm2015/cache/cache.selectors.js +5 -0
- package/esm2015/cache/cache.selectors.js.map +1 -0
- package/esm2015/cache/cache.service.js +72 -0
- package/esm2015/cache/cache.service.js.map +1 -0
- package/esm2015/cache/index.js +7 -0
- package/esm2015/cache/index.js.map +1 -0
- package/esm2015/create-entity-feature.js +283 -0
- package/esm2015/create-entity-feature.js.map +1 -0
- package/esm2015/index.js +7 -0
- package/esm2015/index.js.map +1 -0
- package/esm2015/local-store/disable-local-trait-effects.token.js +6 -0
- package/esm2015/local-store/disable-local-trait-effects.token.js.map +1 -0
- package/esm2015/local-store/index.js +3 -0
- package/esm2015/local-store/index.js.map +1 -0
- package/esm2015/local-store/traits-local-store.js +75 -0
- package/esm2015/local-store/traits-local-store.js.map +1 -0
- package/esm2015/model.js +28 -0
- package/esm2015/model.js.map +1 -0
- package/esm2015/ngrx-traits-core.js +5 -0
- package/esm2015/ngrx-traits-core.js.map +1 -0
- package/esm2015/public_api.js +2 -0
- package/esm2015/public_api.js.map +1 -0
- package/esm2015/testing/index.js +2 -0
- package/esm2015/testing/index.js.map +1 -0
- package/esm2015/testing/ngrx-traits-core-testing.js +5 -0
- package/esm2015/testing/ngrx-traits-core-testing.js.map +1 -0
- package/esm2015/testing/provide-mock-local-traits.js +39 -0
- package/esm2015/testing/provide-mock-local-traits.js.map +1 -0
- package/esm2015/testing/public_api.js +2 -0
- package/esm2015/testing/public_api.js.map +1 -0
- package/esm2015/trait-effect.js +32 -0
- package/esm2015/trait-effect.js.map +1 -0
- package/esm2015/util.js +17 -0
- package/esm2015/util.js.map +1 -0
- package/fesm2015/ngrx-traits-core-testing.js +46 -0
- package/fesm2015/ngrx-traits-core-testing.js.map +1 -0
- package/fesm2015/ngrx-traits-core.js +699 -0
- package/fesm2015/ngrx-traits-core.js.map +1 -0
- package/index.d.ts +6 -0
- package/local-store/disable-local-trait-effects.token.d.ts +5 -0
- package/local-store/index.d.ts +2 -0
- package/local-store/traits-local-store.d.ts +33 -0
- package/model.d.ts +103 -0
- package/ngrx-traits-core.d.ts +5 -0
- package/package.json +29 -0
- package/public_api.d.ts +1 -0
- package/testing/index.d.ts +1 -0
- package/testing/ngrx-traits-core-testing.d.ts +5 -0
- package/testing/package.json +10 -0
- package/testing/provide-mock-local-traits.d.ts +8 -0
- package/testing/public_api.d.ts +1 -0
- package/trait-effect.d.ts +16 -0
- package/util.d.ts +8 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# NGRX-Traits
|
|
2
|
+
|
|
3
|
+
NGRX Traits is a set of factory functions that dynamically generate actions, effects, reducers needed for common functionality like loading a list of entities, filtering, pagination, sorting. They can be mix and match, so you only use what you need, and you can create your own to for example reuse some business logic across your app.
|
|
4
|
+
|
|
5
|
+
# Features
|
|
6
|
+
|
|
7
|
+
- ✅ Reduce boilerplate with generated strongly typed actions, selectors, reducers, and effects.
|
|
8
|
+
- ✅ Easily mix with your own actions, selectors, reducers, and effects
|
|
9
|
+
- ✅ Create your own traits, to easily reuse business logic
|
|
10
|
+
- ✅ Transform any trait config from a global store to a local store bound to a components lifecycle
|
|
11
|
+
- ✅ Trait to load and cache entities list
|
|
12
|
+
- ✅ Trait to filter remote and locally entities list
|
|
13
|
+
- ✅ Trait to sort remote and locally entities list
|
|
14
|
+
- ✅ Trait to paginate entities list
|
|
15
|
+
- ✅ Trait to add single or multi selection entities list
|
|
16
|
+
- ✅ Trait to add crud operations to an entities list
|
|
17
|
+
- ✅ Trait to load single entities
|
|
18
|
+
- ✅ Trait to reduce boilerplate needed when calling backend apis
|
|
19
|
+
|
|
20
|
+
# Installation and Usage
|
|
21
|
+
|
|
22
|
+
`npm install ngrx-traits-core`
|
|
23
|
+
|
|
24
|
+
For more documentation go to our [github page](https://github.com/gabrielguerrero/ngrx-traits-core)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@ngrx-traits/core'), require('@angular/core'), require('@ngrx/effects'), require('@ngrx/store/testing')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@ngrx-traits/core/testing', ['exports', '@ngrx-traits/core', '@angular/core', '@ngrx/effects', '@ngrx/store/testing'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['ngrx-traits'] = global['ngrx-traits'] || {}, global['ngrx-traits'].core = global['ngrx-traits'].core || {}, global['ngrx-traits'].core.testing = {}), global['ngrx-traits'].core, global.ng.core, global.effects, global.testing));
|
|
5
|
+
}(this, (function (exports, core, core$1, effects, testing) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* NOTE: provideMockStore({initialState}) initialState will be ignored with local traits store!
|
|
9
|
+
* Override selectors instead
|
|
10
|
+
*
|
|
11
|
+
* You still need to provideMockStore and provideMockActions
|
|
12
|
+
* */
|
|
13
|
+
function provideMockLocalTraits(_b) {
|
|
14
|
+
var traitFactory = _b.traitFactory, selectors = _b.selectors;
|
|
15
|
+
return [
|
|
16
|
+
{ provide: core.DISABLE_LOCAL_TRAIT_EFFECTS, useValue: true },
|
|
17
|
+
{
|
|
18
|
+
provide: effects.EffectSources,
|
|
19
|
+
useValue: {
|
|
20
|
+
addEffects: function () {
|
|
21
|
+
return;
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
provide: traitFactory,
|
|
27
|
+
deps: [core$1.Injector, testing.MockStore],
|
|
28
|
+
useFactory: function (injector, mockStore) {
|
|
29
|
+
var trait = new traitFactory(injector);
|
|
30
|
+
if (selectors) {
|
|
31
|
+
Object.keys(selectors).forEach(function (key) {
|
|
32
|
+
var _a;
|
|
33
|
+
return ((_a = trait.localSelectors) === null || _a === void 0 ? void 0 : _a[key]) &&
|
|
34
|
+
mockStore.overrideSelector(trait.localSelectors[key], selectors === null || selectors === void 0 ? void 0 : selectors[key]);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return trait;
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Generated bundle index. Do not edit.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
exports.provideMockLocalTraits = provideMockLocalTraits;
|
|
48
|
+
|
|
49
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
+
|
|
51
|
+
})));
|
|
52
|
+
//# sourceMappingURL=ngrx-traits-core-testing.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngrx-traits-core-testing.umd.js","sources":["../../../../../libs/ngrx-traits/core/testing/src/provide-mock-local-traits.ts","../../../../../libs/ngrx-traits/core/testing/src/ngrx-traits-core-testing.ts"],"sourcesContent":["import {\n EntityFeatureFactory,\n TraitsLocalStore,\n DISABLE_LOCAL_TRAIT_EFFECTS,\n} from '@ngrx-traits/core';\nimport { Injector, Provider, Type } from '@angular/core';\nimport { EffectSources } from '@ngrx/effects';\nimport { MockStore } from '@ngrx/store/testing';\n\n/*\n * NOTE: provideMockStore({initialState}) initialState will be ignored with local traits store!\n * Override selectors instead\n *\n * You still need to provideMockStore and provideMockActions\n * */\nexport function provideMockLocalTraits<\n T extends TraitsLocalStore<EntityFeatureFactory<any, any>>\n>({\n traitFactory,\n selectors,\n}: {\n traitFactory: Type<T>;\n selectors?: {\n [key in keyof T['localSelectors']]?: ReturnType<T['localSelectors'][key]>;\n };\n}): Provider[] {\n return [\n { provide: DISABLE_LOCAL_TRAIT_EFFECTS, useValue: true },\n {\n provide: EffectSources,\n useValue: {\n addEffects: () => {\n return;\n },\n },\n },\n {\n provide: traitFactory,\n deps: [Injector, MockStore],\n useFactory: (injector: Injector, mockStore: MockStore) => {\n const trait = new traitFactory(injector);\n if (selectors) {\n Object.keys(selectors).forEach(\n (key) =>\n trait.localSelectors?.[key] &&\n mockStore.overrideSelector(\n trait.localSelectors[key],\n selectors?.[key]\n )\n );\n }\n return trait;\n },\n },\n ];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["DISABLE_LOCAL_TRAIT_EFFECTS","EffectSources","Injector","MockStore"],"mappings":";;;;;;IASA;;;;;;aAMgB,sBAAsB,CAEpC,EAQD;YAPC,YAAY,kBAAA,EACZ,SAAS,eAAA;QAOT,OAAO;YACL,EAAE,OAAO,EAAEA,gCAA2B,EAAE,QAAQ,EAAE,IAAI,EAAE;YACxD;gBACE,OAAO,EAAEC,qBAAa;gBACtB,QAAQ,EAAE;oBACR,UAAU,EAAE;wBACV,OAAO;qBACR;iBACF;aACF;YACD;gBACE,OAAO,EAAE,YAAY;gBACrB,IAAI,EAAE,CAACC,eAAQ,EAAEC,iBAAS,CAAC;gBAC3B,UAAU,EAAE,UAAC,QAAkB,EAAE,SAAoB;oBACnD,IAAM,KAAK,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;oBACzC,IAAI,SAAS,EAAE;wBACb,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAC5B,UAAC,GAAG;;4BACF,OAAA,CAAA,MAAA,KAAK,CAAC,cAAc,0CAAG,GAAG,CAAC;gCAC3B,SAAS,CAAC,gBAAgB,CACxB,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EACzB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,GAAG,CAAC,CACjB,CAAA;yBAAA,CACJ,CAAC;qBACH;oBACD,OAAO,KAAK,CAAC;iBACd;aACF;SACF,CAAC;IACJ;;ICvDA;;;;;;;;;;;;"}
|