@data-weave/datamanager 0.4.3 → 0.4.5
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.
- package/lib/version.js +2 -1
- package/package.json +5 -4
- package/lib/Cache.d.ts +0 -15
- package/lib/DataManager.d.ts +0 -42
- package/lib/List.d.ts +0 -11
- package/lib/LiveList.d.ts +0 -24
- package/lib/LiveReference.d.ts +0 -21
- package/lib/Reference.d.ts +0 -15
- package/lib/index.d.ts +0 -6
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-weave/datamanager",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"author": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
"lib/**/*.d.ts"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"
|
|
13
|
-
"build
|
|
12
|
+
"clean": "rm -rf lib",
|
|
13
|
+
"build": "genversion --force --semi src/version.js && tsc",
|
|
14
|
+
"build:clean": "npm run clean && npm run build",
|
|
14
15
|
"prepare": "npm run build"
|
|
15
16
|
},
|
|
16
17
|
"repository": {
|
|
@@ -21,5 +22,5 @@
|
|
|
21
22
|
"access": "public",
|
|
22
23
|
"registry": "https://registry.npmjs.org/"
|
|
23
24
|
},
|
|
24
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "e78bab6280bc98003ab4dc48a4fda336b5c0f80f"
|
|
25
26
|
}
|
package/lib/Cache.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface Cache<K = any, V = any> {
|
|
2
|
-
get(key: K): V | undefined;
|
|
3
|
-
set(key: K, value: V): void;
|
|
4
|
-
has(key: K): boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare class MapCache<K, V> implements Cache<K, V> {
|
|
7
|
-
private cache;
|
|
8
|
-
private maxSize?;
|
|
9
|
-
constructor(maxSize?: number);
|
|
10
|
-
get(key: K): V | undefined;
|
|
11
|
-
set(key: K, value: V): void;
|
|
12
|
-
has(key: K): boolean;
|
|
13
|
-
delete(key: K): boolean;
|
|
14
|
-
clear(): void;
|
|
15
|
-
}
|
package/lib/DataManager.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { List } from './List';
|
|
2
|
-
import { IdentifiableReference, WithoutId } from './Reference';
|
|
3
|
-
export interface ReadOptions {
|
|
4
|
-
readonly transaction?: unknown;
|
|
5
|
-
}
|
|
6
|
-
export interface WriteOptions {
|
|
7
|
-
readonly transaction?: unknown;
|
|
8
|
-
readonly batcher?: unknown;
|
|
9
|
-
}
|
|
10
|
-
export interface CreateOptions extends WriteOptions {
|
|
11
|
-
id?: string;
|
|
12
|
-
merge?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export type OrderByOption = 'asc' | 'desc';
|
|
15
|
-
export interface GetListOptions {
|
|
16
|
-
readonly filterBy?: unknown;
|
|
17
|
-
readonly orderBy?: unknown;
|
|
18
|
-
readonly limit?: number;
|
|
19
|
-
}
|
|
20
|
-
export interface Metadata {
|
|
21
|
-
readonly id: string;
|
|
22
|
-
readonly createdAt: Date;
|
|
23
|
-
readonly updatedAt: Date;
|
|
24
|
-
readonly deleted: boolean;
|
|
25
|
-
}
|
|
26
|
-
export type WithMetadata<T> = T & Metadata;
|
|
27
|
-
/**
|
|
28
|
-
* DataManager is the base class for all data managers.
|
|
29
|
-
* It is responsible for reading, creating, deleting, and updating data.
|
|
30
|
-
* It is also responsible for returning references and lists.
|
|
31
|
-
* It is generic and can be used for any type of data.
|
|
32
|
-
* @template T - The type of the data to be managed.
|
|
33
|
-
*/
|
|
34
|
-
export declare abstract class DataManager<T> {
|
|
35
|
-
abstract read(id: string): Promise<T | undefined>;
|
|
36
|
-
abstract create(data: WithoutId<T>, options?: CreateOptions): Promise<IdentifiableReference<WithMetadata<T>>>;
|
|
37
|
-
abstract delete(id: string): Promise<void>;
|
|
38
|
-
abstract update(id: string, data: Partial<WithoutId<T>>): Promise<void>;
|
|
39
|
-
abstract upsert(id: string, data: WithoutId<T>): Promise<void>;
|
|
40
|
-
abstract getRef(id: string): IdentifiableReference<WithMetadata<T>>;
|
|
41
|
-
abstract getList(params?: GetListOptions): List<WithMetadata<T>>;
|
|
42
|
-
}
|
package/lib/List.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Resolvable } from './Reference';
|
|
2
|
-
export interface ListPaginationParams {
|
|
3
|
-
readonly pageSize?: number;
|
|
4
|
-
readonly append?: boolean;
|
|
5
|
-
readonly loadFirstPageManually?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface List<T> extends Resolvable<readonly T[]> {
|
|
8
|
-
readonly values: readonly T[];
|
|
9
|
-
}
|
|
10
|
-
export declare function createInitializedList<T>(values: ReadonlyArray<T>): List<T>;
|
|
11
|
-
export declare function createEmptyList<T>(): List<T>;
|
package/lib/LiveList.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { List } from './List';
|
|
2
|
-
export interface LiveListOptions<T> {
|
|
3
|
-
onUpdate?: (newValues: T[]) => void;
|
|
4
|
-
onError?: (error: unknown) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare class LiveList<T> implements List<T> {
|
|
7
|
-
private _values;
|
|
8
|
-
private _resolved;
|
|
9
|
-
private _hasError;
|
|
10
|
-
private _options;
|
|
11
|
-
constructor(options: LiveListOptions<T>);
|
|
12
|
-
resolve(): Promise<readonly T[]>;
|
|
13
|
-
get values(): T[];
|
|
14
|
-
get hasError(): boolean;
|
|
15
|
-
get resolved(): boolean;
|
|
16
|
-
protected setStale(): void;
|
|
17
|
-
protected onValuesChange(): void;
|
|
18
|
-
protected onUpdate(): void;
|
|
19
|
-
protected onUpdateAll(values: T[]): void;
|
|
20
|
-
protected onUpdateAtIndex(index: number, value: T): void;
|
|
21
|
-
protected onAddAtIndex(index: number, value: T): void;
|
|
22
|
-
protected onRemoveAtIndex(index: number): void;
|
|
23
|
-
protected onError(error: unknown): void;
|
|
24
|
-
}
|
package/lib/LiveReference.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Reference } from './Reference';
|
|
2
|
-
export interface LiveReferenceOptions<T> {
|
|
3
|
-
onUpdate?: (newValue: T | undefined) => void;
|
|
4
|
-
onError?: (error: unknown) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare class LiveReference<T> implements Reference<T> {
|
|
7
|
-
readonly options: LiveReferenceOptions<T>;
|
|
8
|
-
private _value;
|
|
9
|
-
private _resolved;
|
|
10
|
-
private _hasError;
|
|
11
|
-
private _options;
|
|
12
|
-
resolve(): Promise<T | undefined>;
|
|
13
|
-
constructor(options: LiveReferenceOptions<T>);
|
|
14
|
-
get value(): T | undefined;
|
|
15
|
-
get resolved(): boolean;
|
|
16
|
-
get hasError(): boolean;
|
|
17
|
-
protected setStale(): void;
|
|
18
|
-
protected onUpdate(data: T | undefined): void;
|
|
19
|
-
protected onError(error: unknown): void;
|
|
20
|
-
protected onValueChange(): void;
|
|
21
|
-
}
|
package/lib/Reference.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface Identifiable {
|
|
2
|
-
readonly id: string;
|
|
3
|
-
}
|
|
4
|
-
export type WithoutId<T> = Omit<T, 'id'>;
|
|
5
|
-
export interface Resolvable<T> {
|
|
6
|
-
readonly resolved: boolean;
|
|
7
|
-
readonly hasError: boolean;
|
|
8
|
-
resolve(): Promise<T>;
|
|
9
|
-
}
|
|
10
|
-
export interface Reference<T> extends Resolvable<T | undefined> {
|
|
11
|
-
readonly value: T | undefined;
|
|
12
|
-
}
|
|
13
|
-
export type IdentifiableReference<T> = Reference<T> & Identifiable;
|
|
14
|
-
export declare function createInitializedIdentifiableReference<T>(value: T | undefined, id: string): Reference<T> & Identifiable;
|
|
15
|
-
export declare function createEmptyIdentifiableReference<T>(id: string): Reference<T>;
|