resourcerer 1.1.8 → 1.1.10

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.
Files changed (2) hide show
  1. package/index.d.ts +12 -5
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -13,6 +13,8 @@ declare module 'resourcerer' {
13
13
  method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
14
14
  params?: Record<string, any>;
15
15
  url?: string;
16
+ // they are free to add any other options they like
17
+ [key: string]: any;
16
18
  };
17
19
 
18
20
  type SetOptions = {
@@ -51,6 +53,8 @@ declare module 'resourcerer' {
51
53
  save(attrs: Partial<T>, options?: {wait?: boolean; patch?: boolean;} & SyncOptions & SetOptions):
52
54
  Promise<[Model<T>, Response]>;
53
55
 
56
+ sync(model: Model<T>, options?: SyncOptions): Promise<[any, Response]>;
57
+
54
58
  destroy(options?: {wait?: boolean} & SyncOptions & SetOptions): Promise<[Model<T>, Response]>;
55
59
 
56
60
  isNew(): boolean;
@@ -87,7 +91,7 @@ declare module 'resourcerer' {
87
91
 
88
92
  add(models: ModelArg<T> | ModelArg<T>[], options?: CSetOptions): Collection<T>;
89
93
 
90
- remove(models: ModelArg<T> | ModelArg<T>[]): Collection<T>;
94
+ remove(models: ModelArg<T> | ModelArg<T>[] | string | string[]): Collection<T>;
91
95
 
92
96
  set(models: ModelArg<T> | ModelArg<T>[], options?: CSetOptions): Collection<T>;
93
97
 
@@ -120,6 +124,8 @@ declare module 'resourcerer' {
120
124
 
121
125
  slice(start: number, end?: number): ModelArg<T>[];
122
126
 
127
+ sync(collection: Collection<T>, options?: SyncOptions): Promise<[any, Response]>;
128
+
123
129
  parse(response: Record<string, any> | any[], options?: Record<string, any>): Array<T>;
124
130
 
125
131
  create(
@@ -174,12 +180,13 @@ declare module 'resourcerer' {
174
180
  declare function areAnyLoading(loadingStates: LoadingTypes | LoadingTypes[]): boolean;
175
181
  declare function areAnyPending(loadingStates: LoadingTypes | LoadingTypes[]): boolean;
176
182
 
183
+ declare function sync(model: Model | Collection, options?: SyncOptions): Promise<[any, Response]>;
184
+
177
185
  type ResourceConfigObj = {
178
186
  data?: {[key: string]: any};
179
187
  dependsOn?: string[];
180
188
  force?: boolean;
181
189
  lazy?: boolean;
182
- modelKey?: ResourceKeys;
183
190
  noncritical?: boolean;
184
191
  options?: {[key: string]: any};
185
192
  params?: {[key: string]: any};
@@ -194,7 +201,9 @@ declare module 'resourcerer' {
194
201
  export type ExecutorFunction = (
195
202
  ResourceKeys_: ResourceKeys,
196
203
  props: {[key: string]: any}
197
- ) => Partial<Record<ResourceValues, ResourceConfigObj>>;
204
+ // return type either has a resource key as the object key or is just a string with a modelKey property
205
+ ) => Partial<Record<ResourceValues, ResourceConfigObj>> |
206
+ Partial<Record<string, ResourceConfigObj & {modelKey: ResourceValues}>>;
198
207
 
199
208
  type WithModelSuffix<K, C> = C extends Collection ? `${K}Collection` : `${K}Model`;
200
209
 
@@ -207,8 +216,6 @@ declare module 'resourcerer' {
207
216
  InstanceType<ModelMap[InvertedResourceKeys[Key]]>
208
217
  };
209
218
 
210
- type test = ReturnType<ExecutorFunction>;
211
-
212
219
  export interface ModelCache {
213
220
  get(key: string): Model | Collection | undefined;
214
221
  put(key: string, model: Model | Collection, component: any): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resourcerer",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "repository": "github.com/noahgrant/resourcerer",
5
5
  "description": "Declarative data-fetching and caching framework for React",
6
6
  "keywords": ["declarative data-fetching framework", "react"],