@pc-nexus/storage 0.8.0-next.3 → 0.8.0-next.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/CHANGELOG.md +17 -0
- package/lib/ces/condition-builder/condition.builder.d.ts +11 -11
- package/lib/ces/condition-builder/condition.builder.d.ts.map +1 -1
- package/lib/ces/condition-builder/condition.builder.js +4 -4
- package/lib/ces/condition-builder/inner-condition.builder.d.ts +12 -13
- package/lib/ces/condition-builder/inner-condition.builder.d.ts.map +1 -1
- package/lib/ces/condition-builder/inner-condition.builder.js +62 -41
- package/lib/kvs/kvs.d.ts +1 -0
- package/lib/kvs/kvs.d.ts.map +1 -1
- package/lib/kvs/kvs.js +24 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
# 0.8.0-next.5 (2026-08-07)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- #NEXUS-3863 kvs补充一下,set时的infinity,nan的边界值测试 (#1369) f7a03f6, closes #NEXUS-3863 #1369 #NEXUS-3863
|
|
10
|
+
- ces update 允许 "{}"&condition 比较值不支持正则 NaN&infinity 转换为安全数字 (#1363) d94cda4, closes #1363
|
|
11
|
+
- exists: false/true 与 eq/ne: null 行为一致&允许所有类型字段 eq/ne: null (#1346) 223659d, closes #1346
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- **backend:** refactor error and remove deprecated error #NEXUS-3701 (#1299) 6c2949e, closes #NEXUS-3701 #1299 #NEXUS-3701 #NEXUS-3701 #NEXUS-3701 #NEXUS-3701 #NEXUS-3701 #NEXUS-3701 #NEXUS-3701
|
|
16
|
+
- **backend:** refactor findOptions ,insertOptions ,update entity #NEXUS-4008 (#1376) 8231826, closes #NEXUS-4008 #1376
|
|
17
|
+
- **backend:** supported error message as unify message #NEXUS-3834 (#1347) be56895, closes #NEXUS-3834 #1347 #NEXUS-3834 #NEXUS-3834 #NEXUS-3834 #NEXUS-3834 #NEXUS-3834 #NEXUS-3834
|
|
18
|
+
- remove CES ConditionBuilder ignoreUndefined/keepNaN #NEXUS-3857 (#1348) 1e103c0, closes #NEXUS-3857 #1348
|
|
19
|
+
|
|
20
|
+
# 0.8.0-next.4 (2026-07-27)
|
|
21
|
+
|
|
5
22
|
# 0.8.0-next.3 (2026-07-24)
|
|
6
23
|
|
|
7
24
|
### Features
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CurrentLevelType,
|
|
1
|
+
import type { CurrentLevelType, KeyChains, LogicalLevelType, Condition, QueryOperatorCondition$contains, RootLevelType, TypeAtKeyChain, ValueAlternativeType, Document } from "@pc-nexus/internal";
|
|
2
2
|
import { InnerConditionBuilder } from "./inner-condition.builder.js";
|
|
3
3
|
export interface CommonConditionBuilder<Schema = Document, CurrentLevel extends CurrentLevelType<Schema> = RootLevelType<Schema>> {
|
|
4
4
|
field<TFieldChains extends KeyChains<Schema>>(field: TFieldChains): LimitComparisonConditionBuilder<Schema, TFieldChains, CurrentLevel, TypeAtKeyChain<Schema, TFieldChains>>;
|
|
@@ -12,25 +12,25 @@ export interface LogicalConditionBuilder<Schema = Document, FieldChains extends
|
|
|
12
12
|
type LimitComparisonConditionBuilder<Schema = Document, FieldChains extends KeyChains<Schema> = KeyChains<Schema>, CurrentLevel extends CurrentLevelType<Schema> = RootLevelType<Schema>, V = TypeAtKeyChain<Schema, FieldChains>, FieldType = TypeAtKeyChain<Schema, FieldChains>> = FieldType extends number ? Pick<ComparisonConditionBuilder<Schema, FieldChains, CurrentLevel, V>, "eq" | "ne" | "exists" | "gt" | "gte" | "lt" | "lte"> : FieldType extends string ? Pick<ComparisonConditionBuilder<Schema, FieldChains, CurrentLevel, V>, "eq" | "ne" | "exists" | "contains" | "notContains"> : FieldType extends boolean ? Pick<ComparisonConditionBuilder<Schema, FieldChains, CurrentLevel, V>, "eq" | "ne" | "exists"> : FieldType extends any[] ? Pick<ComparisonConditionBuilder<Schema, FieldChains, CurrentLevel, V>, "contains" | "notContains" | "eq" | "ne" | "exists"> : FieldType extends Document ? Pick<ComparisonConditionBuilder<Schema, FieldChains, CurrentLevel, V>, "eq" | "ne" | "exists"> : never;
|
|
13
13
|
export type ComparisonConditionBuilderReturnType<Schema = Document, FieldChains extends KeyChains<Schema> = KeyChains<Schema>, CurrentLevel extends CurrentLevelType<Schema> = RootLevelType<Schema>, V = TypeAtKeyChain<Schema, FieldChains>> = LogicalConditionBuilder<Schema, never, CurrentLevel, V> & LimitComparisonConditionBuilder<Schema, FieldChains, CurrentLevel, V>;
|
|
14
14
|
export interface ComparisonConditionBuilder<Schema = Document, FieldChains extends KeyChains<Schema> = KeyChains<Schema>, CurrentLevel extends CurrentLevelType<Schema> = RootLevelType<Schema>, V = TypeAtKeyChain<Schema, FieldChains>> {
|
|
15
|
-
eq(value: ValueAlternativeType<V
|
|
16
|
-
ne(value: ValueAlternativeType<V
|
|
17
|
-
gt(value: ValueAlternativeType<V
|
|
18
|
-
gte(value: ValueAlternativeType<V
|
|
19
|
-
lt(value: ValueAlternativeType<V
|
|
20
|
-
lte(value: ValueAlternativeType<V
|
|
21
|
-
contains(value: QueryOperatorCondition$contains<V
|
|
22
|
-
notContains(value: QueryOperatorCondition$contains<V
|
|
15
|
+
eq(value: ValueAlternativeType<V>): ComparisonConditionBuilderReturnType<Schema, FieldChains, CurrentLevel, V>;
|
|
16
|
+
ne(value: ValueAlternativeType<V>): ComparisonConditionBuilderReturnType<Schema, FieldChains, CurrentLevel, V>;
|
|
17
|
+
gt(value: ValueAlternativeType<V>): ComparisonConditionBuilderReturnType<Schema, FieldChains, CurrentLevel, V>;
|
|
18
|
+
gte(value: ValueAlternativeType<V>): ComparisonConditionBuilderReturnType<Schema, FieldChains, CurrentLevel, V>;
|
|
19
|
+
lt(value: ValueAlternativeType<V>): ComparisonConditionBuilderReturnType<Schema, FieldChains, CurrentLevel, V>;
|
|
20
|
+
lte(value: ValueAlternativeType<V>): ComparisonConditionBuilderReturnType<Schema, FieldChains, CurrentLevel, V>;
|
|
21
|
+
contains(value: QueryOperatorCondition$contains<V>): ComparisonConditionBuilderReturnType<Schema, FieldChains, CurrentLevel, V>;
|
|
22
|
+
notContains(value: QueryOperatorCondition$contains<V>): ComparisonConditionBuilderReturnType<Schema, FieldChains, CurrentLevel, V>;
|
|
23
23
|
exists(exists?: boolean): ComparisonConditionBuilderReturnType<Schema, FieldChains, CurrentLevel, V>;
|
|
24
24
|
}
|
|
25
25
|
export declare class ConditionBuilder<Schema = Document, FieldChains extends KeyChains<Schema> = KeyChains<Schema>, CurrentLevel extends CurrentLevelType<Schema> = RootLevelType<Schema>, V = TypeAtKeyChain<Schema, FieldChains>> implements LogicalConditionBuilder<Schema, FieldChains, CurrentLevel, V> {
|
|
26
26
|
protected _innerBuilder: InnerConditionBuilder<Schema, FieldChains, CurrentLevel, V>;
|
|
27
|
-
constructor(
|
|
27
|
+
constructor();
|
|
28
28
|
and(closure: (andBuilder: LogicalOperatorBuilder<Schema>) => void): LogicalOperatorReturnType<Schema, never, CurrentLevel>;
|
|
29
29
|
or(closure: (orBuilder: LogicalOperatorBuilder<Schema>) => void): LogicalOperatorReturnType<Schema, never, CurrentLevel>;
|
|
30
30
|
field<TFieldChains extends FieldChains>(field: TFieldChains): LimitComparisonConditionBuilder<Schema, TFieldChains, CurrentLevel, TypeAtKeyChain<Schema, TFieldChains>>;
|
|
31
31
|
}
|
|
32
32
|
export declare class ConditionBuilderHelper<Schema = Document, FieldChains extends KeyChains<Schema> = KeyChains<Schema>, CurrentLevel extends CurrentLevelType<Schema> = RootLevelType<Schema>, V = TypeAtKeyChain<Schema, FieldChains>> extends ConditionBuilder<Schema, FieldChains, CurrentLevel, V> {
|
|
33
|
-
static create<Schema>(
|
|
33
|
+
static create<Schema>(): ConditionBuilderHelper<Schema>;
|
|
34
34
|
done(reset?: boolean): Condition;
|
|
35
35
|
}
|
|
36
36
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition.builder.d.ts","sourceRoot":"","sources":["../../../../src/lib/ces/condition-builder/condition.builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,gBAAgB,EAChB,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"condition.builder.d.ts","sourceRoot":"","sources":["../../../../src/lib/ces/condition-builder/condition.builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,+BAA+B,EAC/B,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,QAAQ,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,MAAM,WAAW,sBAAsB,CAAC,MAAM,GAAG,QAAQ,EAAE,YAAY,SAAS,gBAAgB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC;IAC5H,KAAK,CAAC,YAAY,SAAS,SAAS,CAAC,MAAM,CAAC,EACxC,KAAK,EAAE,YAAY,GACpB,+BAA+B,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;CAChH;AAED,KAAK,sBAAsB,CAAC,MAAM,IAAI,uBAAuB,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;AACnH,KAAK,yBAAyB,CAAC,MAAM,EAAE,CAAC,EAAE,YAAY,SAAS,gBAAgB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,uBAAuB,CACtI,MAAM,EACN,SAAS,CAAC,MAAM,CAAC,EACjB,YAAY,EACZ,CAAC,CACJ,CAAC;AACF,MAAM,WAAW,uBAAuB,CACpC,MAAM,GAAG,QAAQ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inner-condition.builder.js";
|
|
2
2
|
export class ConditionBuilder {
|
|
3
3
|
_innerBuilder;
|
|
4
|
-
constructor(
|
|
5
|
-
this._innerBuilder = new InnerConditionBuilder(
|
|
4
|
+
constructor() {
|
|
5
|
+
this._innerBuilder = new InnerConditionBuilder();
|
|
6
6
|
}
|
|
7
7
|
and(closure) {
|
|
8
8
|
this._innerBuilder.and(closure);
|
|
@@ -18,8 +18,8 @@ export class ConditionBuilder {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
export class ConditionBuilderHelper extends ConditionBuilder {
|
|
21
|
-
static create(
|
|
22
|
-
return new ConditionBuilderHelper(
|
|
21
|
+
static create() {
|
|
22
|
+
return new ConditionBuilderHelper();
|
|
23
23
|
}
|
|
24
24
|
done(reset = true) {
|
|
25
25
|
return this._innerBuilder.done(reset);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { CurrentLevelType, EqOptions, KeyChains, LogicalLevelType, Query, Condition,
|
|
1
|
+
import type { CurrentLevelType, EqOptions, KeyChains, LogicalLevelType, Query, Condition, QueryOperatorCondition$contains, RootLevelType, TypeAtKeyChain, ValueAlternativeType } from "@pc-nexus/internal";
|
|
2
2
|
import { QueryOperator } from "@pc-nexus/internal";
|
|
3
3
|
export declare class InnerConditionBuilder<Schema = Record<string, any>, FieldChains extends KeyChains<Schema> = KeyChains<Schema>, CurrentLevel extends CurrentLevelType<Schema> = RootLevelType<Schema>, V = TypeAtKeyChain<Schema, FieldChains>> {
|
|
4
|
+
#private;
|
|
4
5
|
private _field;
|
|
5
|
-
private baseOptions;
|
|
6
6
|
private get currentField();
|
|
7
7
|
private set currentField(value);
|
|
8
8
|
private root;
|
|
9
9
|
private currentLevel;
|
|
10
|
-
static create<Schema>(
|
|
11
|
-
constructor(
|
|
10
|
+
static create<Schema>(): InnerConditionBuilder<Schema>;
|
|
11
|
+
constructor();
|
|
12
12
|
done(reset?: boolean): Condition;
|
|
13
13
|
reset(this: InnerConditionBuilder<Schema, never, CurrentLevelType<Schema>>): InnerConditionBuilder<Schema>;
|
|
14
14
|
private getRawQuery;
|
|
@@ -22,18 +22,17 @@ export declare class InnerConditionBuilder<Schema = Record<string, any>, FieldCh
|
|
|
22
22
|
private logicalClose;
|
|
23
23
|
and(closure: (andBuilder: InnerConditionBuilder<Schema, never, LogicalLevelType<Schema>>) => void): InnerConditionBuilder<Schema, FieldChains, CurrentLevel, V>;
|
|
24
24
|
or(closure: (orBuilder: InnerConditionBuilder<Schema, never, LogicalLevelType<Schema>>) => void): InnerConditionBuilder<Schema, FieldChains, CurrentLevel, V>;
|
|
25
|
-
private shouldReserveValue;
|
|
26
25
|
private updateQuery;
|
|
27
26
|
field<TFieldChains extends FieldChains>(field: TFieldChains): InnerConditionBuilder<Schema, TFieldChains, CurrentLevel>;
|
|
28
27
|
resetFieldConditions(): this;
|
|
29
|
-
eq<OP extends QueryOperator.EQ | QueryOperator.NE | QueryOperator.GT | QueryOperator.GTE | QueryOperator.LTE | QueryOperator.LT | QueryOperator.Contains | QueryOperator.NotContains = QueryOperator.EQ>(value: ValueAlternativeType<V>, { queryOperator
|
|
30
|
-
ne(value: ValueAlternativeType<V
|
|
31
|
-
gte(value: ValueAlternativeType<V
|
|
32
|
-
gt(value: ValueAlternativeType<V
|
|
33
|
-
lte(value: ValueAlternativeType<V
|
|
34
|
-
lt(value: ValueAlternativeType<V
|
|
35
|
-
contains(value: QueryOperatorCondition$contains<V
|
|
36
|
-
notContains(value: QueryOperatorCondition$contains<V
|
|
28
|
+
eq<OP extends QueryOperator.EQ | QueryOperator.NE | QueryOperator.GT | QueryOperator.GTE | QueryOperator.LTE | QueryOperator.LT | QueryOperator.Contains | QueryOperator.NotContains = QueryOperator.EQ>(value: ValueAlternativeType<V>, { queryOperator }?: EqOptions<OP>): this;
|
|
29
|
+
ne(value: ValueAlternativeType<V>): this;
|
|
30
|
+
gte(value: ValueAlternativeType<V>): this;
|
|
31
|
+
gt(value: ValueAlternativeType<V>): this;
|
|
32
|
+
lte(value: ValueAlternativeType<V>): this;
|
|
33
|
+
lt(value: ValueAlternativeType<V>): this;
|
|
34
|
+
contains(value: QueryOperatorCondition$contains<V>): this;
|
|
35
|
+
notContains(value: QueryOperatorCondition$contains<V>): this;
|
|
37
36
|
exists(exists?: boolean): this;
|
|
38
37
|
}
|
|
39
38
|
//# sourceMappingURL=inner-condition.builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inner-condition.builder.d.ts","sourceRoot":"","sources":["../../../../src/lib/ces/condition-builder/inner-condition.builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,gBAAgB,EAChB,SAAS,EACT,SAAS,EAGT,gBAAgB,EAChB,KAAK,EACL,SAAS,
|
|
1
|
+
{"version":3,"file":"inner-condition.builder.d.ts","sourceRoot":"","sources":["../../../../src/lib/ces/condition-builder/inner-condition.builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,gBAAgB,EAChB,SAAS,EACT,SAAS,EAGT,gBAAgB,EAChB,KAAK,EACL,SAAS,EAET,+BAA+B,EAE/B,aAAa,EACb,cAAc,EACd,oBAAoB,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAuD,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxG,qBAAa,qBAAqB,CAC9B,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5B,WAAW,SAAS,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,EACzD,YAAY,SAAS,gBAAgB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,EACrE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC;;IAEvC,OAAO,CAAC,MAAM,CAA0B;IAExC,OAAO,KAAK,YAAY,GAOvB;IAED,OAAO,KAAK,YAAY,QAEvB;IAED,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,YAAY,CAAgB;WAEtB,M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AAI,IAAI;IAqC5B,EAAE,CACL,EAAE,SACI,aAAa,CAAC,EAAE,GAChB,aAAa,CAAC,EAAE,GAChB,aAAa,CAAC,EAAE,GAChB,aAAa,CAAC,GAAG,GACjB,aAAa,CAAC,GAAG,GACjB,aAAa,CAAC,EAAE,GAChB,aAAa,CAAC,QAAQ,GACtB,aAAa,CAAC,WAAW,GAAG,aAAa,CAAC,EAAE,EACpD,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,EAAE,aAAsC,EAAE,GAAE,SAAS,CAAC,EAAE,CAAM,GAAG,IAAI;IAOhG,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI;IAIxC,GAAG,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI;IAKzC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI;IAKxC,GAAG,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI;IAKzC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI;IAKxC,QAAQ,CAAC,KAAK,EAAE,+BAA+B,CAAC,CAAC,CAAC,GAAG,IAAI;IAKzD,WAAW,CAAC,KAAK,EAAE,+BAA+B,CAAC,CAAC,CAAC,GAAG,IAAI;IAK5D,MAAM,CAAC,MAAM,UAAO,GAAG,IAAI;CAUrC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InvalidErrorCode, NexusInvalidError, NexusNotFoundError, NotFoundErrorCode } from "@pc-nexus/internal";
|
|
2
2
|
import { LogicalOperator, logicalOpSymbol, parentLevelSymbol, QueryOperator } from "@pc-nexus/internal";
|
|
3
3
|
import _ from "lodash";
|
|
4
4
|
export class InnerConditionBuilder {
|
|
5
5
|
_field;
|
|
6
|
-
baseOptions = { ignoreUndefined: false, keepNaN: false };
|
|
7
6
|
get currentField() {
|
|
8
7
|
if (!this._field) {
|
|
9
|
-
throw new
|
|
8
|
+
throw new NexusInvalidError(InvalidErrorCode.CesCondition, {
|
|
9
|
+
message: `The value of field is required.`,
|
|
10
|
+
});
|
|
10
11
|
}
|
|
11
12
|
return this._field;
|
|
12
13
|
}
|
|
@@ -15,11 +16,10 @@ export class InnerConditionBuilder {
|
|
|
15
16
|
}
|
|
16
17
|
root;
|
|
17
18
|
currentLevel;
|
|
18
|
-
static create(
|
|
19
|
-
return new InnerConditionBuilder(
|
|
19
|
+
static create() {
|
|
20
|
+
return new InnerConditionBuilder();
|
|
20
21
|
}
|
|
21
|
-
constructor(
|
|
22
|
-
Object.assign(this.baseOptions, options);
|
|
22
|
+
constructor() {
|
|
23
23
|
this.reset();
|
|
24
24
|
}
|
|
25
25
|
done(reset = true) {
|
|
@@ -76,7 +76,10 @@ export class InnerConditionBuilder {
|
|
|
76
76
|
assertAtRootLevel() {
|
|
77
77
|
if (!this.isAtRootLevel()) {
|
|
78
78
|
const logicalOp = this.currentLevel[logicalOpSymbol];
|
|
79
|
-
throw new
|
|
79
|
+
throw new NexusNotFoundError(NotFoundErrorCode.CesConditionRoot, {
|
|
80
|
+
errObject: "root operator",
|
|
81
|
+
key: logicalOp,
|
|
82
|
+
});
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
assertAtLogicalLevel(expect) {
|
|
@@ -84,15 +87,20 @@ export class InnerConditionBuilder {
|
|
|
84
87
|
const isRootLevel = _.isNil(logicalOp);
|
|
85
88
|
if (expect) {
|
|
86
89
|
if (logicalOp !== expect) {
|
|
87
|
-
throw new
|
|
90
|
+
throw new NexusNotFoundError(NotFoundErrorCode.CesConditionLogicalOperator, {
|
|
91
|
+
errObject: "logical operator",
|
|
92
|
+
key: expect,
|
|
93
|
+
});
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
else if (isRootLevel) {
|
|
91
|
-
throw new
|
|
97
|
+
throw new NexusInvalidError(InvalidErrorCode.CesCondition, {
|
|
98
|
+
message: `The value of logical operator is required.`,
|
|
99
|
+
});
|
|
92
100
|
}
|
|
93
101
|
}
|
|
94
102
|
logicalClosure(logicalOp, closure) {
|
|
95
|
-
const logicalQB = new InnerConditionBuilder(
|
|
103
|
+
const logicalQB = new InnerConditionBuilder().logicalOpen(logicalOp);
|
|
96
104
|
closure(logicalQB);
|
|
97
105
|
logicalQB.logicalClose(logicalOp);
|
|
98
106
|
if (this.isAtRootLevel()) {
|
|
@@ -130,16 +138,6 @@ export class InnerConditionBuilder {
|
|
|
130
138
|
or(closure) {
|
|
131
139
|
return this.logicalClosure(LogicalOperator.Or, closure);
|
|
132
140
|
}
|
|
133
|
-
shouldReserveValue(value, options) {
|
|
134
|
-
options = { ...this.baseOptions, ...options };
|
|
135
|
-
if (options.ignoreUndefined && value === undefined) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
if (!options.keepNaN && Number.isNaN(value)) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
141
|
updateQuery(field, condition) {
|
|
144
142
|
if (this.isAtRootLevel()) {
|
|
145
143
|
if (field in LogicalOperator && _.isArray(condition)) {
|
|
@@ -186,44 +184,67 @@ export class InnerConditionBuilder {
|
|
|
186
184
|
}
|
|
187
185
|
return this;
|
|
188
186
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return this;
|
|
187
|
+
#normalizeValue(value) {
|
|
188
|
+
if (value === Number.POSITIVE_INFINITY) {
|
|
189
|
+
return Number.MAX_SAFE_INTEGER;
|
|
193
190
|
}
|
|
194
|
-
|
|
191
|
+
if (value === Number.NEGATIVE_INFINITY) {
|
|
192
|
+
return Number.MIN_SAFE_INTEGER;
|
|
193
|
+
}
|
|
194
|
+
if (_.isRegExp(value)) {
|
|
195
|
+
throw new NexusInvalidError(InvalidErrorCode.CesCondition, {
|
|
196
|
+
message: "Regular expressions is not supported as comparison values.",
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
if (_.isNaN(value)) {
|
|
200
|
+
throw new NexusInvalidError(InvalidErrorCode.CesCondition, {
|
|
201
|
+
message: "NaN is not supported as comparison values.",
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
eq(value, { queryOperator = QueryOperator.EQ } = {}) {
|
|
207
|
+
const field = this.currentField;
|
|
208
|
+
const normalizedValue = this.#normalizeValue(value);
|
|
209
|
+
this.updateQuery(field, { [queryOperator]: normalizedValue });
|
|
195
210
|
return this;
|
|
196
211
|
}
|
|
197
|
-
ne(value
|
|
198
|
-
return this.eq(value, {
|
|
212
|
+
ne(value) {
|
|
213
|
+
return this.eq(value, { queryOperator: QueryOperator.NE });
|
|
199
214
|
}
|
|
200
|
-
gte(value
|
|
201
|
-
this.eq(value, { queryOperator: QueryOperator.GTE
|
|
215
|
+
gte(value) {
|
|
216
|
+
this.eq(value, { queryOperator: QueryOperator.GTE });
|
|
202
217
|
return this;
|
|
203
218
|
}
|
|
204
|
-
gt(value
|
|
205
|
-
this.eq(value, { queryOperator: QueryOperator.GT
|
|
219
|
+
gt(value) {
|
|
220
|
+
this.eq(value, { queryOperator: QueryOperator.GT });
|
|
206
221
|
return this;
|
|
207
222
|
}
|
|
208
|
-
lte(value
|
|
209
|
-
this.eq(value, { queryOperator: QueryOperator.LTE
|
|
223
|
+
lte(value) {
|
|
224
|
+
this.eq(value, { queryOperator: QueryOperator.LTE });
|
|
210
225
|
return this;
|
|
211
226
|
}
|
|
212
|
-
lt(value
|
|
213
|
-
this.eq(value, { queryOperator: QueryOperator.LT
|
|
227
|
+
lt(value) {
|
|
228
|
+
this.eq(value, { queryOperator: QueryOperator.LT });
|
|
214
229
|
return this;
|
|
215
230
|
}
|
|
216
|
-
contains(value
|
|
217
|
-
this.eq(value, { queryOperator: QueryOperator.Contains
|
|
231
|
+
contains(value) {
|
|
232
|
+
this.eq(value, { queryOperator: QueryOperator.Contains });
|
|
218
233
|
return this;
|
|
219
234
|
}
|
|
220
|
-
notContains(value
|
|
221
|
-
this.eq(value, { queryOperator: QueryOperator.NotContains
|
|
235
|
+
notContains(value) {
|
|
236
|
+
this.eq(value, { queryOperator: QueryOperator.NotContains });
|
|
222
237
|
return this;
|
|
223
238
|
}
|
|
224
239
|
exists(exists = true) {
|
|
225
240
|
const field = this.currentField;
|
|
226
|
-
|
|
241
|
+
const value = !!exists;
|
|
242
|
+
if (value) {
|
|
243
|
+
this.updateQuery(field, { [QueryOperator.NE]: null });
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
this.updateQuery(field, { [QueryOperator.EQ]: null });
|
|
247
|
+
}
|
|
227
248
|
return this;
|
|
228
249
|
}
|
|
229
250
|
}
|
package/lib/kvs/kvs.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { KvsValueType } from "@pc-nexus/internal";
|
|
2
2
|
import { KvsGetOptions, KvsSetResult, KvsSetOptions } from "./type.js";
|
|
3
3
|
declare class Kvs {
|
|
4
|
+
#private;
|
|
4
5
|
set<T extends KvsValueType>(key: string, value: T, options?: KvsSetOptions): Promise<KvsSetResult<T>>;
|
|
5
6
|
get<T extends KvsValueType>(key: string, options?: KvsGetOptions): Promise<T | undefined>;
|
|
6
7
|
delete(key: string): Promise<void>;
|
package/lib/kvs/kvs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kvs.d.ts","sourceRoot":"","sources":["../../../src/lib/kvs/kvs.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"kvs.d.ts","sourceRoot":"","sources":["../../../src/lib/kvs/kvs.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,YAAY,EAAmD,MAAM,oBAAoB,CAAC;AAC7H,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAEvE,cAAM,GAAG;;IAuBQ,GAAG,CAAC,CAAC,SAAS,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAWrG,GAAG,CAAC,CAAC,SAAS,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IASzF,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKlD;AACD,eAAO,MAAM,GAAG,KAAY,CAAC"}
|
package/lib/kvs/kvs.js
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
-
import { invoke } from "@pc-nexus/internal";
|
|
1
|
+
import { InvalidErrorCode, invoke, NexusInvalidError } from "@pc-nexus/internal";
|
|
2
2
|
class Kvs {
|
|
3
|
+
#assertKvsValueSupported(value) {
|
|
4
|
+
if (typeof value === "number") {
|
|
5
|
+
if (!Number.isFinite(value)) {
|
|
6
|
+
throw new NexusInvalidError(InvalidErrorCode.KvsValue, {
|
|
7
|
+
message: "NaN, Infinity and -Infinity are not supported as kvs values.",
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (value === null || typeof value !== "object") {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
for (const item of value) {
|
|
17
|
+
this.#assertKvsValueSupported(item);
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
for (const nested of Object.values(value)) {
|
|
22
|
+
this.#assertKvsValueSupported(nested);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
3
25
|
async set(key, value, options) {
|
|
26
|
+
this.#assertKvsValueSupported(value);
|
|
4
27
|
const response = await invoke("storage/kvs", "set", {
|
|
5
28
|
key,
|
|
6
29
|
value,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pc-nexus/storage",
|
|
3
|
-
"version": "0.8.0-next.
|
|
3
|
+
"version": "0.8.0-next.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"type": "module",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@pc-nexus/internal": "0.8.0-next.
|
|
33
|
+
"@pc-nexus/internal": "0.8.0-next.5",
|
|
34
34
|
"lodash": "^4.17.21"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {},
|