File tree Expand file tree Collapse file tree 2 files changed +83
-10
lines changed Expand file tree Collapse file tree 2 files changed +83
-10
lines changed Original file line number Diff line number Diff line change 6
6
7
7
import _omit from 'lodash/omit'
8
8
9
- export default function makeDefaultState ( servicePath , options ) {
9
+ import { MakeServicePluginOptions , PaginationState } from './types'
10
+
11
+ export interface ServiceStateExclusiveDefaults {
12
+ ids : string [ ]
13
+
14
+ errorOnFind : any
15
+ errorOnGet : any
16
+ errorOnCreate : any
17
+ errorOnPatch : any
18
+ errorOnUpdate : any
19
+ errorOnRemove : any
20
+
21
+ isFindPending : boolean
22
+ isGetPending : boolean
23
+ isCreatePending : boolean
24
+ isPatchPending : boolean
25
+ isUpdatePending : boolean
26
+ isRemovePending : boolean
27
+
28
+ keyedById : { }
29
+ tempsById : { }
30
+ tempsByNewId : { }
31
+ copiesById : { }
32
+ namespace ?: string
33
+ pagination ?: {
34
+ defaultLimit : number
35
+ defaultSkip : number
36
+ default ?: PaginationState
37
+ }
38
+ modelName ?: string
39
+ }
40
+
41
+ export interface ServiceState {
42
+ options : { }
43
+ ids : string [ ]
44
+ autoRemove : boolean
45
+ errorOnFind : any
46
+ errorOnGet : any
47
+ errorOnCreate : any
48
+ errorOnPatch : any
49
+ errorOnUpdate : any
50
+ errorOnRemove : any
51
+ isFindPending : boolean
52
+ isGetPending : boolean
53
+ isCreatePending : boolean
54
+ isPatchPending : boolean
55
+ isUpdatePending : boolean
56
+ isRemovePending : boolean
57
+ idField : string
58
+ keyedById : { }
59
+ tempsById : { }
60
+ tempsByNewId : { }
61
+ copiesById : { }
62
+ whitelist : string [ ]
63
+ paramsForServer : string [ ]
64
+ namespace : string
65
+ nameStyle : string // Should be enum of 'short' or 'path'
66
+ pagination ?: {
67
+ defaultLimit : number
68
+ defaultSkip : number
69
+ default ?: PaginationState
70
+ }
71
+ modelName ?: string
72
+ }
73
+
74
+ export interface PaginationState {
75
+ ids : any
76
+ limit : number
77
+ skip : number
78
+ ip : number
79
+ total : number
80
+ mostRecent : any
81
+ }
82
+
83
+ export default function makeDefaultState ( options : MakeServicePluginOptions ) {
10
84
const nonStateProps = [
11
- 'actions' ,
12
- 'getters' ,
13
- 'instanceDefaults' ,
14
- 'handleEvents' ,
15
85
'Model' ,
16
- 'mutations' ,
17
86
'service' ,
87
+ 'instanceDefaults' ,
18
88
'setupInstance' ,
89
+ 'handleEvents' ,
19
90
'state' ,
91
+ 'getters' ,
92
+ 'mutations' ,
20
93
'actions'
21
94
]
22
95
23
- const state = {
96
+ const state : ServiceStateExclusiveDefaults = {
24
97
ids : [ ] ,
25
98
keyedById : { } ,
26
99
copiesById : { } ,
@@ -43,8 +116,7 @@ export default function makeDefaultState(servicePath, options) {
43
116
errorOnCreate : null ,
44
117
errorOnUpdate : null ,
45
118
errorOnPatch : null ,
46
- errorOnRemove : null ,
47
- modelName : null as string | null
119
+ errorOnRemove : null
48
120
}
49
121
50
122
if ( options . Model ) {
Original file line number Diff line number Diff line change 3
3
@typescript -eslint/explicit-function-return-type: 0,
4
4
@typescript -eslint/no-explicit-any: 0
5
5
*/
6
- // TODO: use this in the src
7
6
export interface ServiceState {
8
7
options : { }
9
8
ids : string [ ]
@@ -23,13 +22,15 @@ export interface ServiceState {
23
22
idField : string
24
23
keyedById : { }
25
24
tempsById : { }
25
+ tempsByNewId : { }
26
26
whitelist : string [ ]
27
27
paramsForServer : string [ ]
28
28
namespace : string
29
29
nameStyle : string // Should be enum of 'short' or 'path'
30
30
pagination ?: {
31
31
default : PaginationState
32
32
}
33
+ modelName : string
33
34
}
34
35
35
36
export interface PaginationState {
You can’t perform that action at this time.
0 commit comments