@api-client/core 0.6.24 → 0.6.27
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.
|
@@ -50,7 +50,7 @@ export interface ContextReadBulkEventDetail {
|
|
|
50
50
|
/**
|
|
51
51
|
* An event to be used to read a list of object from the API store.
|
|
52
52
|
*/
|
|
53
|
-
export declare class ContextReadBulkEvent<T> extends ContextEvent<ContextReadBulkEventDetail, T> {
|
|
53
|
+
export declare class ContextReadBulkEvent<T> extends ContextEvent<ContextReadBulkEventDetail, T[]> {
|
|
54
54
|
/**
|
|
55
55
|
* @param type The type of the event
|
|
56
56
|
* @param ids The list of domain ids to read. These must be of the same domain type.
|
|
@@ -90,17 +90,40 @@ export interface ContextDeleteEventDetail {
|
|
|
90
90
|
*/
|
|
91
91
|
parent?: string;
|
|
92
92
|
}
|
|
93
|
+
export interface ContextDeleteBulkEventDetail {
|
|
94
|
+
/**
|
|
95
|
+
* The list of ids of the domain object to remove.
|
|
96
|
+
*/
|
|
97
|
+
ids: string[];
|
|
98
|
+
/**
|
|
99
|
+
* The id of the parent object, if applicable.
|
|
100
|
+
*/
|
|
101
|
+
parent?: string;
|
|
102
|
+
}
|
|
93
103
|
/**
|
|
94
104
|
* An event to be used to delete a state in the context provider.
|
|
95
105
|
*/
|
|
96
106
|
export declare class ContextDeleteEvent extends ContextEvent<ContextDeleteEventDetail, ContextDeleteRecord> {
|
|
97
107
|
/**
|
|
108
|
+
* An event to be used to delete a state in the context provider.
|
|
98
109
|
* @param type The type of the event to dispatch.
|
|
99
110
|
* @param id The id of the object to delete
|
|
100
111
|
* @param parent The id of the parent object, if applicable.
|
|
101
112
|
*/
|
|
102
113
|
constructor(type: string, id: string, parent?: string);
|
|
103
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* An event to be used to delete a number of entities in the context provider.
|
|
117
|
+
*/
|
|
118
|
+
export declare class ContextDeleteBulkEvent extends ContextEvent<ContextDeleteBulkEventDetail, ContextDeleteRecord[]> {
|
|
119
|
+
/**
|
|
120
|
+
* An event to be used to delete a number of entities in the context provider.
|
|
121
|
+
* @param type The type of the event to dispatch.
|
|
122
|
+
* @param ids The list of ids of the domain object to remove.
|
|
123
|
+
* @param parent The id of the parent object, if applicable.
|
|
124
|
+
*/
|
|
125
|
+
constructor(type: string, ids: string[], parent?: string);
|
|
126
|
+
}
|
|
104
127
|
export interface ContextDeleteRecord {
|
|
105
128
|
/**
|
|
106
129
|
* The data kind of the deleted item.
|
|
@@ -116,6 +139,20 @@ export interface ContextDeleteRecord {
|
|
|
116
139
|
*/
|
|
117
140
|
parent?: string;
|
|
118
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* An event dispatched to the context store to restore previously deleted items.
|
|
144
|
+
*/
|
|
145
|
+
export declare class ContextRestoreEvent<T> extends ContextEvent<ContextDeleteRecord[], ContextChangeRecord<T>[]> {
|
|
146
|
+
/**
|
|
147
|
+
* An event dispatched to the context store to restore previously deleted items.
|
|
148
|
+
*
|
|
149
|
+
* The result of the event is the list of `ContextChangeRecord` for the restored items.
|
|
150
|
+
*
|
|
151
|
+
* @param type The type of the event.
|
|
152
|
+
* @param records The records of previously deleted items.
|
|
153
|
+
*/
|
|
154
|
+
constructor(type: string, records: ContextDeleteRecord[]);
|
|
155
|
+
}
|
|
119
156
|
/**
|
|
120
157
|
* An event dispatched when a context store object has been deleted.
|
|
121
158
|
* In general a single context store uses the same event to dispatch the change record.
|
|
@@ -149,15 +186,52 @@ export interface ContextUpdateEventDetail<T> {
|
|
|
149
186
|
*/
|
|
150
187
|
parent?: string;
|
|
151
188
|
}
|
|
189
|
+
export interface ContextUpdateBulkEventDetail<T> {
|
|
190
|
+
/**
|
|
191
|
+
* The list of context store objects to be updated by the context provider.
|
|
192
|
+
*/
|
|
193
|
+
items: T[];
|
|
194
|
+
/**
|
|
195
|
+
* The id of the parent object, if applicable.
|
|
196
|
+
*/
|
|
197
|
+
parent?: string;
|
|
198
|
+
}
|
|
152
199
|
/**
|
|
153
200
|
* An event that is dispatched to update the entire object in the store.
|
|
154
201
|
* This is equivalent to PUT operation in REST HTTP.
|
|
155
202
|
*
|
|
156
203
|
* @template T The object that is being updated.
|
|
204
|
+
* @template U The object that is returned by the context store after updating. By default it is the `T`.
|
|
157
205
|
*/
|
|
158
206
|
export declare class ContextUpdateEvent<T extends object, U = T> extends ContextEvent<ContextUpdateEventDetail<T>, ContextChangeRecord<U>> {
|
|
207
|
+
/**
|
|
208
|
+
* An event that is dispatched to update the entire object in the store.
|
|
209
|
+
* This is equivalent to PUT operation in REST HTTP.
|
|
210
|
+
*
|
|
211
|
+
* @param type The type of the event to dispatch
|
|
212
|
+
* @param updateInfo The update information.
|
|
213
|
+
*/
|
|
159
214
|
constructor(type: string, updateInfo: ContextUpdateEventDetail<T>);
|
|
160
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* An event that is dispatched to update a list of objects in the store.
|
|
218
|
+
* This is equivalent to PUT operation in REST HTTP.
|
|
219
|
+
*
|
|
220
|
+
* If there's a parent, this event only allows to update entities in bulk for the same parent.
|
|
221
|
+
*
|
|
222
|
+
* @template T The object that is being updated.
|
|
223
|
+
* @template U The object that is returned by the context store after updating. By default it is the `T`.
|
|
224
|
+
*/
|
|
225
|
+
export declare class ContextUpdateBulkEvent<T extends object, U = T> extends ContextEvent<ContextUpdateBulkEventDetail<T>, ContextChangeRecord<U>[]> {
|
|
226
|
+
/**
|
|
227
|
+
* An event that is dispatched to update the entire object in the store.
|
|
228
|
+
* This is equivalent to PUT operation in REST HTTP.
|
|
229
|
+
*
|
|
230
|
+
* @param type The type of the event to dispatch
|
|
231
|
+
* @param updateInfo The update information.
|
|
232
|
+
*/
|
|
233
|
+
constructor(type: string, updateInfo: ContextUpdateBulkEventDetail<T>);
|
|
234
|
+
}
|
|
161
235
|
/**
|
|
162
236
|
* Data store query result object.
|
|
163
237
|
*/
|
|
@@ -193,3 +267,46 @@ export declare class ContextListEvent<T> extends ContextEvent<ContextListOptions
|
|
|
193
267
|
*/
|
|
194
268
|
constructor(type: string, opts?: ContextListOptions);
|
|
195
269
|
}
|
|
270
|
+
export interface IQueryDetail {
|
|
271
|
+
/**
|
|
272
|
+
* The query term. All values are always passed as string. Context store must parse value if it requires other types.
|
|
273
|
+
*/
|
|
274
|
+
term: string;
|
|
275
|
+
/**
|
|
276
|
+
* If the context store supports it, the tags to use with the query function to limit the results.
|
|
277
|
+
*/
|
|
278
|
+
tags?: string[];
|
|
279
|
+
/**
|
|
280
|
+
* General purpose type to be defined by the context store.
|
|
281
|
+
* Allows to specify the type of the query to perform.
|
|
282
|
+
*/
|
|
283
|
+
type?: string;
|
|
284
|
+
/**
|
|
285
|
+
* General purpose keyword to be defined by the context store.
|
|
286
|
+
* The purpose is to instruct the context store to perform detailed search.
|
|
287
|
+
* Usually this means longer search time but more accurate results.
|
|
288
|
+
*/
|
|
289
|
+
detailed?: boolean;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* An event dispatched to the context store to perform a query operation.
|
|
293
|
+
* If the context store supports the query operation, it should use the definition of `IQueryDetail` to perform the query.
|
|
294
|
+
* The result is the list of objects ordered by the store from the most relevant items to the least.
|
|
295
|
+
*
|
|
296
|
+
* The implementation should not assume pagination and return enough results for the user to find what they were looking for
|
|
297
|
+
* or to redefine the query. Suggested limit is `50` which in many cases is equivalent of 2 pages of results.
|
|
298
|
+
*/
|
|
299
|
+
export declare class ContextQueryEvent<T = unknown> extends ContextEvent<IQueryDetail, T[]> {
|
|
300
|
+
/**
|
|
301
|
+
* An event dispatched to the context store to perform a query operation.
|
|
302
|
+
* If the context store supports the query operation, it should use the definition of `IQueryDetail` to perform the query.
|
|
303
|
+
* The result is the list of objects ordered by the store from the most relevant items to the least.
|
|
304
|
+
*
|
|
305
|
+
* The implementation should not assume pagination and return enough results for the user to find what they were looking for
|
|
306
|
+
* or to redefine the query. Suggested limit is `50` which in many cases is equivalent of 2 pages of results.
|
|
307
|
+
*
|
|
308
|
+
* @param type The type of the event.
|
|
309
|
+
* @param opts The query options.
|
|
310
|
+
*/
|
|
311
|
+
constructor(type: string, opts: IQueryDetail);
|
|
312
|
+
}
|
|
@@ -49,6 +49,7 @@ export class ContextReadBulkEvent extends ContextEvent {
|
|
|
49
49
|
*/
|
|
50
50
|
export class ContextDeleteEvent extends ContextEvent {
|
|
51
51
|
/**
|
|
52
|
+
* An event to be used to delete a state in the context provider.
|
|
52
53
|
* @param type The type of the event to dispatch.
|
|
53
54
|
* @param id The id of the object to delete
|
|
54
55
|
* @param parent The id of the parent object, if applicable.
|
|
@@ -57,6 +58,36 @@ export class ContextDeleteEvent extends ContextEvent {
|
|
|
57
58
|
super(type, { id, parent });
|
|
58
59
|
}
|
|
59
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* An event to be used to delete a number of entities in the context provider.
|
|
63
|
+
*/
|
|
64
|
+
export class ContextDeleteBulkEvent extends ContextEvent {
|
|
65
|
+
/**
|
|
66
|
+
* An event to be used to delete a number of entities in the context provider.
|
|
67
|
+
* @param type The type of the event to dispatch.
|
|
68
|
+
* @param ids The list of ids of the domain object to remove.
|
|
69
|
+
* @param parent The id of the parent object, if applicable.
|
|
70
|
+
*/
|
|
71
|
+
constructor(type, ids, parent) {
|
|
72
|
+
super(type, { ids, parent });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* An event dispatched to the context store to restore previously deleted items.
|
|
77
|
+
*/
|
|
78
|
+
export class ContextRestoreEvent extends ContextEvent {
|
|
79
|
+
/**
|
|
80
|
+
* An event dispatched to the context store to restore previously deleted items.
|
|
81
|
+
*
|
|
82
|
+
* The result of the event is the list of `ContextChangeRecord` for the restored items.
|
|
83
|
+
*
|
|
84
|
+
* @param type The type of the event.
|
|
85
|
+
* @param records The records of previously deleted items.
|
|
86
|
+
*/
|
|
87
|
+
constructor(type, records) {
|
|
88
|
+
super(type, records);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
60
91
|
/**
|
|
61
92
|
* An event dispatched when a context store object has been deleted.
|
|
62
93
|
* In general a single context store uses the same event to dispatch the change record.
|
|
@@ -99,8 +130,37 @@ export class ContextStateUpdateEvent extends CustomEvent {
|
|
|
99
130
|
* This is equivalent to PUT operation in REST HTTP.
|
|
100
131
|
*
|
|
101
132
|
* @template T The object that is being updated.
|
|
133
|
+
* @template U The object that is returned by the context store after updating. By default it is the `T`.
|
|
102
134
|
*/
|
|
103
135
|
export class ContextUpdateEvent extends ContextEvent {
|
|
136
|
+
/**
|
|
137
|
+
* An event that is dispatched to update the entire object in the store.
|
|
138
|
+
* This is equivalent to PUT operation in REST HTTP.
|
|
139
|
+
*
|
|
140
|
+
* @param type The type of the event to dispatch
|
|
141
|
+
* @param updateInfo The update information.
|
|
142
|
+
*/
|
|
143
|
+
constructor(type, updateInfo) {
|
|
144
|
+
super(type, updateInfo);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* An event that is dispatched to update a list of objects in the store.
|
|
149
|
+
* This is equivalent to PUT operation in REST HTTP.
|
|
150
|
+
*
|
|
151
|
+
* If there's a parent, this event only allows to update entities in bulk for the same parent.
|
|
152
|
+
*
|
|
153
|
+
* @template T The object that is being updated.
|
|
154
|
+
* @template U The object that is returned by the context store after updating. By default it is the `T`.
|
|
155
|
+
*/
|
|
156
|
+
export class ContextUpdateBulkEvent extends ContextEvent {
|
|
157
|
+
/**
|
|
158
|
+
* An event that is dispatched to update the entire object in the store.
|
|
159
|
+
* This is equivalent to PUT operation in REST HTTP.
|
|
160
|
+
*
|
|
161
|
+
* @param type The type of the event to dispatch
|
|
162
|
+
* @param updateInfo The update information.
|
|
163
|
+
*/
|
|
104
164
|
constructor(type, updateInfo) {
|
|
105
165
|
super(type, updateInfo);
|
|
106
166
|
}
|
|
@@ -114,4 +174,28 @@ export class ContextListEvent extends ContextEvent {
|
|
|
114
174
|
super(type, opts);
|
|
115
175
|
}
|
|
116
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* An event dispatched to the context store to perform a query operation.
|
|
179
|
+
* If the context store supports the query operation, it should use the definition of `IQueryDetail` to perform the query.
|
|
180
|
+
* The result is the list of objects ordered by the store from the most relevant items to the least.
|
|
181
|
+
*
|
|
182
|
+
* The implementation should not assume pagination and return enough results for the user to find what they were looking for
|
|
183
|
+
* or to redefine the query. Suggested limit is `50` which in many cases is equivalent of 2 pages of results.
|
|
184
|
+
*/
|
|
185
|
+
export class ContextQueryEvent extends ContextEvent {
|
|
186
|
+
/**
|
|
187
|
+
* An event dispatched to the context store to perform a query operation.
|
|
188
|
+
* If the context store supports the query operation, it should use the definition of `IQueryDetail` to perform the query.
|
|
189
|
+
* The result is the list of objects ordered by the store from the most relevant items to the least.
|
|
190
|
+
*
|
|
191
|
+
* The implementation should not assume pagination and return enough results for the user to find what they were looking for
|
|
192
|
+
* or to redefine the query. Suggested limit is `50` which in many cases is equivalent of 2 pages of results.
|
|
193
|
+
*
|
|
194
|
+
* @param type The type of the event.
|
|
195
|
+
* @param opts The query options.
|
|
196
|
+
*/
|
|
197
|
+
constructor(type, opts) {
|
|
198
|
+
super(type, opts);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
117
201
|
//# sourceMappingURL=BaseEvents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseEvents.js","sourceRoot":"","sources":["../../../src/events/BaseEvents.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAc3C;;GAEG;AACH,MAAM,OAAO,YAAkC,SAAQ,WAAgD;IACrG;;;OAGG;IACH,YAAY,IAAY,EAAE,MAAS;QACjC,KAAK,CAAC,IAAI,EAAE;YACV,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE;gBACN,MAAM,EAAE,SAAS;gBACjB,GAAG,MAAM;aACV;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAaD;;GAEG;AACH,MAAM,OAAO,gBAAoB,SAAQ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D;IAC7F;;;OAGG;IACH,YAAY,IAAY,EAAE,OAA2B,EAAE;QACrD,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpB,CAAC;CACF;AA2BD;;;;;;;GAOG;AACH,MAAM,OAAO,iBAA+B,SAAQ,YAA+B;IACjF;;;;;;;;;;OAUG;IACH,YAAY,IAAY,EAAE,IAAkB;QAC1C,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpB,CAAC;CACF"}
|
package/package.json
CHANGED
package/src/events/BaseEvents.ts
CHANGED
|
@@ -68,7 +68,7 @@ export interface ContextReadBulkEventDetail {
|
|
|
68
68
|
/**
|
|
69
69
|
* An event to be used to read a list of object from the API store.
|
|
70
70
|
*/
|
|
71
|
-
export class ContextReadBulkEvent<T> extends ContextEvent<ContextReadBulkEventDetail, T> {
|
|
71
|
+
export class ContextReadBulkEvent<T> extends ContextEvent<ContextReadBulkEventDetail, T[]> {
|
|
72
72
|
/**
|
|
73
73
|
* @param type The type of the event
|
|
74
74
|
* @param ids The list of domain ids to read. These must be of the same domain type.
|
|
@@ -113,11 +113,23 @@ export interface ContextDeleteEventDetail {
|
|
|
113
113
|
parent?: string;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
export interface ContextDeleteBulkEventDetail {
|
|
117
|
+
/**
|
|
118
|
+
* The list of ids of the domain object to remove.
|
|
119
|
+
*/
|
|
120
|
+
ids: string[];
|
|
121
|
+
/**
|
|
122
|
+
* The id of the parent object, if applicable.
|
|
123
|
+
*/
|
|
124
|
+
parent?: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
116
127
|
/**
|
|
117
128
|
* An event to be used to delete a state in the context provider.
|
|
118
129
|
*/
|
|
119
130
|
export class ContextDeleteEvent extends ContextEvent<ContextDeleteEventDetail, ContextDeleteRecord> {
|
|
120
131
|
/**
|
|
132
|
+
* An event to be used to delete a state in the context provider.
|
|
121
133
|
* @param type The type of the event to dispatch.
|
|
122
134
|
* @param id The id of the object to delete
|
|
123
135
|
* @param parent The id of the parent object, if applicable.
|
|
@@ -127,6 +139,21 @@ export class ContextDeleteEvent extends ContextEvent<ContextDeleteEventDetail, C
|
|
|
127
139
|
}
|
|
128
140
|
}
|
|
129
141
|
|
|
142
|
+
/**
|
|
143
|
+
* An event to be used to delete a number of entities in the context provider.
|
|
144
|
+
*/
|
|
145
|
+
export class ContextDeleteBulkEvent extends ContextEvent<ContextDeleteBulkEventDetail, ContextDeleteRecord[]> {
|
|
146
|
+
/**
|
|
147
|
+
* An event to be used to delete a number of entities in the context provider.
|
|
148
|
+
* @param type The type of the event to dispatch.
|
|
149
|
+
* @param ids The list of ids of the domain object to remove.
|
|
150
|
+
* @param parent The id of the parent object, if applicable.
|
|
151
|
+
*/
|
|
152
|
+
constructor(type: string, ids: string[], parent?: string) {
|
|
153
|
+
super(type, { ids, parent });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
130
157
|
export interface ContextDeleteRecord {
|
|
131
158
|
/**
|
|
132
159
|
* The data kind of the deleted item.
|
|
@@ -143,6 +170,23 @@ export interface ContextDeleteRecord {
|
|
|
143
170
|
parent?: string;
|
|
144
171
|
}
|
|
145
172
|
|
|
173
|
+
/**
|
|
174
|
+
* An event dispatched to the context store to restore previously deleted items.
|
|
175
|
+
*/
|
|
176
|
+
export class ContextRestoreEvent<T> extends ContextEvent<ContextDeleteRecord[], ContextChangeRecord<T>[]> {
|
|
177
|
+
/**
|
|
178
|
+
* An event dispatched to the context store to restore previously deleted items.
|
|
179
|
+
*
|
|
180
|
+
* The result of the event is the list of `ContextChangeRecord` for the restored items.
|
|
181
|
+
*
|
|
182
|
+
* @param type The type of the event.
|
|
183
|
+
* @param records The records of previously deleted items.
|
|
184
|
+
*/
|
|
185
|
+
constructor(type: string, records: ContextDeleteRecord[]) {
|
|
186
|
+
super(type, records);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
146
190
|
/**
|
|
147
191
|
* An event dispatched when a context store object has been deleted.
|
|
148
192
|
* In general a single context store uses the same event to dispatch the change record.
|
|
@@ -193,18 +237,59 @@ export interface ContextUpdateEventDetail<T> {
|
|
|
193
237
|
parent?: string;
|
|
194
238
|
}
|
|
195
239
|
|
|
240
|
+
export interface ContextUpdateBulkEventDetail<T> {
|
|
241
|
+
/**
|
|
242
|
+
* The list of context store objects to be updated by the context provider.
|
|
243
|
+
*/
|
|
244
|
+
items: T[];
|
|
245
|
+
/**
|
|
246
|
+
* The id of the parent object, if applicable.
|
|
247
|
+
*/
|
|
248
|
+
parent?: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
196
251
|
/**
|
|
197
252
|
* An event that is dispatched to update the entire object in the store.
|
|
198
253
|
* This is equivalent to PUT operation in REST HTTP.
|
|
199
254
|
*
|
|
200
255
|
* @template T The object that is being updated.
|
|
256
|
+
* @template U The object that is returned by the context store after updating. By default it is the `T`.
|
|
201
257
|
*/
|
|
202
258
|
export class ContextUpdateEvent<T extends object, U = T> extends ContextEvent<ContextUpdateEventDetail<T>, ContextChangeRecord<U>> {
|
|
259
|
+
/**
|
|
260
|
+
* An event that is dispatched to update the entire object in the store.
|
|
261
|
+
* This is equivalent to PUT operation in REST HTTP.
|
|
262
|
+
*
|
|
263
|
+
* @param type The type of the event to dispatch
|
|
264
|
+
* @param updateInfo The update information.
|
|
265
|
+
*/
|
|
203
266
|
constructor(type: string, updateInfo: ContextUpdateEventDetail<T>) {
|
|
204
267
|
super(type, updateInfo);
|
|
205
268
|
}
|
|
206
269
|
}
|
|
207
270
|
|
|
271
|
+
/**
|
|
272
|
+
* An event that is dispatched to update a list of objects in the store.
|
|
273
|
+
* This is equivalent to PUT operation in REST HTTP.
|
|
274
|
+
*
|
|
275
|
+
* If there's a parent, this event only allows to update entities in bulk for the same parent.
|
|
276
|
+
*
|
|
277
|
+
* @template T The object that is being updated.
|
|
278
|
+
* @template U The object that is returned by the context store after updating. By default it is the `T`.
|
|
279
|
+
*/
|
|
280
|
+
export class ContextUpdateBulkEvent<T extends object, U = T> extends ContextEvent<ContextUpdateBulkEventDetail<T>, ContextChangeRecord<U>[]> {
|
|
281
|
+
/**
|
|
282
|
+
* An event that is dispatched to update the entire object in the store.
|
|
283
|
+
* This is equivalent to PUT operation in REST HTTP.
|
|
284
|
+
*
|
|
285
|
+
* @param type The type of the event to dispatch
|
|
286
|
+
* @param updateInfo The update information.
|
|
287
|
+
*/
|
|
288
|
+
constructor(type: string, updateInfo: ContextUpdateBulkEventDetail<T>) {
|
|
289
|
+
super(type, updateInfo);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
208
293
|
/**
|
|
209
294
|
* Data store query result object.
|
|
210
295
|
*/
|
|
@@ -244,3 +329,53 @@ export class ContextListEvent<T> extends ContextEvent<ContextListOptions, Contex
|
|
|
244
329
|
super(type, opts);
|
|
245
330
|
}
|
|
246
331
|
}
|
|
332
|
+
|
|
333
|
+
export interface IQueryDetail {
|
|
334
|
+
/**
|
|
335
|
+
* The query term. All values are always passed as string. Context store must parse value if it requires other types.
|
|
336
|
+
*/
|
|
337
|
+
term: string;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* If the context store supports it, the tags to use with the query function to limit the results.
|
|
341
|
+
*/
|
|
342
|
+
tags?: string[];
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* General purpose type to be defined by the context store.
|
|
346
|
+
* Allows to specify the type of the query to perform.
|
|
347
|
+
*/
|
|
348
|
+
type?: string;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* General purpose keyword to be defined by the context store.
|
|
352
|
+
* The purpose is to instruct the context store to perform detailed search.
|
|
353
|
+
* Usually this means longer search time but more accurate results.
|
|
354
|
+
*/
|
|
355
|
+
detailed?: boolean;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* An event dispatched to the context store to perform a query operation.
|
|
360
|
+
* If the context store supports the query operation, it should use the definition of `IQueryDetail` to perform the query.
|
|
361
|
+
* The result is the list of objects ordered by the store from the most relevant items to the least.
|
|
362
|
+
*
|
|
363
|
+
* The implementation should not assume pagination and return enough results for the user to find what they were looking for
|
|
364
|
+
* or to redefine the query. Suggested limit is `50` which in many cases is equivalent of 2 pages of results.
|
|
365
|
+
*/
|
|
366
|
+
export class ContextQueryEvent<T = unknown> extends ContextEvent<IQueryDetail, T[]> {
|
|
367
|
+
/**
|
|
368
|
+
* An event dispatched to the context store to perform a query operation.
|
|
369
|
+
* If the context store supports the query operation, it should use the definition of `IQueryDetail` to perform the query.
|
|
370
|
+
* The result is the list of objects ordered by the store from the most relevant items to the least.
|
|
371
|
+
*
|
|
372
|
+
* The implementation should not assume pagination and return enough results for the user to find what they were looking for
|
|
373
|
+
* or to redefine the query. Suggested limit is `50` which in many cases is equivalent of 2 pages of results.
|
|
374
|
+
*
|
|
375
|
+
* @param type The type of the event.
|
|
376
|
+
* @param opts The query options.
|
|
377
|
+
*/
|
|
378
|
+
constructor(type: string, opts: IQueryDetail) {
|
|
379
|
+
super(type, opts);
|
|
380
|
+
}
|
|
381
|
+
}
|