Alex Rickabaugh d442b6855f feat(service-worker): introduce the @angular/service-worker package (#19274)
This service worker is a conceptual derivative of the existing @angular/service-worker maintained at github.com/angular/mobile-toolkit, but has been rewritten to support use across a much wider variety of applications.

Entrypoints include:

@angular/service-worker: a library for use within Angular client apps to communicate with the service worker.
@angular/service-worker/gen: a library for generating ngsw.json files from glob-based SW config files.
@angular/service-worker/ngsw-worker.js: the bundled service worker script itself.
@angular/service-worker/ngsw-cli.js: a CLI tool for generating ngsw.json files from glob-based SW config files.
2017-09-28 16:18:12 -07:00

61 lines
1.3 KiB
TypeScript

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* An abstract table, with the ability to read/write objects stored under keys.
*/
export interface Table {
/**
* Delete a key from the table.
*/
'delete'(key: string): Promise<boolean>;
/**
* List all the keys currently stored in the table.
*/
keys(): Promise<string[]>;
/**
* Read a key from a table, either as an Object or with a given type.
*/
read(key: string): Promise<Object>;
read<T>(key: string): Promise<T>;
/**
* Write a new value for a key to the table, overwriting any previous value.
*/
write(key: string, value: Object): Promise<void>;
}
/**
* An abstract database, consisting of multiple named `Table`s.
*/
export interface Database {
/**
* Delete an entire `Table` from the database, by name.
*/
'delete'(table: string): Promise<boolean>;
/**
* List all `Table`s by name.
*/
list(): Promise<string[]>;
/**
* Open a `Table`.
*/
open(table: string): Promise<Table>;
}
/**
* An error returned in rejected promises if the given key is not found in the table.
*/
export class NotFound {
constructor(public table: string, public key: string) {}
}