@@ -231,12 +231,189 @@ declare namespace dojo {
231231 interface SimpleQueryEngine extends api . QueryEngine < Object , api . BaseQueryType > { }
232232 }
233233
234+ /* dojo/store/Cache */
235+
236+ interface CacheOptions {
237+ /**
238+ * This is a function that will be called for each item in a query response to determine
239+ * if it is cacheable. If isLoaded returns true, the item will be cached, otherwise it
240+ * will not be cached. If isLoaded is not provided, all items will be cached.
241+ */
242+ isLoaded ?: Function ;
243+ }
244+
245+ interface CacheMixin {
246+ /**
247+ * Remove the object with the specific id.
248+ */
249+ remove ( id : string | number ) : promise . Promise < void > ;
250+
251+ /**
252+ * Remove the object with the given id from the underlying caching store.
253+ */
254+ evict ( id : string | number ) : promise . Promise < void > ;
255+ }
256+
257+ interface Cache {
258+ /**
259+ * The Cache store wrapper takes a master store and a caching store,
260+ * caches data from the master into the caching store for faster
261+ * lookup. Normally one would use a memory store for the caching
262+ * store and a server store like JsonRest for the master store.
263+ */
264+ < T , Q extends api . BaseQueryType , O extends api . QueryOptions , S extends api . Store < T , Q , O > > ( masterStore : S , cacheStore : api . Store < T , Q , O > , options ?: CacheOptions ) : CacheMixin & S ;
265+ }
266+
267+ /* dojo/store/DataStore */
268+
269+ interface DataStoreOptions < T > {
270+ idProperty ?: string ;
271+ queryEngine ?: api . QueryEngine < T , api . QueryOptions > ;
272+ store ?: data . api . Read < T > | data . api . Write < T > | data . api . Identity < T > ;
273+ }
274+
275+ interface DataStore < T extends Object > extends api . Store < T , api . BaseQueryType , api . QueryOptions > {
276+ /**
277+ * The object store to convert to a data store
278+ */
279+ store : data . api . Read < T > | data . api . Write < T > | data . api . Identity < T > ;
280+
281+ /**
282+ * Defines the query engine to use for querying the data store
283+ */
284+ queryEngine : api . QueryEngine < T , api . BaseQueryType > ;
285+
286+ _objectConverter ( callback : ( item : T ) => any ) : ( item : T ) => any ;
287+ }
288+
289+ interface DataStoreConstructor extends _base . DeclareConstructor < DataStore < Object > > {
290+ new < T > ( options ?: DataStoreOptions < T > ) : DataStore < T > ;
291+ }
292+
293+ /* dojo/store/JsonRest */
294+
295+ interface Headers {
296+ [ header : string ] : string ;
297+ }
298+
299+ interface JsonRestPutDirectives < T > extends api . PutDirectives < T > {
300+ headers ?: Headers ;
301+ }
302+
303+ interface JsonRestQueryOptions extends api . QueryOptions {
304+ headers ?: Headers ;
305+ }
306+
307+ interface JsonRestOptions < T extends Object > {
308+ idProperty ?: string ;
309+ queryEngine ?: api . QueryEngine < T , JsonRestQueryOptions > ;
310+ headers ?: Headers ;
311+ target ?: string ;
312+ rangeParam ?: string ;
313+ sortParam ?: string ;
314+ ascendingPrefix ?: string ;
315+ descendingPrefix ?: string ;
316+ accepts ?: string ;
317+ }
318+
319+ interface JsonRest < T , Q extends api . BaseQueryType , O extends JsonRestQueryOptions > {
320+ /**
321+ * Additional headers to pass in all requests to the server. These can be overridden
322+ * by passing additional headers to calls to the store.
323+ */
324+ headers : Headers ;
325+
326+ /**
327+ * The target base URL to use for all requests to the server. This string will be
328+ * prepended to the id to generate the URL (relative or absolute) for requests
329+ * sent to the server
330+ */
331+ target : string ;
332+
333+ /**
334+ * Indicates the property to use as the identity property. The values of this
335+ * property should be unique.
336+ */
337+ idProperty : string ;
338+
339+ /**
340+ * Use a query parameter for the requested range. If this is omitted, than the
341+ * Range header will be used. Independent of this, the X-Range header is always set.
342+ */
343+ rangeParam ?: string ;
344+
345+ /**
346+ * The query parameter to used for holding sort information. If this is omitted, than
347+ * the sort information is included in a functional query token to avoid colliding
348+ * with the set of name/value pairs.
349+ */
350+ sortParam ?: string ;
351+
352+ /**
353+ * The prefix to apply to sort attribute names that are ascending
354+ */
355+ ascendingPrefix : string ;
356+
357+ /**
358+ * The prefix to apply to sort attribute names that are descending
359+ */
360+ descendingPrefix : string ;
361+
362+ /**
363+ * If the target has no trailing '/', then append it.
364+ */
365+ _getTarget ( id : string | number ) : string ;
366+
367+ /**
368+ * Retrieves an object by its identity. This will trigger a GET request to the server using
369+ * the url `this.target + id`.
370+ */
371+ get ( id : string | number , options ?: { headers : Headers } | Headers ) : promise . Promise < T > ;
372+
373+ /**
374+ * Defines the Accept header to use on HTTP requests
375+ */
376+ accepts : string ;
377+
378+ /**
379+ * Returns an object's identity
380+ */
381+ getIdentity ( object : T ) : string | number ;
382+
383+ /**
384+ * Stores an object. This will trigger a PUT request to the server
385+ * if the object has an id, otherwise it will trigger a POST request.
386+ */
387+ put ( object : T , options ?: JsonRestPutDirectives < T > ) : promise . Promise < T > ;
388+
389+ /**
390+ * Adds an object. This will trigger a PUT request to the server
391+ * if the object has an id, otherwise it will trigger a POST request.
392+ */
393+ add ( object : T , options ?: JsonRestPutDirectives < T > ) : promise . Promise < T > ;
394+
395+ /**
396+ * Deletes an object by its identity. This will trigger a DELETE request to the server.
397+ */
398+ remove ( id : string | number , options ?: { headers : Headers } ) : promise . Promise < void > ;
399+
400+ /**
401+ * Queries the store for objects. This will trigger a GET request to the server, with the
402+ * query added as a query string.
403+ */
404+ query ( query : Q , options ?: O ) : api . QueryResults < T > ;
405+ }
406+
407+ interface JsonRestConstrcutor extends _base . DeclareConstructor < JsonRest < Object , api . BaseQueryType , JsonRestQueryOptions > > {
408+ new < T extends Object , Q extends api . BaseQueryType , O extends JsonRestQueryOptions > ( options ?: JsonRestOptions < T > ) : JsonRest < T , Q , O > ;
409+ }
410+
234411 /* dojo/store/Memory */
235412
236413 interface MemoryOptions < T extends Object > {
237414 data ?: T [ ] ;
238415 idProperty ?: string ;
239- queryEngine ?: api . QueryEngine < any , any > ;
416+ queryEngine ?: api . QueryEngine < T , api . QueryOptions > ;
240417 setData ?: ( data : T [ ] ) => void ;
241418 }
242419
@@ -257,12 +434,38 @@ declare namespace dojo {
257434 setData ( data : T [ ] ) : void ;
258435 }
259436
260- interface MemoryConstructor {
437+ interface MemoryConstructor extends _base . DeclareConstructor < Memory < Object > > {
261438 /**
262439 * This is a basic in-memory object store. It implements dojo/store/api/Store.
263440 */
264441 new < T extends Object > ( options ?: MemoryOptions < T > ) : Memory < T > ;
265442 }
266443
444+ /* dojo/store/Observable */
445+
446+ interface ObservableQueryResults < T > extends api . QueryResults < T > {
447+ /**
448+ * Allows observation of results
449+ */
450+ observe ( listener : ( object : T , previousIndex : number , newIndex : number ) => void , includeUpdates ?: boolean ) : {
451+ remove ( ) : void ;
452+ cancel ( ) : void ;
453+ } ;
454+ }
455+
456+ interface ObservableMixin < T , Q extends api . BaseQueryType , O extends api . QueryOptions > {
457+ notify ( object : T , existingId : string | number ) : void ;
458+
459+ /**
460+ * Queries the store for objects. This does not alter the store, but returns a
461+ * set of data from the store.
462+ */
463+ query ( query : Q , options ?: O ) : ObservableQueryResults < T > ;
464+ }
465+
466+ interface Observable {
467+ < T , Q extends api . BaseQueryType , O extends api . QueryOptions , S extends api . Store < T , Q , O > > ( store : S ) : ObservableMixin < T , Q , O > & S ;
468+ }
469+
267470 }
268471}
0 commit comments