shelving 1.33.0 → 1.34.0
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/package.json +7 -7
- package/query/Filters.d.ts +1 -0
- package/query/Filters.js +5 -0
- package/query/Query.d.ts +4 -2
- package/query/Query.js +8 -2
- package/query/Sorts.d.ts +1 -0
- package/query/Sorts.js +6 -1
- package/query/types.d.ts +7 -2
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"state-management",
|
|
12
12
|
"query-builder"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.34.0",
|
|
15
15
|
"repository": "https://github.com/dhoulb/shelving",
|
|
16
16
|
"author": "Dave Houlbrooke <dave@shax.com>",
|
|
17
17
|
"license": "0BSD",
|
|
@@ -63,20 +63,20 @@
|
|
|
63
63
|
"@types/jest": "^27.0.3",
|
|
64
64
|
"@types/react": "^17.0.37",
|
|
65
65
|
"@types/react-dom": "^17.0.11",
|
|
66
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
67
|
-
"@typescript-eslint/parser": "^5.
|
|
68
|
-
"eslint": "^8.
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^5.7.0",
|
|
67
|
+
"@typescript-eslint/parser": "^5.7.0",
|
|
68
|
+
"eslint": "^8.5.0",
|
|
69
69
|
"eslint-config-prettier": "^8.3.0",
|
|
70
70
|
"eslint-plugin-import": "^2.25.3",
|
|
71
71
|
"eslint-plugin-prettier": "^4.0.0",
|
|
72
72
|
"firebase": "^9.6.1",
|
|
73
|
-
"jest": "^27.4.
|
|
73
|
+
"jest": "^27.4.5",
|
|
74
74
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
75
75
|
"prettier": "^2.5.1",
|
|
76
76
|
"react": "^17.0.2",
|
|
77
77
|
"react-dom": "^17.0.2",
|
|
78
|
-
"ts-jest": "^27.1.
|
|
79
|
-
"typescript": "^4.5.
|
|
78
|
+
"ts-jest": "^27.1.2",
|
|
79
|
+
"typescript": "^4.5.4"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"@google-cloud/firestore": ">=4.0.0",
|
package/query/Filters.d.ts
CHANGED
|
@@ -13,5 +13,6 @@ export declare class Filters<T extends Data> extends Rules<T, Filter<T>> impleme
|
|
|
13
13
|
gt<K extends QueryKey<T>>(key: K, value: K extends "id" ? string : T[K]): this;
|
|
14
14
|
gte<K extends QueryKey<T>>(key: K, value: K extends "id" ? string : T[K]): this;
|
|
15
15
|
match(entry: Entry<T>): boolean;
|
|
16
|
+
get unfiltered(): this;
|
|
16
17
|
transform(iterable: Results<T>): Results<T>;
|
|
17
18
|
}
|
package/query/Filters.js
CHANGED
|
@@ -3,6 +3,7 @@ import { ArrayContainsFilter, EqualFilter, GreaterThanEqualFilter, GreaterThanFi
|
|
|
3
3
|
import { Rules } from "./Rules.js";
|
|
4
4
|
/** A set of filters. */
|
|
5
5
|
export class Filters extends Rules {
|
|
6
|
+
// Implement `Filterable`
|
|
6
7
|
is(key, value) {
|
|
7
8
|
return { __proto__: Object.getPrototypeOf(this), ...this, _rules: [...this._rules, new EqualFilter(key, value)] };
|
|
8
9
|
}
|
|
@@ -33,6 +34,10 @@ export class Filters extends Rules {
|
|
|
33
34
|
return false;
|
|
34
35
|
return true;
|
|
35
36
|
}
|
|
37
|
+
get unfiltered() {
|
|
38
|
+
return { __proto__: Object.getPrototypeOf(this), ...this, _rules: [] };
|
|
39
|
+
}
|
|
40
|
+
// Implement `Rule`
|
|
36
41
|
transform(iterable) {
|
|
37
42
|
return this._rules.length ? yieldFiltered(iterable, this) : iterable;
|
|
38
43
|
}
|
package/query/Query.d.ts
CHANGED
|
@@ -17,9 +17,11 @@ export declare class Query<T extends Data> extends Rule<T> implements Queryable<
|
|
|
17
17
|
lte<K extends QueryKey<T>>(key: K, value: K extends "id" ? string : T[K]): this;
|
|
18
18
|
gt<K extends QueryKey<T>>(key: K, value: K extends "id" ? string : T[K]): this;
|
|
19
19
|
gte<K extends QueryKey<T>>(key: K, value: K extends "id" ? string : T[K]): this;
|
|
20
|
+
get unfiltered(): this;
|
|
20
21
|
match(entry: Entry<T>): boolean;
|
|
21
|
-
asc(key
|
|
22
|
-
desc(key
|
|
22
|
+
asc(key: QueryKey<T>): this;
|
|
23
|
+
desc(key: QueryKey<T>): this;
|
|
24
|
+
get unsorted(): this;
|
|
23
25
|
rank(left: Entry<T>, right: Entry<T>): number;
|
|
24
26
|
/** Return a new instance of this class with a limit defined. */
|
|
25
27
|
max(limit: number | null): this;
|
package/query/Query.js
CHANGED
|
@@ -40,16 +40,22 @@ export class Query extends Rule {
|
|
|
40
40
|
gte(key, value) {
|
|
41
41
|
return { __proto__: Object.getPrototypeOf(this), ...this, filters: this.filters.gte(key, value) };
|
|
42
42
|
}
|
|
43
|
+
get unfiltered() {
|
|
44
|
+
return { __proto__: Object.getPrototypeOf(this), ...this, filters: this.filters.unfiltered };
|
|
45
|
+
}
|
|
43
46
|
match(entry) {
|
|
44
47
|
return this.filters.match(entry);
|
|
45
48
|
}
|
|
46
49
|
// Implement `Sortable`
|
|
47
|
-
asc(key
|
|
50
|
+
asc(key) {
|
|
48
51
|
return { __proto__: Object.getPrototypeOf(this), ...this, sorts: this.sorts.asc(key) };
|
|
49
52
|
}
|
|
50
|
-
desc(key
|
|
53
|
+
desc(key) {
|
|
51
54
|
return { __proto__: Object.getPrototypeOf(this), ...this, sorts: this.sorts.desc(key) };
|
|
52
55
|
}
|
|
56
|
+
get unsorted() {
|
|
57
|
+
return { __proto__: Object.getPrototypeOf(this), ...this, sorts: this.sorts.unsorted };
|
|
58
|
+
}
|
|
53
59
|
rank(left, right) {
|
|
54
60
|
return this.sorts.rank(left, right);
|
|
55
61
|
}
|
package/query/Sorts.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { Rules } from "./Rules.js";
|
|
|
6
6
|
export declare class Sorts<T extends Data> extends Rules<T, Sort<T>> implements Sortable<T> {
|
|
7
7
|
asc(key: QueryKey<T>): this;
|
|
8
8
|
desc(key: QueryKey<T>): this;
|
|
9
|
+
get unsorted(): this;
|
|
9
10
|
rank(left: Entry<T>, right: Entry<T>): number;
|
|
10
11
|
transform(iterable: Results<T>): Results<T>;
|
|
11
12
|
}
|
package/query/Sorts.js
CHANGED
|
@@ -3,20 +3,25 @@ import { AscendingSort, DescendingSort } from "./Sort.js";
|
|
|
3
3
|
import { Rules } from "./Rules.js";
|
|
4
4
|
/** A set of sorts. */
|
|
5
5
|
export class Sorts extends Rules {
|
|
6
|
+
// Implement `Sortable`
|
|
6
7
|
asc(key) {
|
|
7
8
|
return { __proto__: Object.getPrototypeOf(this), ...this, _rules: [...this._rules, new AscendingSort(key)] };
|
|
8
9
|
}
|
|
9
10
|
desc(key) {
|
|
10
11
|
return { __proto__: Object.getPrototypeOf(this), ...this, _rules: [...this._rules, new DescendingSort(key)] };
|
|
11
12
|
}
|
|
13
|
+
get unsorted() {
|
|
14
|
+
return { __proto__: Object.getPrototypeOf(this), ...this, _rules: [] };
|
|
15
|
+
}
|
|
12
16
|
rank(left, right) {
|
|
13
|
-
for (const rule of this) {
|
|
17
|
+
for (const rule of this._rules) {
|
|
14
18
|
const l = rule.rank(left, right);
|
|
15
19
|
if (l !== 0)
|
|
16
20
|
return l;
|
|
17
21
|
}
|
|
18
22
|
return 0;
|
|
19
23
|
}
|
|
24
|
+
// Implement `Rule`
|
|
20
25
|
transform(iterable) {
|
|
21
26
|
return this._rules.length ? sortItems(iterable, this) : iterable;
|
|
22
27
|
}
|
package/query/types.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ export interface Filterable<T extends Data> extends Matchable<Entry<T>, void> {
|
|
|
16
16
|
lte<K extends QueryKey<T>>(key: K, value: K extends "id" ? string : T[K]): this;
|
|
17
17
|
gt<K extends QueryKey<T>>(key: K, value: K extends "id" ? string : T[K]): this;
|
|
18
18
|
gte<K extends QueryKey<T>>(key: K, value: K extends "id" ? string : T[K]): this;
|
|
19
|
+
/** Return a new instance of this class with no sorts specified. */
|
|
20
|
+
unfiltered: this;
|
|
21
|
+
/** Match an entry against the filters specified for this object. */
|
|
19
22
|
match(entry: Entry<T>): boolean;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
@@ -24,9 +27,11 @@ export interface Filterable<T extends Data> extends Matchable<Entry<T>, void> {
|
|
|
24
27
|
*/
|
|
25
28
|
export interface Sortable<T extends Data> extends Rankable<Entry<T>> {
|
|
26
29
|
/** Return a new instance of this class with an ascending order sort defined. */
|
|
27
|
-
asc(key
|
|
30
|
+
asc(key: QueryKey<T>): this;
|
|
28
31
|
/** Return a new instance of this class with a descending order sort defined. */
|
|
29
|
-
desc(key
|
|
32
|
+
desc(key: QueryKey<T>): this;
|
|
33
|
+
/** Return a new instance of this class with no sorts specified. */
|
|
34
|
+
unsorted: this;
|
|
30
35
|
}
|
|
31
36
|
/** Possible operator references. */
|
|
32
37
|
export declare type SortDirection = "ASC" | "DESC";
|