@rentman/rm-core 1.0.21 → 1.0.22

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.
@@ -1,16 +1,17 @@
1
1
  import ApiResponseProcessorFactory from '../factories/ApiResponseProcessorFactory';
2
2
  import ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';
3
+ import ApiResponseProcessor from './ApiResponseProcessor';
3
4
  export default class ApiRequestService {
4
5
  private externalApiRequestService;
5
6
  private apiResponseProcessorFactory;
6
7
  constructor(externalApiRequestService: ApiRequestServiceInterface, apiResponseProcessorFactory: ApiResponseProcessorFactory);
7
- template(itemType: string, params: any): Promise<any>;
8
- create(itemType: string, itemId: number, values: any, parentType?: string, parentId?: number): Promise<any>;
9
- delete(itemType: string, itemIds: number[]): Promise<any>;
10
- updateItems(itemType: string, items: object, columns: any): Promise<any>;
11
- requestSkeleton(params: any, requestCanceler?: Promise<any>): Promise<any>;
12
- moveItems(parentType: string, parentId: number, items: object): Promise<any>;
13
- columns(itemType: string, columns: object, params?: any): Promise<any>;
14
- query(itemType: string, query: object, columns: object, allLinks?: boolean, limit?: object): Promise<any>;
15
- processResponse(request: any): any;
8
+ template(itemType: string, params: any): PromiseLike<ApiResponseProcessor>;
9
+ create(itemType: string, itemId: number, values: any, parentType?: string, parentId?: number): PromiseLike<ApiResponseProcessor>;
10
+ delete(itemType: string, itemIds: number[]): PromiseLike<ApiResponseProcessor>;
11
+ updateItems(itemType: string, items: object, columns: any): PromiseLike<ApiResponseProcessor>;
12
+ requestSkeleton(params: any, requestCanceler?: PromiseLike<any>): PromiseLike<ApiResponseProcessor>;
13
+ moveItems(parentType: string, parentId: number, items: object): PromiseLike<ApiResponseProcessor>;
14
+ columns(itemType: string, columns: object, params?: any): PromiseLike<ApiResponseProcessor>;
15
+ query(itemType: string, query: object, columns: object, allLinks?: boolean, limit?: object): PromiseLike<ApiResponseProcessor>;
16
+ processResponse(request: any): PromiseLike<ApiResponseProcessor>;
16
17
  }
@@ -1,10 +1,11 @@
1
1
  import ApiFormatter from './ApiFormatter';
2
+ import { ItemTypeMap } from '../types/ItemTypesCollection';
2
3
  export default class ApiResponseProcessor {
3
4
  apiFormatter: ApiFormatter;
4
5
  response: any;
5
- columns: any[];
6
- items: any[];
7
- links: any[];
6
+ columns: ItemTypeMap;
7
+ items: ItemTypeMap;
8
+ links: ItemTypeMap;
8
9
  cacheable: boolean;
9
10
  map: any;
10
11
  columnIndexMap: any;
@@ -1,16 +1,19 @@
1
+ import { ENTRY_STATUS } from "../constants";
1
2
  import ItemEntry from "../models/ItemEntry";
2
3
  import PromiseService from "./PromiseService";
4
+ import { EntryStatus } from '../types/ItemTypesCollection';
5
+ import { ItemEntryEntryStatusMap } from '../types/ItemTypesCollection';
3
6
  export default class BatchStatus {
4
7
  private promiseService;
5
8
  getItemId: (itemEntry: ItemEntry) => number;
6
- getPromise: (itemEntry: ItemEntry) => Promise<any>;
7
- entries: {};
8
- constructor(promiseService: PromiseService, getItemId: (itemEntry: ItemEntry) => number, getPromise: (itemEntry: ItemEntry) => Promise<any>);
9
- add(entryStatus: any): void;
10
- hasEntries(statusArray: any): boolean;
9
+ getPromise: (itemEntry: ItemEntry) => Promise<ItemEntry>;
10
+ entries: ItemEntryEntryStatusMap;
11
+ constructor(promiseService: PromiseService, getItemId: (itemEntry: ItemEntry) => number, getPromise: (itemEntry: ItemEntry) => Promise<ItemEntry>);
12
+ add(entryStatus: EntryStatus<ItemEntry>): void;
13
+ hasEntries(statusArray: ENTRY_STATUS[]): boolean;
11
14
  hasRequests(): boolean;
12
- forEachEntry(statusArray: any[], callback: any): void;
13
- getPromises(): any;
15
+ forEachEntry(statusArray: ENTRY_STATUS[], callback: (itemEntry: ItemEntry) => void): void;
16
+ getPromises(): PromiseLike<ItemEntry[]>;
14
17
  getRequestIds(): number[];
15
- getArray(): any[];
18
+ getArray(): ItemEntry[];
16
19
  }
@@ -1,26 +1,28 @@
1
1
  import QueryMatcherFactory from "../factories/QueryMatcherFactory";
2
2
  import CollectionEntry from "../models/CollectionEntry";
3
+ import CollectionResource from '../models/CollectionResource';
4
+ import { CollectionEntryItemTypeMap } from '../types/ItemTypesCollection';
3
5
  export default class CollectionCache {
4
6
  private queryMatcherFactory;
5
- entries: {};
7
+ entries: CollectionEntryItemTypeMap;
6
8
  constructor(queryMatcherFactory: QueryMatcherFactory);
7
- contains(collectionEntry: any): boolean;
8
- some(callback: any): boolean;
9
- forEach(callback: any): void;
10
- toArray(): any[];
9
+ contains(collectionEntry: CollectionEntry): boolean;
10
+ some(callback: (entry: CollectionEntry) => void): boolean;
11
+ forEach(callback: (entry: CollectionEntry) => void): void;
12
+ toArray(): CollectionEntry[];
11
13
  add(collectionEntry: CollectionEntry): CollectionEntry;
12
14
  clear(collectionEntry?: CollectionEntry): boolean;
13
- getByItemType(itemType: any): any;
14
- getByParent(parentType: any, parentId: any, itemType: any): any;
15
- getResourceByParent(parentType: any, parentId: any, itemType: any): any;
16
- getCollectionsByParent(parentType: any, parentId: any): any[];
15
+ getByItemType(itemType: string): CollectionEntry[];
16
+ getByParent(parentType: any, parentId: any, itemType: any): CollectionEntry | null;
17
+ getResourceByParent(parentType: any, parentId: any, itemType: any): CollectionResource;
18
+ getCollectionsByParent(parentType: any, parentId: any): CollectionEntry[];
17
19
  /**
18
20
  * Only resources
19
21
  * @param {String} itemType
20
22
  * @param {String|Integer} itemId
21
23
  * @returns {Object} Array of collections.
22
24
  */
23
- getByContainingItem(itemType: any, itemId: any): any[];
25
+ getByContainingItem(itemType: any, itemId: any): CollectionEntry[];
24
26
  /**
25
27
  * Returns an array of collections the item 'belongs' in.
26
28
  * @param {String} parentType
@@ -33,7 +35,7 @@ export default class CollectionCache {
33
35
  notfitting: any[];
34
36
  maybe: any[];
35
37
  };
36
- getByQuery(itemType: any, query: any): any;
37
- getByKey(itemType: any, entryKey: any): any[];
38
+ getByQuery(itemType: any, query: any): CollectionEntry;
39
+ getByKey(itemType: any, entryKey: any): CollectionEntry[];
38
40
  getResourceByKey(itemType: any, resourceKey: any): any[];
39
41
  }
@@ -10,6 +10,14 @@ export default class CollectionEntryService {
10
10
  object: any;
11
11
  string: any;
12
12
  };
13
- getIdArray(itemEntries: ItemEntry[], accumulator: any): any;
14
- filterArray(itemEntries: ItemEntry[], callback: any): any[];
13
+ getIdArray(itemEntries: ItemEntry[], accumulator: any): number[];
14
+ /**
15
+ * @param {ItemEntry[]} itemEntries
16
+ * @param {(itemEntry: ItemEntry) => boolean} callback
17
+ * @returns {ItemEntry[]}
18
+ *
19
+ * filter an array according to the callback function. Return the entries that failed the condition
20
+ * Replace the given array with the entries that didn't fail the condition.
21
+ */
22
+ filterArray(itemEntries: ItemEntry[], callback: (itemEntry: ItemEntry) => boolean): ItemEntry[];
15
23
  }
@@ -18,6 +18,7 @@ import ItemRequestService from "./ItemRequestService";
18
18
  import KeyService from "./KeyService";
19
19
  import PromiseService from "./PromiseService";
20
20
  import QueryService from "./QueryService";
21
+ import { CollectionEntryBatchStatusMap, CollectionEntryParentIdMap, EntryStatus, ItemResourceItemIdMap } from '../types/ItemTypesCollection';
21
22
  export default class CollectionHandler {
22
23
  private errorHandler;
23
24
  private itemRequestService;
@@ -35,37 +36,28 @@ export default class CollectionHandler {
35
36
  private columnUtil;
36
37
  entries: CollectionCache;
37
38
  constructor(errorHandler: ErrorHandlerInterface, itemRequestService: ItemRequestService, itemHandler: ItemHandler, columnHandler: ColumnHandler, collectionEntryFactory: CollectionEntryFactory, collectionCacheFactory: CollectionCacheFactory, queryParserFactory: QueryParserFactory, collectionEntryService: CollectionEntryService, columnSetFactory: ColumnSetFactory, itemEntryService: ItemEntryService, keyService: KeyService, promiseService: PromiseService, queryService: QueryService, columnUtil: ColumnUtil);
38
- getPromises(statusResource: any): any[];
39
+ getPromises(statusResource: CollectionEntryBatchStatusMap): any[];
39
40
  getRequestIds(statusResource: any): any[];
40
41
  removeFromAndAddToCollections(collectionMap: any, updateInitial?: any): void;
41
42
  removeFromCollections(collectionMap: any, updateInitial?: any, resultResource?: CollectionResource | null): any;
42
43
  /**
43
44
  * @deprecated
44
45
  */
45
- addItemsToCollections(itemEntries: ItemEntry[]): any;
46
- addToCollections(collectionMap: any, updateInitial: boolean, resultResource?: ItemResource | null): any;
47
- batchExpand(parentType: string, itemType: string, collections: CollectionResource[], newColumns: any): any;
48
- batchExtend(parentType: string, itemType: string, options: any, queryCallback: any, collections: CollectionResource[], returnAllItems?: boolean): {};
49
- batchFetch(parentType: string, parentIdArray: number[], itemType: string, options: any, deferredCollectionCache: CollectionCache): any;
46
+ addItemsToCollections(itemEntries: ItemEntry[]): ItemResource[];
47
+ addToCollections(collectionMap: any, updateInitial: boolean, resultResource?: ItemResource | null): ItemResource[];
48
+ batchExpand(parentType: string, itemType: string, collections: CollectionResource[], newColumns: any): PromiseLike<CollectionResource[]>;
49
+ batchExtend(parentType: string, itemType: string, options: any, queryCallback: any, collections: CollectionResource[], returnAllItems?: boolean): PromiseLike<ItemResourceItemIdMap>;
50
+ batchFetch(parentType: string, parentIdArray: number[], itemType: string, options: any, deferredCollectionCache: CollectionCache): PromiseLike<CollectionEntryParentIdMap>;
50
51
  clone(collectionEntry: CollectionEntry, options: any, conversionMap?: {}): CollectionEntry;
51
52
  create(itemType: string, options: any, columns: any, items: ItemEntry[]): CollectionEntry;
52
53
  createCollectionMap(itemEntries: ItemEntry[]): {};
53
- createStatusResource(parentType: string, parentIdArray: number[], itemType: string, options: any, deferredCollectionCache: CollectionCache): {};
54
+ createStatusResource(parentType: string, parentIdArray: number[], itemType: string, options: any, deferredCollectionCache: CollectionCache): CollectionEntryBatchStatusMap;
54
55
  expandCollectionMap(itemEntry: ItemEntry, accumulator: any, collectionCache?: CollectionCache): void;
55
- fetch(itemType: string, options: any, itemCache: ItemCache, deferredCollectionCache: CollectionCache): any;
56
- getDeferredEntryStatus(collectionEntry: CollectionEntry, options: any): {
57
- entry: CollectionEntry;
58
- status: string;
59
- };
60
- getEntryStatus(itemType: string, options: any, deferredEntries: CollectionCache): {
61
- entry: any;
62
- status: string;
63
- };
64
- getNewEntryStatus(itemType: string, query: any, options: any, deferredEntries: CollectionCache): {
65
- entry: any;
66
- status: string;
67
- };
68
- handleBatchResponse(statusResource: any, itemEntryResource: any): {};
56
+ fetch(itemType: string, options: any, itemCache: ItemCache, deferredCollectionCache: CollectionCache): PromiseLike<CollectionEntry>;
57
+ getDeferredEntryStatus(collectionEntry: CollectionEntry, options: any): EntryStatus<CollectionEntry>;
58
+ getEntryStatus(itemType: string, options: any, deferredEntries: CollectionCache): EntryStatus<CollectionEntry>;
59
+ getNewEntryStatus(itemType: string, query: any, options: any, deferredEntries: CollectionCache): EntryStatus<CollectionEntry>;
60
+ handleBatchResponse(statusResource: any, itemEntryResource: any): CollectionEntryParentIdMap;
69
61
  /**
70
62
  * @deprecated
71
63
  */
@@ -74,6 +66,6 @@ export default class CollectionHandler {
74
66
  * @deprecated
75
67
  */
76
68
  removeItemsFromCollections(itemEntries: ItemEntry[]): any;
77
- resolveLocal(collectionEntry: CollectionEntry, itemCache: any): Promise<any>;
78
- resolveRemote(collectionEntry: any, itemCache: any): Promise<any>;
69
+ resolveLocal(collectionEntry: CollectionEntry, itemCache: any): PromiseLike<CollectionEntry>;
70
+ resolveRemote(collectionEntry: any, itemCache: any): PromiseLike<CollectionEntry>;
79
71
  }
@@ -13,7 +13,7 @@ export default class ColumnHandler {
13
13
  setColumn(itemType: any, responseColumn: any): any;
14
14
  setColumns(itemType: any, requestColumns: any, responseColumns: any): {};
15
15
  fetchItemTypeTranslations(itemTypes: any): Promise<any>;
16
- request(itemType: any, columns: any, params?: {}): Promise<any>;
17
- fetch(itemType: any, requestColumns: any, params?: {}): Promise<any>;
18
- fetchAll(itemType: any): Promise<any>;
16
+ request(itemType: any, columns: any, params?: {}): PromiseLike<any>;
17
+ fetch(itemType: any, requestColumns: any, params?: {}): PromiseLike<any>;
18
+ fetchAll(itemType: any): PromiseLike<any>;
19
19
  }
@@ -18,6 +18,8 @@ import ItemRequestService from "./ItemRequestService";
18
18
  import KeyService from "./KeyService";
19
19
  import QueryService from "./QueryService";
20
20
  import ResourceCache from "./ResourceCache";
21
+ import ItemEntry from '../models/ItemEntry';
22
+ import { CollectionEntryParentIdMap, CollectionResourceParentIdMap, ItemResourceItemTypeMap, TemplateResponseItemEntryMap } from '../types/ItemTypesCollection';
21
23
  export default class ItemAdministrator {
22
24
  private apiRequestService;
23
25
  private resourceCacheInterface;
@@ -41,11 +43,31 @@ export default class ItemAdministrator {
41
43
  itemId: any;
42
44
  };
43
45
  createCollectionMap(itemEntries: any[], addToTab: boolean): {};
44
- getItemById(itemType: string, itemId: number, options: any): any;
45
- getItemsById(itemType: string, itemIds: number[], options: any): any;
46
- getItemsByQuery(itemType: string, query: any, options: any): Promise<any>;
47
- getDuplicateById(itemType: string, duplicateId: number, options: any): any;
48
- getNewResource(itemType: string, options: any, returnLinks: boolean, isRoot: boolean): any;
46
+ /**
47
+ *
48
+ * @param {string} itemType
49
+ * @param {number} itemId
50
+ * @param options
51
+ * @returns {PromiseLike<ItemResource>}
52
+ *
53
+ * I expect not a template request from itemhandler.fetchItem because addSingleItem does not handle the
54
+ * TemplateResponseItemEntryMap
55
+ */
56
+ getItemById(itemType: string, itemId: number, options: any): PromiseLike<ItemResource>;
57
+ getItemsById(itemType: string, itemIds: number[], options: any): PromiseLike<ItemResource[]>;
58
+ getItemsByQuery(itemType: string, query: any, options: any): PromiseLike<ItemResource[]>;
59
+ getDuplicateById(itemType: string, duplicateId: number, options: any): PromiseLike<any>;
60
+ /**
61
+ * The return value is depended on the return links boolean. true returns the TemplateResponseItemEntryMap.
62
+ * The type has to be asserted at use since you only know the type of the return value when the function is called
63
+ *
64
+ * @param {string} itemType
65
+ * @param options
66
+ * @param {boolean} returnLinks
67
+ * @param {boolean} isRoot
68
+ * @returns {PromiseLike<ItemResource> | PromiseLike<TemplateResponseItemEntryMap>}
69
+ */
70
+ getNewResource(itemType: string, options: any, returnLinks: boolean, isRoot: boolean): PromiseLike<ItemResource> | PromiseLike<TemplateResponseItemEntryMap>;
49
71
  getCollectionDef(itemType: string, options: any): {
50
72
  itemType: string;
51
73
  options: {
@@ -64,14 +86,14 @@ export default class ItemAdministrator {
64
86
  };
65
87
  };
66
88
  /** @deprecated */
67
- getCollection(itemType: string, query: any, options: any): any;
68
- _getCollection(itemType: string, options: any): any;
69
- getCollectionFromDef(definition: any): any;
70
- getLinkCollection(linkType: string, linkId: number, itemType: string, options: any): any;
71
- getLinkCollections(linkType: string, linkIdArray: number[], itemType: string, options: any): any;
72
- getLinkCollectionsFromDef(definition: any): any;
73
- getAllLinkCollections(linkType: string, itemType: string, options: any): Promise<any>;
74
- getItemByDef(definition: any, isRoot: boolean): any;
89
+ getCollection(itemType: string, query: any, options: any): PromiseLike<any>;
90
+ _getCollection(itemType: string, options: any): PromiseLike<CollectionResource>;
91
+ getCollectionFromDef(definition: any): PromiseLike<CollectionResource>;
92
+ getLinkCollection(linkType: string, linkId: number, itemType: string, options: any): PromiseLike<CollectionResource>;
93
+ getLinkCollections(linkType: string, linkIdArray: number[], itemType: string, options: any): PromiseLike<CollectionResourceParentIdMap>;
94
+ getLinkCollectionsFromDef(definition: any): PromiseLike<CollectionResourceParentIdMap>;
95
+ getAllLinkCollections(linkType: string, itemType: string, options: any): PromiseLike<CollectionEntryParentIdMap>;
96
+ getItemByDef(definition: any, isRoot: boolean): PromiseLike<any>;
75
97
  cloneItem(newItemId: number, itemResource: any, options: any): ItemResource;
76
98
  cloneCollection(collectionResource: any, options: any, conversionMap: any): CollectionResource;
77
99
  /**
@@ -86,11 +108,11 @@ export default class ItemAdministrator {
86
108
  itemId: number;
87
109
  items: any;
88
110
  };
89
- addSingleItem(itemEntry: any, options: any, isRoot?: boolean): ItemResource;
90
- addSingleItems(itemEntries: any[], options: any): any[];
111
+ addSingleItem(itemEntry: ItemEntry, options: any, isRoot?: boolean): ItemResource;
112
+ addSingleItems(itemEntries: ItemEntry[], options: any): ItemResource[];
91
113
  addCollection(collectionEntry: any, resourceOptions: any, processOptions?: any): CollectionResource;
92
- addCollections(collectionEntries: any[], resourceOptions: any): {};
93
- processLinkedItems(linkedEntries: any[], options: any, addToCollections: boolean): {};
114
+ addCollections(collectionEntries: CollectionEntryParentIdMap, resourceOptions: any): CollectionResourceParentIdMap;
115
+ processLinkedItems(linkedEntries: any[], options: any, addToCollections: boolean): ItemResourceItemTypeMap;
94
116
  /**
95
117
  * @deprecated
96
118
  */
@@ -101,12 +123,12 @@ export default class ItemAdministrator {
101
123
  */
102
124
  resetTabEntry(): void;
103
125
  resetResourceCache(): void;
104
- addToCollections(itemEntries: any[], resultCollectionResource: any): any;
126
+ addToCollections(itemEntries: any[], resultCollectionResource: any): ItemResource[];
105
127
  removeFromCollections(itemEntries: any[], resultCollectionResource: any): any;
106
128
  updateItemIdMap(collectionMap: any, conversionMap: any): void;
107
129
  createCollectionResource(collectionEntry: any, resourceOptions: any, processOptions?: any): CollectionResource;
108
130
  createItemResource(itemEntry: any, options: any, isRoot: boolean): ItemResource;
109
- createItemResources(itemEntries: any[], options: any): any[];
131
+ createItemResources(itemEntries: any[], options: any): ItemResource[];
110
132
  /**
111
133
  * @deprecated
112
134
  */
@@ -1,6 +1,7 @@
1
1
  import ApiFormatter from './ApiFormatter';
2
2
  import KeyService from './KeyService';
3
3
  import PromiseService from "./PromiseService";
4
+ import ItemEntry from '../models/ItemEntry';
4
5
  export default class ItemEntryService {
5
6
  private apiFormatter;
6
7
  private keyService;
@@ -9,9 +10,9 @@ export default class ItemEntryService {
9
10
  ALL_PERMISSIONS: number;
10
11
  constructor(apiFormatter: ApiFormatter, keyService: KeyService, promiseService: PromiseService);
11
12
  resetDerived(itemEntry: any, columnIds: any): void;
12
- defer(itemEntry: any, deferRequest: any): any;
13
- resolve(itemEntry: any): any;
14
- reject(itemEntry: any, error?: string): any;
13
+ defer(itemEntry: ItemEntry, deferRequest: any): ItemEntry;
14
+ resolve(itemEntry: any): ItemEntry;
15
+ reject(itemEntry: any, error?: string): ItemEntry;
15
16
  clearResources(itemEntry: any): void;
16
17
  deactivateResources(itemEntry: any): void;
17
18
  getFields(itemEntry: any): any;
@@ -1,3 +1,4 @@
1
+ import { ENTRY_STATUS } from "../constants";
1
2
  import BatchStatusFactory from "../factories/BatchStatusFactory";
2
3
  import ColumnExpansionFactory from "../factories/ColumnExpansionFactory";
3
4
  import ColumnSetFactory from "../factories/ColumnSetFactory";
@@ -14,6 +15,9 @@ import ItemCache from "./ItemCache";
14
15
  import ItemEntryService from "./ItemEntryService";
15
16
  import KeyService from "./KeyService";
16
17
  import PromiseService from "./PromiseService";
18
+ import BatchStatus from './BatchStatus';
19
+ import ApiResponseProcessor from './ApiResponseProcessor';
20
+ import { ApiTemplateItemTypeMap, EntryStatus, TemplateResponseItemEntryMap, TemplateResponseLinkedItemEntryMap } from '../types/ItemTypesCollection';
17
21
  export default class ItemHandler {
18
22
  private apiRequestService;
19
23
  private authInterface;
@@ -30,41 +34,56 @@ export default class ItemHandler {
30
34
  private promiseService;
31
35
  private columnUtil;
32
36
  entries: ItemCache;
33
- templates: {};
37
+ templates: ApiTemplateItemTypeMap;
34
38
  constructor(apiRequestService: ApiRequestServiceInterface, authInterface: AuthInterface, errorHandler: ErrorHandlerInterface, itemEntryFactory: ItemEntryFactory, columnHandler: ColumnHandler, itemCacheFactory: ItemCacheFactory, batchStatusFactory: BatchStatusFactory, columnExpansionFactory: ColumnExpansionFactory, columnSetFactory: ColumnSetFactory, itemEntryService: ItemEntryService, apiFormatter: ApiFormatter, keyService: KeyService, promiseService: PromiseService, columnUtil: ColumnUtil);
35
39
  getItemId(itemEntry: ItemEntry): number;
36
40
  getPromise(itemEntry: ItemEntry): any;
37
- fetchItem(itemType: string, itemId: number, options: any): any;
38
- fetchItems(itemType: any, itemIds: any, options: any): any;
39
- resolveCached(itemEntry: ItemEntry, status: any, options: any): any;
40
- resolveLocal(itemEntry: ItemEntry, parent: any, template: any): {
41
- main: ItemEntry;
42
- linked: any[];
43
- };
44
- resolveExpansion(itemEntry: any, columnExpansion: any, response: any): any;
45
- resolveRemote(itemEntry: any, columnInfo: any, response: any): any;
41
+ fetchItem(itemType: string, itemId: number, options: any): PromiseLike<ItemEntry | TemplateResponseItemEntryMap>;
42
+ /**
43
+ *
44
+ * @param itemType
45
+ * @param itemIds
46
+ * @param options
47
+ * @returns {PromiseLike<ItemEntry[]>}
48
+ *
49
+ * For every itemid find the status of the ItemEntry and resolve the promises so the result is
50
+ * a usable ItemEntry
51
+ */
52
+ fetchItems(itemType: any, itemIds: any, options: any): PromiseLike<ItemEntry[]>;
53
+ resolveCached(itemEntry: ItemEntry, status: ENTRY_STATUS, options: any): PromiseLike<ItemEntry>;
54
+ resolveLocal(itemEntry: ItemEntry, parent: any, template: any): TemplateResponseItemEntryMap;
55
+ resolveExpansion(itemEntry: any, columnExpansion: any, response: any): ItemEntry;
56
+ resolveRemote(itemEntry: any, columnInfo: any, response: any): ItemEntry;
46
57
  fetchTemplate(itemType: string, templateOptions?: any, templateColumns?: any): Promise<any>;
47
- getEntryStatus(itemType: string, itemId: number, options: any): {
48
- entry: any;
49
- status: string;
50
- };
51
- getCachedEntryStatus(itemEntry: ItemEntry, options: any): string;
52
- createDeferredEntry(itemType: string, itemId: number, requestColumns: any, deferRequest: any): any;
58
+ getEntryStatus(itemType: string, itemId: number, options: any): EntryStatus<ItemEntry>;
59
+ getCachedEntryStatus(itemEntry: ItemEntry, options: any): ENTRY_STATUS;
60
+ createDeferredEntry(itemType: string, itemId: number, requestColumns: any, deferRequest: any): ItemEntry;
53
61
  createEntryStub(itemType: string, itemId: number): ItemEntry;
54
- createEntry(itemId: number, initial: any, derived: any, columnInfo: any): any;
55
- resolveDeferredEntry(itemEntry: any, initial: any, derived: any, columns: any): any;
56
- batchResolve(itemType: any, batchStatus: any, requestColumns: any, resolved: any): any;
62
+ createEntry(itemId: number, initial: any, derived: any, columnInfo: any): ItemEntry;
63
+ resolveDeferredEntry(itemEntry: any, initial: any, derived: any, columns: any): ItemEntry;
64
+ /**
65
+ *
66
+ * @param itemType
67
+ * @param {BatchStatus} batchStatus
68
+ * @param requestColumns
69
+ * @param resolved
70
+ * @returns {ItemEntry[]}
71
+ *
72
+ * for every type of entry status there is in this batch request make sure the entries get resolved.
73
+ * then return a array of the resulting ItemEntryArray
74
+ */
75
+ batchResolve(itemType: any, batchStatus: BatchStatus, requestColumns: any, resolved: any): ItemEntry[] | PromiseLike<any>;
57
76
  cloneItem(newItemId: any, itemEntry: any, conversionMap?: any): any;
58
77
  createConversionMap(itemType: string, itemId: number, extend: boolean, response: any): {
59
78
  [x: string]: {
60
79
  [x: number]: number;
61
80
  };
62
81
  };
63
- createLocalEntries(parentType: string, localParentId: number, template: any, conversionMap: any): any[];
82
+ createLocalEntries(parentType: string, localParentId: number, template: any, conversionMap: any): TemplateResponseLinkedItemEntryMap[];
64
83
  createLocalEntry(itemId: number, template: any, modified: any, derived: any, parent?: any): ItemEntry;
65
84
  extendConversionMap(conversionMap: any, links: any, apiResponse: any): void;
66
- fetchTitle(itemType: string, itemId: number, deferRequest?: boolean): any;
67
- requestItem(itemType: string, itemId: number | number[], columns: any): Promise<any>;
85
+ fetchTitle(itemType: string, itemId: number, deferRequest?: boolean): PromiseLike<any>;
86
+ requestItem(itemType: string, itemId: number | number[], columns: any): PromiseLike<ApiResponseProcessor>;
68
87
  updateItemId(itemEntry: any, itemId: any): ItemEntry;
69
88
  private setCreator(itemEntry);
70
89
  }
@@ -10,6 +10,7 @@ import ItemEntryService from "./ItemEntryService";
10
10
  import ItemHandler from "./ItemHandler";
11
11
  import PromiseService from "./PromiseService";
12
12
  import QueryService from "./QueryService";
13
+ import ApiResponseProcessor from './ApiResponseProcessor';
13
14
  export default class ItemRequestService {
14
15
  private apiRequestService;
15
16
  private errorHandler;
@@ -21,11 +22,11 @@ export default class ItemRequestService {
21
22
  private queryService;
22
23
  private promiseService;
23
24
  constructor(apiRequestService: ApiRequestServiceInterface, errorHandler: ErrorHandlerInterface, itemHandler: ItemHandler, columnHandler: ColumnHandler, columnExpansionFactory: ColumnExpansionFactory, columnSetFactory: ColumnSetFactory, itemEntryService: ItemEntryService, queryService: QueryService, promiseService: PromiseService);
24
- requestItem(itemType: any, itemId: any, columns: any): Promise<any>;
25
- requestItems(collectionEntry: CollectionEntry, query?: any, columns?: any): Promise<any>;
26
- requestLinkItems(parentType: any, parentIdArray: any, itemType: any, query: any, columns: any): Promise<any>;
25
+ requestItem(itemType: any, itemId: any, columns: any): PromiseLike<ApiResponseProcessor>;
26
+ requestItems(collectionEntry: CollectionEntry, query?: any, columns?: any): PromiseLike<ApiResponseProcessor>;
27
+ requestLinkItems(parentType: any, parentIdArray: any, itemType: any, query: any, columns: any): PromiseLike<ApiResponseProcessor>;
27
28
  processExpansion(requestColumns: any, response: any, itemType: string, itemEntries: ItemEntry[]): ColumnExpansion;
28
- processResponse(response: any, idArray: any, parent: any, columnInfo: any, columnExpansion?: any): Promise<ItemEntry[]>;
29
+ processResponse(response: any, idArray: any, parent: any, columnInfo: any, columnExpansion?: any): PromiseLike<ItemEntry[]>;
29
30
  handleCachedItem(itemEntry: any, response: any, columnExpansion: ColumnExpansion): any;
30
31
  processLinkResponse(response: any, parentType: any, parentIdArray: any, itemType: any, options: any): any;
31
32
  }
@@ -1,8 +1,7 @@
1
- import ItemEntryService from "./ItemEntryService";
1
+ import { EditResource } from '../models/EditResource';
2
2
  export default class ItemResourceService {
3
- private itemEntryService;
4
- constructor(itemEntryService: ItemEntryService);
3
+ constructor();
5
4
  processOptions(options: any): any;
6
5
  compareOptions(first: any, second: any): boolean;
7
- isNew(resource: any): boolean;
6
+ isNewResource(resource: EditResource): boolean;
8
7
  }
@@ -53,9 +53,9 @@ export default class ResourceCache {
53
53
  clearItem(itemResource: ItemResource): void;
54
54
  clearResources(isSubTabChange?: boolean): void;
55
55
  updateSingleItems(conversionMap: any): void;
56
- revertChanges(): void;
56
+ revertChanges(): any;
57
57
  resetCollection(collectionEntry: CollectionEntry): void;
58
- hasChanges(): boolean;
58
+ hasChanges: boolean;
59
59
  detectChanges(): boolean;
60
60
  collectionHasChanges(collectionEntry: CollectionEntry): boolean;
61
61
  isLockable(): boolean;
@@ -1,10 +1,10 @@
1
- export declare const ENTRY_STATUS: {
2
- CACHED: string;
3
- PROMISED: string;
4
- EXPAND: string;
5
- PROMISED_EXPAND: string;
6
- RESOLVE: string;
7
- LOCAL: string;
8
- };
1
+ export declare enum ENTRY_STATUS {
2
+ CACHED = "cached",
3
+ PROMISED = "promised",
4
+ EXPAND = "expand",
5
+ PROMISED_EXPAND = "promised-expand",
6
+ RESOLVE = "resolve",
7
+ LOCAL = "local",
8
+ }
9
9
  export declare const COLUMN_SEPERATOR = ">";
10
10
  export declare const RENDER_AS_SEPERATOR = ":";
@@ -1,3 +1,4 @@
1
+ import CollectionResourceService from '../classes/CollectionResourceService';
1
2
  import ItemHandler from "../classes/ItemHandler";
2
3
  import KeyService from '../classes/KeyService';
3
4
  import PromiseService from '../classes/PromiseService';
@@ -13,6 +14,7 @@ export default class CollectionResourceFactory {
13
14
  private changesProcessorFactory;
14
15
  private keyService;
15
16
  private promiseService;
16
- constructor(errorHandler: ErrorHandlerInterface, itemHandler: ItemHandler, itemResourceFactory: ItemResourceFactory, changesProcessorFactory: ChangesProcessorFactory, keyService: KeyService, promiseService: PromiseService);
17
+ private collectionResourceService;
18
+ constructor(errorHandler: ErrorHandlerInterface, itemHandler: ItemHandler, itemResourceFactory: ItemResourceFactory, changesProcessorFactory: ChangesProcessorFactory, keyService: KeyService, promiseService: PromiseService, collectionResourceService: CollectionResourceService);
17
19
  construct(collectionEntry: CollectionEntry, options: any): CollectionResource;
18
20
  }
@@ -1,10 +1,10 @@
1
1
  export default interface ApiRequestServiceInterface {
2
- template(itemType: string, params: any): Promise<any>;
3
- create(itemType: string, itemId: number, values: any, parentType?: string, parentId?: number): Promise<any>;
4
- delete(itemType: string, itemIds: number[]): Promise<any>;
5
- updateItems(itemType: string, items: object, columns: any): Promise<any>;
6
- requestSkeleton(params: any, requestCanceler?: Promise<any>): Promise<any>;
7
- moveItems(parentType: string, parentId: number, items: object): Promise<any>;
8
- columns(itemType: string, columns: object, params?: any): Promise<any>;
9
- query(itemType: string, query: object, columns: object, allLinks?: boolean, limit?: object): Promise<any>;
2
+ template(itemType: string, params: any): PromiseLike<any>;
3
+ create(itemType: string, itemId: number, values: any, parentType?: string, parentId?: number): PromiseLike<any>;
4
+ delete(itemType: string, itemIds: number[]): PromiseLike<any>;
5
+ updateItems(itemType: string, items: object, columns: any): PromiseLike<any>;
6
+ requestSkeleton(params: any, requestCanceler?: PromiseLike<any>): PromiseLike<any>;
7
+ moveItems(parentType: string, parentId: number, items: object): PromiseLike<any>;
8
+ columns(itemType: string, columns: object, params?: any): PromiseLike<any>;
9
+ query(itemType: string, query: object, columns: object, allLinks?: boolean, limit?: object): PromiseLike<any>;
10
10
  }
@@ -7,6 +7,7 @@ import QueryService from "../classes/QueryService";
7
7
  import ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';
8
8
  import CollectionResource from "./CollectionResource";
9
9
  import ItemEntry from "./ItemEntry";
10
+ import ItemResource from './ItemResource';
10
11
  export default class CollectionEntry {
11
12
  private errorHandler;
12
13
  private collectionEntryService;
@@ -32,19 +33,19 @@ export default class CollectionEntry {
32
33
  reloadQueued: boolean;
33
34
  constructor(errorHandler: ErrorHandlerInterface, collectionEntryService: CollectionEntryService, itemRequestService: ItemRequestService, itemEntryService: ItemEntryService, keyService: KeyService, queryService: QueryService, promiseService: PromiseService, itemType: string, options: any);
34
35
  isDeferred(): boolean;
35
- resolve(itemEntryResource: any): this;
36
+ resolve(itemEntryResource: any): CollectionEntry;
36
37
  isLocal(): boolean;
37
38
  matchParent(itemType: any, itemId: any): boolean;
38
- forEach(callback: any): void;
39
+ forEach(callback: (itemEntry: ItemEntry) => void): void;
39
40
  getItemById(itemId: any): ItemEntry;
40
- getIdArray(accumulator?: any[]): any;
41
- addItems(itemEntries: any, resultResource: any, updateInitial?: boolean, enableCallback?: boolean): any;
41
+ getIdArray(accumulator?: any[]): number[];
42
+ addItems(itemEntries: any, resultResource: any, updateInitial?: boolean, enableCallback?: boolean): ItemResource[];
42
43
  removeItems(idArray: any, resultResource: any, updateInitial: any, enableCallback?: any): any;
43
44
  clear(resultResource: any, updateInitial: any, enableCallback?: any): any;
44
- handleRemovedItems(filterFunction: any, resultResource: any, updateInitial: any, enableCallback: any): any;
45
+ handleRemovedItems(filterFunction: any, resultResource: any, updateInitial: any, enableCallback?: boolean): any;
45
46
  expand(newColumns: any): any;
46
47
  extendQuery(callback: any): any;
47
- extend(queryCallback: any, collectionResource: any, enableCallback?: any, updateInitial?: any): Promise<any>;
48
+ extend(queryCallback: any, collectionResource: any, enableCallback?: any, updateInitial?: any): PromiseLike<any>;
48
49
  queueReload(): void;
49
50
  updateColumns(columnExpansion: any): void;
50
51
  getAddedItems(returnItemIds?: boolean): any[];
@@ -2,28 +2,36 @@ import ItemResourceFactory from "../factories/ItemResourceFactory";
2
2
  import CollectionEntry from './CollectionEntry';
3
3
  import ItemEntry from "./ItemEntry";
4
4
  import ItemResource from "./ItemResource";
5
+ import { ItemResourceItemIdMap } from '../types/ItemTypesCollection';
5
6
  export default class CollectionResource {
6
7
  private itemResourceFactory;
7
8
  entry: CollectionEntry;
8
9
  options: any;
9
- columns: any;
10
10
  items: ItemResource[];
11
- itemIdMap: {};
11
+ itemIdMap: ItemResourceItemIdMap;
12
+ columns: any;
12
13
  constructor(itemResourceFactory: ItemResourceFactory, entry: CollectionEntry, options: any);
13
- getItemById(itemId: any): any;
14
+ getItemById(itemId: number): ItemResource;
14
15
  rebuildMap(): void;
15
- addItemResources(itemEntries: ItemEntry[]): any[];
16
- removeItemResources(itemEntries: any): any[];
16
+ addItemResources(itemEntries: ItemEntry[]): ItemResource[];
17
+ /**
18
+ * @param itemEntries
19
+ * @returns {ItemResource[]}
20
+ *
21
+ * Returns the Itemresources that where removed Collection.
22
+ * Filters on ItemResource.entry === ItemEntry
23
+ */
24
+ removeItemResources(itemEntries: ItemEntry[]): ItemResource[];
17
25
  callOnAdd(itemResources: ItemResource[]): void;
18
26
  callOnRemove(itemResources: ItemResource[]): void;
19
- forEach(callback: any): void;
20
- filter(callback: any): any[];
21
- first(callback: any): ItemResource;
22
- some(callback: any): boolean;
27
+ forEach(callback: (itemResource: ItemResource) => void): void;
28
+ filter(callback: (itemResource: ItemResource) => boolean): any[];
29
+ first(callback: (itemResource: ItemResource) => boolean): ItemResource;
30
+ some(callback: (itemResource: ItemResource) => boolean): boolean;
23
31
  groupBy(argument: any): {};
24
32
  map(argument: any): any[];
25
- reduce(callback: any, value: any): any;
26
- extend(queryCallback: any, returnAllItems: any, enableCallbacks: any): Promise<any>;
33
+ reduce<T>(callback: (itemResource: ItemResource, value: T) => T, value: T): T;
34
+ extend(queryCallback: any, returnAllItems: any, enableCallbacks: any): PromiseLike<ItemResource[]>;
27
35
  deactivate(): void;
28
36
  clearResource(): void;
29
37
  }