##// END OF EJS Templates
added type parameter to dojo.store.api.SortInformation,...
cin -
r20:1c7650c17856 v1.0.8 default
parent child
Show More
@@ -46,7 +46,7 declare namespace dijit {
46 /* dijit/form/_AutoCompleterMixin */
46 /* dijit/form/_AutoCompleterMixin */
47
47
48 /* tslint:disable:class-name */
48 /* tslint:disable:class-name */
49 interface _AutoCompleterMixin<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions> extends _SearchMixin<T, Q, O> {
49 interface _AutoCompleterMixin<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>> extends _SearchMixin<T, Q, O> {
50 /**
50 /**
51 * This is the item returned by the dojo/store/api/Store implementation that
51 * This is the item returned by the dojo/store/api/Store implementation that
52 * provides the data for this ComboBox, it's the currently selected item.
52 * provides the data for this ComboBox, it's the currently selected item.
@@ -250,7 +250,7 declare namespace dijit {
250 /**
250 /**
251 * Fills in the items in the drop down list
251 * Fills in the items in the drop down list
252 */
252 */
253 createOptions(results: T[], options: dojo.store.api.QueryOptions, labelFunc: (item: T) => { html: boolean; label: string; }): void;
253 createOptions(results: T[], options: dojo.store.api.QueryOptions<T>, labelFunc: (item: T) => { html: boolean; label: string; }): void;
254
254
255 /**
255 /**
256 * Clears the entries in the drop down list, but of course keeps the previous and next buttons.
256 * Clears the entries in the drop down list, but of course keeps the previous and next buttons.
@@ -470,7 +470,7 declare namespace dijit {
470 disabled?: boolean;
470 disabled?: boolean;
471 }
471 }
472
472
473 interface _FormSelectWidget<T extends Object, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions> extends _FormValueWidget {
473 interface _FormSelectWidget<T extends Object, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>> extends _FormValueWidget {
474 /**
474 /**
475 * Whether or not we are multi-valued
475 * Whether or not we are multi-valued
476 */
476 */
@@ -869,7 +869,7 declare namespace dijit {
869
869
870 /* dijit/form/_SearchMixin */
870 /* dijit/form/_SearchMixin */
871
871
872 interface _SearchMixin<T extends Object, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions> {
872 interface _SearchMixin<T extends Object, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>> {
873 /**
873 /**
874 * Argument to data provider.
874 * Argument to data provider.
875 * Specifies maximum number of search results to return per query
875 * Specifies maximum number of search results to return per query
@@ -1170,18 +1170,18 declare namespace dijit {
1170
1170
1171 /* dijit/form/ComboBox */
1171 /* dijit/form/ComboBox */
1172
1172
1173 interface ComboBox<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions, C extends Constraints = Constraints> extends ValidationTextBox<C>, ComboBoxMixin<T, Q, O> {
1173 interface ComboBox<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>, C extends Constraints = Constraints> extends ValidationTextBox<C>, ComboBoxMixin<T, Q, O> {
1174 // set(name: string, value: any): this;
1174 // set(name: string, value: any): this;
1175 // set(values: Object): this;
1175 // set(values: Object): this;
1176 }
1176 }
1177
1177
1178 interface ComboBoxConstructor extends _WidgetBaseConstructor<ComboBox<any>> {
1178 interface ComboBoxConstructor extends _WidgetBaseConstructor<ComboBox<any>> {
1179 new <T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions, C extends Constraints = Constraints>(params: Object, srcNodeRef: dojo.NodeOrString): ComboBox<T, Q, O, C>;
1179 new <T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>, C extends Constraints = Constraints>(params: Object, srcNodeRef: dojo.NodeOrString): ComboBox<T, Q, O, C>;
1180 }
1180 }
1181
1181
1182 /* dijit/form/ComboBoxMixin */
1182 /* dijit/form/ComboBoxMixin */
1183
1183
1184 interface ComboBoxMixin<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions> extends _HasDropDown<_ComboBoxMenu<T>>, _AutoCompleterMixin<T, Q, O> {
1184 interface ComboBoxMixin<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>> extends _HasDropDown<_ComboBoxMenu<T>>, _AutoCompleterMixin<T, Q, O> {
1185
1185
1186 /**
1186 /**
1187 * Dropdown widget class used to select a date/time.
1187 * Dropdown widget class used to select a date/time.
@@ -1315,7 +1315,7 declare namespace dijit {
1315
1315
1316 /* dijit/form/FilteringSelect */
1316 /* dijit/form/FilteringSelect */
1317
1317
1318 interface FilteringSelect<C extends Constraints, T extends Object, Q extends string | Object | Function, O extends dojo.store.api.QueryOptions> extends MappedTextBox<C>, ComboBoxMixin<T, Q, O> {
1318 interface FilteringSelect<C extends Constraints, T extends Object, Q extends string | Object | Function, O extends dojo.store.api.QueryOptions<T>> extends MappedTextBox<C>, ComboBoxMixin<T, Q, O> {
1319 /**
1319 /**
1320 * True (default) if user is required to enter a value into this field.
1320 * True (default) if user is required to enter a value into this field.
1321 */
1321 */
@@ -1341,7 +1341,7 declare namespace dijit {
1341 }
1341 }
1342
1342
1343 interface FilteringSelectConstructor extends _WidgetBaseConstructor<FilteringSelect<any, any, any, any>> {
1343 interface FilteringSelectConstructor extends _WidgetBaseConstructor<FilteringSelect<any, any, any, any>> {
1344 new <C extends Constraints, T extends Object, Q extends string | Object | Function, O extends dojo.store.api.QueryOptions>(params: Object, srcNodeRef: dojo.NodeOrString): FilteringSelect<C, T, Q, O>;
1344 new <C extends Constraints, T extends Object, Q extends string | Object | Function, O extends dojo.store.api.QueryOptions<T>>(params: Object, srcNodeRef: dojo.NodeOrString): FilteringSelect<C, T, Q, O>;
1345 }
1345 }
1346
1346
1347 /* dijit/form/Form */
1347 /* dijit/form/Form */
@@ -1691,7 +1691,7 declare namespace dijit {
1691
1691
1692 /* dijit/form/Select */
1692 /* dijit/form/Select */
1693
1693
1694 interface Select<T extends Object, Q extends dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions, U extends dijit._WidgetBase> extends _FormSelectWidget<T, Q, O>, _HasDropDown<U>, _KeyNavMixin {
1694 interface Select<T extends Object, Q extends dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T>, U extends dijit._WidgetBase> extends _FormSelectWidget<T, Q, O>, _HasDropDown<U>, _KeyNavMixin {
1695 baseClass: string;
1695 baseClass: string;
1696
1696
1697 /**
1697 /**
@@ -332,7 +332,7 declare module 'dijit/form/DropDownButto
332 }
332 }
333
333
334 declare module 'dijit/form/FilteringSelect' {
334 declare module 'dijit/form/FilteringSelect' {
335 type FilteringSelect<C extends dijit.form.Constraints = dijit.form.Constraints, T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions> = dijit.form.FilteringSelect<C, T, Q, O>;
335 type FilteringSelect<C extends dijit.form.Constraints = dijit.form.Constraints, T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>> = dijit.form.FilteringSelect<C, T, Q, O>;
336 const FilteringSelect: dijit.form.FilteringSelectConstructor;
336 const FilteringSelect: dijit.form.FilteringSelectConstructor;
337 export = FilteringSelect;
337 export = FilteringSelect;
338 }
338 }
@@ -9,12 +9,12 declare namespace dojo {
9
9
10 /* dojo/store/api/Store */
10 /* dojo/store/api/Store */
11
11
12 interface SortInformation {
12 interface SortInformation<K extends string | number | symbol = string> {
13
13
14 /**
14 /**
15 * The name of the attribute to sort on.
15 * The name of the attribute to sort on.
16 */
16 */
17 attribute: string;
17 attribute: K;
18
18
19 /**
19 /**
20 * The direction of the sort. Default is false.
20 * The direction of the sort. Default is false.
@@ -22,7 +22,9 declare namespace dojo {
22 descending?: boolean;
22 descending?: boolean;
23 }
23 }
24
24
25 interface QueryOptions {
25 type SortFn<T> = (left: T, right: T) => number;
26
27 interface QueryOptions<T = unknown> {
26 /**
28 /**
27 * A list of attributes to sort on, as well as direction
29 * A list of attributes to sort on, as well as direction
28 * For example:
30 * For example:
@@ -30,7 +32,7 declare namespace dojo {
30 * If the sort parameter is omitted, then the natural order of the store may be
32 * If the sort parameter is omitted, then the natural order of the store may be
31 * applied if there is a natural order.
33 * applied if there is a natural order.
32 */
34 */
33 sort?: SortInformation[];
35 sort?: SortFn<T> | SortInformation<keyof T>[];
34
36
35 /**
37 /**
36 * The first result to begin iteration on
38 * The first result to begin iteration on
@@ -51,7 +53,7 declare namespace dojo {
51 type BaseQueryType = string | object | ((...params: unknown[]) => boolean);
53 type BaseQueryType = string | object | ((...params: unknown[]) => boolean);
52
54
53 interface QueryEngine<T extends object, Q extends BaseQueryType> {
55 interface QueryEngine<T extends object, Q extends BaseQueryType> {
54 <O extends QueryOptions>(query: Q, options?: O): QueryEngineFunction<T>;
56 <O extends QueryOptions<T>>(query: Q, options?: O): QueryEngineFunction<T>;
55 }
57 }
56
58
57 interface PutDirectives<T extends object> {
59 interface PutDirectives<T extends object> {
@@ -173,7 +175,7 declare namespace dojo {
173 interface Queryable<
175 interface Queryable<
174 T extends object,
176 T extends object,
175 Q extends BaseQueryType,
177 Q extends BaseQueryType,
176 O extends QueryOptions,
178 O extends QueryOptions<T>,
177 R extends QueryResults<T> = QueryResults<T>> {
179 R extends QueryResults<T> = QueryResults<T>> {
178
180
179 /**
181 /**
@@ -183,7 +185,7 declare namespace dojo {
183 query(query?: Q, options?: O): R;
185 query(query?: Q, options?: O): R;
184 }
186 }
185
187
186 interface SyncStore<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions = QueryOptions>
188 interface SyncStore<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions<T> = QueryOptions<T>>
187 extends IdentityProvider<T>, Queryable<T, Q, O, SyncQueryResults<T>> {
189 extends IdentityProvider<T>, Queryable<T, Q, O, SyncQueryResults<T>> {
188
190
189 /**
191 /**
@@ -223,7 +225,7 declare namespace dojo {
223
225
224 }
226 }
225
227
226 interface AsyncStore<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions = QueryOptions>
228 interface AsyncStore<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions<T> = QueryOptions<T>>
227 extends IdentityProvider<T>, Queryable<T, Q, O, AsyncQueryResults<T>> {
229 extends IdentityProvider<T>, Queryable<T, Q, O, AsyncQueryResults<T>> {
228
230
229 /**
231 /**
@@ -263,7 +265,7 declare namespace dojo {
263
265
264 }
266 }
265
267
266 interface HierarchicalStore<T extends object, O extends QueryOptions = QueryOptions, R extends QueryResults<T> = QueryResults<T>> {
268 interface HierarchicalStore<T extends object, O extends QueryOptions<T> = QueryOptions<T>, R extends QueryResults<T> = QueryResults<T>> {
267
269
268 /**
270 /**
269 * Retrieves the children of an object.
271 * Retrieves the children of an object.
@@ -271,7 +273,7 declare namespace dojo {
271 getChildren(parent: T, options?: O): R;
273 getChildren(parent: T, options?: O): R;
272 }
274 }
273
275
274 interface Store<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions = QueryOptions>
276 interface Store<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions<T> = QueryOptions<T>>
275 extends IdentityProvider<T>, Queryable<T, Q, O> {
277 extends IdentityProvider<T>, Queryable<T, Q, O> {
276
278
277 /**
279 /**
@@ -370,11 +372,11 declare namespace dojo {
370
372
371 interface DataStoreOptions<T extends object> {
373 interface DataStoreOptions<T extends object> {
372 idProperty?: keyof T;
374 idProperty?: keyof T;
373 queryEngine?: api.QueryEngine<T, api.QueryOptions>;
375 queryEngine?: api.QueryEngine<T, api.QueryOptions<T>>;
374 store?: data.api.Read<T> | data.api.Write<T> | data.api.Identity<T>;
376 store?: data.api.Read<T> | data.api.Write<T> | data.api.Identity<T>;
375 }
377 }
376
378
377 interface DataStore<T extends object> extends api.Store<T, api.BaseQueryType, api.QueryOptions> {
379 interface DataStore<T extends object> extends api.Store<T, api.BaseQueryType, api.QueryOptions<T>> {
378 /**
380 /**
379 * The object store to convert to a data store
381 * The object store to convert to a data store
380 */
382 */
@@ -406,7 +408,7 declare namespace dojo {
406 timeout?: number
408 timeout?: number
407 }
409 }
408
410
409 interface JsonRestQueryOptions extends api.QueryOptions {
411 interface JsonRestQueryOptions<T = unknown> extends api.QueryOptions<T> {
410 headers?: Headers;
412 headers?: Headers;
411
413
412 timeout?: number;
414 timeout?: number;
@@ -414,7 +416,7 declare namespace dojo {
414
416
415 interface JsonRestOptions<T extends object> {
417 interface JsonRestOptions<T extends object> {
416 idProperty?: keyof T;
418 idProperty?: keyof T;
417 queryEngine?: api.QueryEngine<T, JsonRestQueryOptions>;
419 queryEngine?: api.QueryEngine<T, JsonRestQueryOptions<T>>;
418 headers?: Headers;
420 headers?: Headers;
419 target?: string;
421 target?: string;
420 rangeParam?: string;
422 rangeParam?: string;
@@ -427,7 +429,7 declare namespace dojo {
427 interface JsonRest<
429 interface JsonRest<
428 T extends object,
430 T extends object,
429 Q extends api.BaseQueryType = (Partial<T> | string) & api.BaseQueryType,
431 Q extends api.BaseQueryType = (Partial<T> | string) & api.BaseQueryType,
430 O extends JsonRestQueryOptions = JsonRestQueryOptions>
432 O extends JsonRestQueryOptions<T> = JsonRestQueryOptions<T>>
431 extends api.AsyncStore<T, Q, O> {
433 extends api.AsyncStore<T, Q, O> {
432 /**
434 /**
433 * Additional headers to pass in all requests to the server. These can be overridden
435 * Additional headers to pass in all requests to the server. These can be overridden
@@ -509,7 +511,7 declare namespace dojo {
509 interface MemoryOptions<T extends object> {
511 interface MemoryOptions<T extends object> {
510 data?: T[];
512 data?: T[];
511 idProperty?: keyof T;
513 idProperty?: keyof T;
512 queryEngine?: api.QueryEngine<T, api.QueryOptions>;
514 queryEngine?: api.QueryEngine<T, api.QueryOptions<T>>;
513 setData?: (data: T[]) => void;
515 setData?: (data: T[]) => void;
514 }
516 }
515
517
@@ -551,7 +553,7 declare namespace dojo {
551
553
552 type ObservableQueryResults<T extends object> = ObservableQueryResultsMixin<T> & api.QueryResults<T>;
554 type ObservableQueryResults<T extends object> = ObservableQueryResultsMixin<T> & api.QueryResults<T>;
553
555
554 interface ObservableMixin<T extends object, Q extends api.BaseQueryType, O extends api.QueryOptions, R extends api.QueryResults<T> = api.QueryResults<T> > {
556 interface ObservableMixin<T extends object, Q extends api.BaseQueryType, O extends api.QueryOptions<T>, R extends api.QueryResults<T> = api.QueryResults<T> > {
555 notify(object: T, existingId?: api.Identity): void;
557 notify(object: T, existingId?: api.Identity): void;
556
558
557 /**
559 /**
@@ -19,7 +19,8 const mem = new Memory<Schedule>();
19 observable.query().observe(() => { });
19 observable.query().observe(() => { });
20 store.query().forEach(() => { });
20 store.query().forEach(() => { });
21 const total = await store.query().total;
21 const total = await store.query().total;
22 const result = await store.query();
22 const res1 = await store.query(undefined, { sort: [{ attribute: "duration", descending: true }] });
23 const res2 = await store.query(undefined, { sort: ({ duration: a }, { duration: b }) => a - b });
23
24
24 mem.query();
25 mem.query();
25
26
General Comments 0
You need to be logged in to leave comments. Login now