@fjell/core 4.4.43 → 4.4.44
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/dist/index.js +12 -1
- package/dist/item/IQFactory.d.ts +2 -2
- package/dist/item/ItemQuery.d.ts +1 -1
- package/package.json +1 -1
- package/src/item/IQFactory.ts +2 -2
- package/src/item/IQUtils.ts +14 -0
- package/src/item/ItemQuery.ts +3 -2
package/dist/index.js
CHANGED
|
@@ -413,7 +413,7 @@ var AItemService = class {
|
|
|
413
413
|
|
|
414
414
|
// src/item/ItemQuery.ts
|
|
415
415
|
var isCondition = (condition) => {
|
|
416
|
-
return (typeof condition.column === "string" && (Array.isArray(condition.value) && condition.value.every((item) => typeof item === "string")) || Array.isArray(condition.value) && condition.value.every((item) => typeof item === "number") || typeof condition.value === "string" || typeof condition.value === "number" || typeof condition.value === "boolean" || condition.value instanceof Date) && (condition.operator ? typeof condition.operator === "string" : true);
|
|
416
|
+
return (typeof condition.column === "string" && (Array.isArray(condition.value) && condition.value.every((item) => typeof item === "string")) || Array.isArray(condition.value) && condition.value.every((item) => typeof item === "number") || typeof condition.value === "string" || typeof condition.value === "number" || typeof condition.value === "boolean" || condition.value instanceof Date || condition.value === null) && (condition.operator ? typeof condition.operator === "string" : true);
|
|
417
417
|
};
|
|
418
418
|
|
|
419
419
|
// src/item/IQFactory.ts
|
|
@@ -620,6 +620,17 @@ var isConditionQueryMatch = (queryCondition, item) => {
|
|
|
620
620
|
return false;
|
|
621
621
|
}
|
|
622
622
|
logger3.debug("Comparing Condition", { propKey, itemProp: item[propKey], queryCondition });
|
|
623
|
+
if (queryCondition.value === null) {
|
|
624
|
+
if (queryCondition.operator === "==") {
|
|
625
|
+
return item[propKey] === null;
|
|
626
|
+
} else if (queryCondition.operator === "!=") {
|
|
627
|
+
return item[propKey] !== null;
|
|
628
|
+
} else {
|
|
629
|
+
throw new Error(
|
|
630
|
+
`Operator ${queryCondition.operator} cannot be used with null value. Use '==' for null checks or '!=' for not-null checks.`
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
623
634
|
let result = false;
|
|
624
635
|
switch (queryCondition.operator) {
|
|
625
636
|
case "==":
|
package/dist/item/IQFactory.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class IQFactory {
|
|
|
9
9
|
limit(limit: number): this;
|
|
10
10
|
offset(offset: number): this;
|
|
11
11
|
pk(kt: string, pk: string, name?: string): this;
|
|
12
|
-
condition(column: string, value: string[] | string | number[] | number | boolean | Date, operator?: ConditionOperator): this;
|
|
12
|
+
condition(column: string, value: string[] | string | number[] | number | boolean | Date | null, operator?: ConditionOperator): this;
|
|
13
13
|
static all(): IQFactory;
|
|
14
14
|
static orderBy(field: string, direction?: OrderDirection): IQFactory;
|
|
15
15
|
static agg(name: string, query: ItemQuery): IQFactory;
|
|
@@ -17,7 +17,7 @@ export declare class IQFactory {
|
|
|
17
17
|
static limit(limit: number): IQFactory;
|
|
18
18
|
static offset(offset: number): IQFactory;
|
|
19
19
|
static pk(kt: string, pk: string, name?: string): IQFactory;
|
|
20
|
-
static condition(column: string, value: string[] | string | number[] | number | boolean | Date, operator?: ConditionOperator): IQFactory;
|
|
20
|
+
static condition(column: string, value: string[] | string | number[] | number | boolean | Date | null, operator?: ConditionOperator): IQFactory;
|
|
21
21
|
static conditions(conditions: Condition[], compoundType?: CompoundType): IQFactory;
|
|
22
22
|
toQuery(): ItemQuery;
|
|
23
23
|
}
|
package/dist/item/ItemQuery.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type ConditionOperator = '==' | '!=' | '>' | '>=' | '<' | '<=' | 'in' | '
|
|
|
10
10
|
*/
|
|
11
11
|
export type Condition = {
|
|
12
12
|
column: string;
|
|
13
|
-
value: string[] | string | number[] | number | boolean | Date;
|
|
13
|
+
value: string[] | string | number[] | number | boolean | Date | null;
|
|
14
14
|
operator: ConditionOperator;
|
|
15
15
|
};
|
|
16
16
|
/**
|
package/package.json
CHANGED
package/src/item/IQFactory.ts
CHANGED
|
@@ -88,7 +88,7 @@ export class IQFactory {
|
|
|
88
88
|
|
|
89
89
|
public condition(
|
|
90
90
|
column: string,
|
|
91
|
-
value: string[] | string | number[] | number | boolean | Date,
|
|
91
|
+
value: string[] | string | number[] | number | boolean | Date | null,
|
|
92
92
|
operator: ConditionOperator = '==',
|
|
93
93
|
) {
|
|
94
94
|
const condition: Condition = { column, value, operator };
|
|
@@ -145,7 +145,7 @@ export class IQFactory {
|
|
|
145
145
|
|
|
146
146
|
public static condition(
|
|
147
147
|
column: string,
|
|
148
|
-
value: string[] | string | number[] | number | boolean | Date,
|
|
148
|
+
value: string[] | string | number[] | number | boolean | Date | null,
|
|
149
149
|
operator: ConditionOperator = '=='
|
|
150
150
|
) {
|
|
151
151
|
const iqFactory = new IQFactory();
|
package/src/item/IQUtils.ts
CHANGED
|
@@ -158,6 +158,20 @@ const isConditionQueryMatch = <
|
|
|
158
158
|
return false;
|
|
159
159
|
}
|
|
160
160
|
logger.debug('Comparing Condition', { propKey, itemProp: item[propKey], queryCondition });
|
|
161
|
+
|
|
162
|
+
// Handle null values - only == and != make sense with null
|
|
163
|
+
if (queryCondition.value === null) {
|
|
164
|
+
if (queryCondition.operator === '==') {
|
|
165
|
+
return item[propKey] === null;
|
|
166
|
+
} else if (queryCondition.operator === '!=') {
|
|
167
|
+
return item[propKey] !== null;
|
|
168
|
+
} else {
|
|
169
|
+
throw new Error(
|
|
170
|
+
`Operator ${queryCondition.operator} cannot be used with null value. Use '==' for null checks or '!=' for not-null checks.`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
161
175
|
let result = false;
|
|
162
176
|
switch (queryCondition.operator) {
|
|
163
177
|
case '==':
|
package/src/item/ItemQuery.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type ConditionOperator =
|
|
|
14
14
|
*/
|
|
15
15
|
export type Condition = {
|
|
16
16
|
column: string,
|
|
17
|
-
value: string[] | string | number[] | number | boolean | Date,
|
|
17
|
+
value: string[] | string | number[] | number | boolean | Date | null,
|
|
18
18
|
operator: ConditionOperator,
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -55,7 +55,8 @@ export const isCondition = (condition: any): condition is Condition => {
|
|
|
55
55
|
typeof condition.value === 'string' ||
|
|
56
56
|
typeof condition.value === 'number' ||
|
|
57
57
|
typeof condition.value === 'boolean' ||
|
|
58
|
-
condition.value instanceof Date
|
|
58
|
+
condition.value instanceof Date ||
|
|
59
|
+
condition.value === null
|
|
59
60
|
) && (condition.operator ? typeof condition.operator === 'string' : true);
|
|
60
61
|
}
|
|
61
62
|
|