@onchaindb/sdk 0.4.5 → 1.0.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/.claude/settings.local.json +10 -2
- package/README.md +422 -355
- package/dist/batch.d.ts +1 -10
- package/dist/batch.d.ts.map +1 -1
- package/dist/batch.js +4 -26
- package/dist/batch.js.map +1 -1
- package/dist/client.d.ts +29 -43
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +198 -323
- package/dist/client.js.map +1 -1
- package/dist/database.d.ts +14 -131
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +35 -131
- package/dist/database.js.map +1 -1
- package/dist/index.d.ts +6 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -15
- package/dist/index.js.map +1 -1
- package/dist/query-sdk/ConditionBuilder.d.ts +3 -11
- package/dist/query-sdk/ConditionBuilder.d.ts.map +1 -1
- package/dist/query-sdk/ConditionBuilder.js +10 -48
- package/dist/query-sdk/ConditionBuilder.js.map +1 -1
- package/dist/query-sdk/NestedBuilders.d.ts +33 -30
- package/dist/query-sdk/NestedBuilders.d.ts.map +1 -1
- package/dist/query-sdk/NestedBuilders.js +46 -43
- package/dist/query-sdk/NestedBuilders.js.map +1 -1
- package/dist/query-sdk/QueryBuilder.d.ts +4 -2
- package/dist/query-sdk/QueryBuilder.d.ts.map +1 -1
- package/dist/query-sdk/QueryBuilder.js +47 -169
- package/dist/query-sdk/QueryBuilder.js.map +1 -1
- package/dist/query-sdk/QueryResult.d.ts +0 -38
- package/dist/query-sdk/QueryResult.d.ts.map +1 -1
- package/dist/query-sdk/QueryResult.js +1 -227
- package/dist/query-sdk/QueryResult.js.map +1 -1
- package/dist/query-sdk/index.d.ts +1 -1
- package/dist/query-sdk/index.d.ts.map +1 -1
- package/dist/query-sdk/index.js.map +1 -1
- package/dist/query-sdk/operators.d.ts +32 -28
- package/dist/query-sdk/operators.d.ts.map +1 -1
- package/dist/query-sdk/operators.js +45 -155
- package/dist/query-sdk/operators.js.map +1 -1
- package/dist/types.d.ts +153 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/jest.config.js +4 -0
- package/package.json +1 -1
- package/skills.md +0 -1
- package/src/client.ts +242 -745
- package/src/database.ts +70 -493
- package/src/index.ts +40 -193
- package/src/query-sdk/ConditionBuilder.ts +37 -89
- package/src/query-sdk/NestedBuilders.ts +90 -92
- package/src/query-sdk/QueryBuilder.ts +59 -218
- package/src/query-sdk/QueryResult.ts +4 -330
- package/src/query-sdk/README.md +214 -583
- package/src/query-sdk/index.ts +1 -1
- package/src/query-sdk/operators.ts +91 -200
- package/src/query-sdk/tests/FieldConditionBuilder.test.ts +70 -71
- package/src/query-sdk/tests/LogicalOperator.test.ts +43 -82
- package/src/query-sdk/tests/NestedBuilders.test.ts +229 -309
- package/src/query-sdk/tests/QueryBuilder.test.ts +5 -5
- package/src/query-sdk/tests/QueryResult.test.ts +41 -435
- package/src/query-sdk/tests/comprehensive.test.ts +4 -185
- package/src/tests/client-requests.test.ts +280 -0
- package/src/tests/client-validation.test.ts +80 -0
- package/src/types.ts +229 -8
- package/src/batch.ts +0 -257
- package/src/query-sdk/dist/ConditionBuilder.d.ts +0 -22
- package/src/query-sdk/dist/ConditionBuilder.js +0 -90
- package/src/query-sdk/dist/FieldConditionBuilder.d.ts +0 -1
- package/src/query-sdk/dist/FieldConditionBuilder.js +0 -6
- package/src/query-sdk/dist/NestedBuilders.d.ts +0 -43
- package/src/query-sdk/dist/NestedBuilders.js +0 -144
- package/src/query-sdk/dist/OnChainDB.d.ts +0 -19
- package/src/query-sdk/dist/OnChainDB.js +0 -123
- package/src/query-sdk/dist/QueryBuilder.d.ts +0 -70
- package/src/query-sdk/dist/QueryBuilder.js +0 -295
- package/src/query-sdk/dist/QueryResult.d.ts +0 -52
- package/src/query-sdk/dist/QueryResult.js +0 -293
- package/src/query-sdk/dist/SelectionBuilder.d.ts +0 -20
- package/src/query-sdk/dist/SelectionBuilder.js +0 -80
- package/src/query-sdk/dist/adapters/HttpClientAdapter.d.ts +0 -27
- package/src/query-sdk/dist/adapters/HttpClientAdapter.js +0 -170
- package/src/query-sdk/dist/index.d.ts +0 -36
- package/src/query-sdk/dist/index.js +0 -27
- package/src/query-sdk/dist/operators.d.ts +0 -56
- package/src/query-sdk/dist/operators.js +0 -289
- package/src/query-sdk/dist/tests/setup.d.ts +0 -15
- package/src/query-sdk/dist/tests/setup.js +0 -46
- package/src/query-sdk/jest.config.js +0 -25
- package/src/query-sdk/package.json +0 -46
- package/src/query-sdk/tests/aggregations.test.ts +0 -653
- package/src/query-sdk/tests/integration.test.ts +0 -608
- package/src/query-sdk/tests/operators.test.ts +0 -327
- package/src/query-sdk/tests/unit.test.ts +0 -794
- package/src/query-sdk/tsconfig.json +0 -26
- package/src/query-sdk/yarn.lock +0 -3092
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createHttpClient = exports.NodeHttpClient = exports.AxiosHttpClient = exports.FetchHttpClient = exports.createQueryResult = exports.QueryResult = exports.NestedFieldConditionBuilder = exports.NestedConditionBuilder = exports.LogicalOperator = exports.FieldConditionBuilder = exports.ConditionBuilder = exports.SelectionBuilder = exports.QueryBuilder = exports.OnChainDB = void 0;
|
|
4
|
-
// Main SDK exports
|
|
5
|
-
var OnChainDB_1 = require("./OnChainDB");
|
|
6
|
-
Object.defineProperty(exports, "OnChainDB", { enumerable: true, get: function () { return OnChainDB_1.OnChainDB; } });
|
|
7
|
-
var QueryBuilder_1 = require("./QueryBuilder");
|
|
8
|
-
Object.defineProperty(exports, "QueryBuilder", { enumerable: true, get: function () { return QueryBuilder_1.QueryBuilder; } });
|
|
9
|
-
var SelectionBuilder_1 = require("./SelectionBuilder");
|
|
10
|
-
Object.defineProperty(exports, "SelectionBuilder", { enumerable: true, get: function () { return SelectionBuilder_1.SelectionBuilder; } });
|
|
11
|
-
var ConditionBuilder_1 = require("./ConditionBuilder");
|
|
12
|
-
Object.defineProperty(exports, "ConditionBuilder", { enumerable: true, get: function () { return ConditionBuilder_1.ConditionBuilder; } });
|
|
13
|
-
var operators_1 = require("./operators");
|
|
14
|
-
Object.defineProperty(exports, "FieldConditionBuilder", { enumerable: true, get: function () { return operators_1.FieldConditionBuilder; } });
|
|
15
|
-
Object.defineProperty(exports, "LogicalOperator", { enumerable: true, get: function () { return operators_1.LogicalOperator; } });
|
|
16
|
-
var NestedBuilders_1 = require("./NestedBuilders");
|
|
17
|
-
Object.defineProperty(exports, "NestedConditionBuilder", { enumerable: true, get: function () { return NestedBuilders_1.NestedConditionBuilder; } });
|
|
18
|
-
Object.defineProperty(exports, "NestedFieldConditionBuilder", { enumerable: true, get: function () { return NestedBuilders_1.NestedFieldConditionBuilder; } });
|
|
19
|
-
var QueryResult_1 = require("./QueryResult");
|
|
20
|
-
Object.defineProperty(exports, "QueryResult", { enumerable: true, get: function () { return QueryResult_1.QueryResult; } });
|
|
21
|
-
Object.defineProperty(exports, "createQueryResult", { enumerable: true, get: function () { return QueryResult_1.createQueryResult; } });
|
|
22
|
-
// HTTP Client adapters
|
|
23
|
-
var HttpClientAdapter_1 = require("./adapters/HttpClientAdapter");
|
|
24
|
-
Object.defineProperty(exports, "FetchHttpClient", { enumerable: true, get: function () { return HttpClientAdapter_1.FetchHttpClient; } });
|
|
25
|
-
Object.defineProperty(exports, "AxiosHttpClient", { enumerable: true, get: function () { return HttpClientAdapter_1.AxiosHttpClient; } });
|
|
26
|
-
Object.defineProperty(exports, "NodeHttpClient", { enumerable: true, get: function () { return HttpClientAdapter_1.NodeHttpClient; } });
|
|
27
|
-
Object.defineProperty(exports, "createHttpClient", { enumerable: true, get: function () { return HttpClientAdapter_1.createHttpClient; } });
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { BetweenValue, DateRange, Val } from './index';
|
|
2
|
-
export interface Condition {
|
|
3
|
-
field: string;
|
|
4
|
-
operator: string;
|
|
5
|
-
value: Val | BetweenValue | DateRange;
|
|
6
|
-
}
|
|
7
|
-
export declare function createNestedQuery(fieldPath: string, operator: string, value: Val | BetweenValue | DateRange): any;
|
|
8
|
-
export declare enum LogicalOperatorType {
|
|
9
|
-
AND = "and",
|
|
10
|
-
OR = "or",
|
|
11
|
-
NOT = "not",
|
|
12
|
-
CONDITION = "condition"
|
|
13
|
-
}
|
|
14
|
-
export declare class LogicalOperator {
|
|
15
|
-
type: LogicalOperatorType;
|
|
16
|
-
conditions: LogicalOperator[];
|
|
17
|
-
condition?: Condition | undefined;
|
|
18
|
-
constructor(type: LogicalOperatorType, conditions?: LogicalOperator[], condition?: Condition | undefined);
|
|
19
|
-
static And(conditions: LogicalOperator[]): LogicalOperator;
|
|
20
|
-
static Or(conditions: LogicalOperator[]): LogicalOperator;
|
|
21
|
-
static Not(conditions: LogicalOperator[]): LogicalOperator;
|
|
22
|
-
static Condition(condition: Condition): LogicalOperator;
|
|
23
|
-
toComposable(): any;
|
|
24
|
-
}
|
|
25
|
-
export declare class FieldConditionBuilder {
|
|
26
|
-
private fieldName;
|
|
27
|
-
constructor(fieldName: string);
|
|
28
|
-
equals(value: Val): Condition;
|
|
29
|
-
notEquals(value: Val): Condition;
|
|
30
|
-
in(values: Val[]): Condition;
|
|
31
|
-
notIn(values: Val[]): Condition;
|
|
32
|
-
isNull(): Condition;
|
|
33
|
-
isNotNull(): Condition;
|
|
34
|
-
exists(): Condition;
|
|
35
|
-
notExists(): Condition;
|
|
36
|
-
startsWith(value: string): Condition;
|
|
37
|
-
endsWith(value: string): Condition;
|
|
38
|
-
contains(value: string): Condition;
|
|
39
|
-
regExpMatches(pattern: string): Condition;
|
|
40
|
-
includesCaseInsensitive(value: string): Condition;
|
|
41
|
-
startsWithCaseInsensitive(value: string): Condition;
|
|
42
|
-
endsWithCaseInsensitive(value: string): Condition;
|
|
43
|
-
greaterThan(value: Val): Condition;
|
|
44
|
-
lessThan(value: Val): Condition;
|
|
45
|
-
greaterThanOrEqual(value: Val): Condition;
|
|
46
|
-
lessThanOrEqual(value: Val): Condition;
|
|
47
|
-
isLocalIp(): Condition;
|
|
48
|
-
isExternalIp(): Condition;
|
|
49
|
-
b64(value: string): Condition;
|
|
50
|
-
inDataset(dataset: string): Condition;
|
|
51
|
-
inCountry(countryCode: string): Condition;
|
|
52
|
-
cidr(cidr: string): Condition;
|
|
53
|
-
between(min: Val, max: Val): Condition;
|
|
54
|
-
isTrue(): Condition;
|
|
55
|
-
isFalse(): Condition;
|
|
56
|
-
}
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FieldConditionBuilder = exports.LogicalOperator = exports.LogicalOperatorType = void 0;
|
|
4
|
-
exports.createNestedQuery = createNestedQuery;
|
|
5
|
-
// Helper function to convert dot notation paths to nested structures
|
|
6
|
-
function createNestedQuery(fieldPath, operator, value) {
|
|
7
|
-
if (!fieldPath.includes('.')) {
|
|
8
|
-
return {
|
|
9
|
-
[fieldPath]: {
|
|
10
|
-
[operator]: value
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
const pathParts = fieldPath.split('.');
|
|
15
|
-
let result = {
|
|
16
|
-
[operator]: value
|
|
17
|
-
};
|
|
18
|
-
// Build nested structure from inside out
|
|
19
|
-
for (let i = pathParts.length - 1; i >= 0; i--) {
|
|
20
|
-
const part = pathParts[i];
|
|
21
|
-
if (i === pathParts.length - 1) {
|
|
22
|
-
result = {
|
|
23
|
-
[part]: result
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
result = {
|
|
28
|
-
[part]: result
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
// Logical operators for combining conditions
|
|
35
|
-
var LogicalOperatorType;
|
|
36
|
-
(function (LogicalOperatorType) {
|
|
37
|
-
LogicalOperatorType["AND"] = "and";
|
|
38
|
-
LogicalOperatorType["OR"] = "or";
|
|
39
|
-
LogicalOperatorType["NOT"] = "not";
|
|
40
|
-
LogicalOperatorType["CONDITION"] = "condition";
|
|
41
|
-
})(LogicalOperatorType || (exports.LogicalOperatorType = LogicalOperatorType = {}));
|
|
42
|
-
class LogicalOperator {
|
|
43
|
-
constructor(type, conditions = [], condition) {
|
|
44
|
-
this.type = type;
|
|
45
|
-
this.conditions = conditions;
|
|
46
|
-
this.condition = condition;
|
|
47
|
-
}
|
|
48
|
-
static And(conditions) {
|
|
49
|
-
return new LogicalOperator(LogicalOperatorType.AND, conditions);
|
|
50
|
-
}
|
|
51
|
-
static Or(conditions) {
|
|
52
|
-
return new LogicalOperator(LogicalOperatorType.OR, conditions);
|
|
53
|
-
}
|
|
54
|
-
static Not(conditions) {
|
|
55
|
-
return new LogicalOperator(LogicalOperatorType.NOT, conditions);
|
|
56
|
-
}
|
|
57
|
-
static Condition(condition) {
|
|
58
|
-
return new LogicalOperator(LogicalOperatorType.CONDITION, [], condition);
|
|
59
|
-
}
|
|
60
|
-
// Convert to composable query structure for HTTP requests
|
|
61
|
-
toComposable() {
|
|
62
|
-
switch (this.type) {
|
|
63
|
-
case LogicalOperatorType.AND:
|
|
64
|
-
return {
|
|
65
|
-
[LogicalOperatorType.AND]: this.conditions.map(c => c.toComposable())
|
|
66
|
-
};
|
|
67
|
-
case LogicalOperatorType.OR:
|
|
68
|
-
return {
|
|
69
|
-
[LogicalOperatorType.OR]: this.conditions.map(c => c.toComposable())
|
|
70
|
-
};
|
|
71
|
-
case LogicalOperatorType.NOT:
|
|
72
|
-
return {
|
|
73
|
-
[LogicalOperatorType.NOT]: this.conditions.map(c => c.toComposable())
|
|
74
|
-
};
|
|
75
|
-
case LogicalOperatorType.CONDITION:
|
|
76
|
-
if (!this.condition)
|
|
77
|
-
throw new Error('Condition is required for CONDITION type');
|
|
78
|
-
// Use dot notation helper to create nested structures
|
|
79
|
-
return createNestedQuery(this.condition.field, this.condition.operator, this.condition.value);
|
|
80
|
-
default:
|
|
81
|
-
throw new Error(`Unknown logical operator type: ${this.type}`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
exports.LogicalOperator = LogicalOperator;
|
|
86
|
-
// Field condition builder for creating individual field conditions
|
|
87
|
-
// Only includes operators that actually exist in the Rust implementation
|
|
88
|
-
class FieldConditionBuilder {
|
|
89
|
-
constructor(fieldName) {
|
|
90
|
-
this.fieldName = fieldName;
|
|
91
|
-
}
|
|
92
|
-
// ===== BASE OPERATORS (BaseOperator) =====
|
|
93
|
-
equals(value) {
|
|
94
|
-
return {
|
|
95
|
-
field: this.fieldName,
|
|
96
|
-
operator: 'is',
|
|
97
|
-
value
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
notEquals(value) {
|
|
101
|
-
return {
|
|
102
|
-
field: this.fieldName,
|
|
103
|
-
operator: 'isNot',
|
|
104
|
-
value
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
in(values) {
|
|
108
|
-
return {
|
|
109
|
-
field: this.fieldName,
|
|
110
|
-
operator: 'in',
|
|
111
|
-
value: values
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
notIn(values) {
|
|
115
|
-
return {
|
|
116
|
-
field: this.fieldName,
|
|
117
|
-
operator: 'notIn',
|
|
118
|
-
value: values
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
isNull() {
|
|
122
|
-
return {
|
|
123
|
-
field: this.fieldName,
|
|
124
|
-
operator: 'isNull',
|
|
125
|
-
value: true
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
isNotNull() {
|
|
129
|
-
return {
|
|
130
|
-
field: this.fieldName,
|
|
131
|
-
operator: 'isNull',
|
|
132
|
-
value: false
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
exists() {
|
|
136
|
-
return {
|
|
137
|
-
field: this.fieldName,
|
|
138
|
-
operator: 'exists',
|
|
139
|
-
value: true
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
notExists() {
|
|
143
|
-
return {
|
|
144
|
-
field: this.fieldName,
|
|
145
|
-
operator: 'exists',
|
|
146
|
-
value: false
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
// ===== STRING OPERATORS (StringOperator) =====
|
|
150
|
-
startsWith(value) {
|
|
151
|
-
return {
|
|
152
|
-
field: this.fieldName,
|
|
153
|
-
operator: 'startsWith',
|
|
154
|
-
value
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
endsWith(value) {
|
|
158
|
-
return {
|
|
159
|
-
field: this.fieldName,
|
|
160
|
-
operator: 'endsWith',
|
|
161
|
-
value
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
contains(value) {
|
|
165
|
-
return {
|
|
166
|
-
field: this.fieldName,
|
|
167
|
-
operator: 'includes',
|
|
168
|
-
value
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
regExpMatches(pattern) {
|
|
172
|
-
return {
|
|
173
|
-
field: this.fieldName,
|
|
174
|
-
operator: 'regExpMatches',
|
|
175
|
-
value: pattern
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
includesCaseInsensitive(value) {
|
|
179
|
-
return {
|
|
180
|
-
field: this.fieldName,
|
|
181
|
-
operator: 'includesCaseInsensitive',
|
|
182
|
-
value
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
startsWithCaseInsensitive(value) {
|
|
186
|
-
return {
|
|
187
|
-
field: this.fieldName,
|
|
188
|
-
operator: 'startsWithCaseInsensitive',
|
|
189
|
-
value
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
endsWithCaseInsensitive(value) {
|
|
193
|
-
return {
|
|
194
|
-
field: this.fieldName,
|
|
195
|
-
operator: 'endsWithCaseInsensitive',
|
|
196
|
-
value
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
// ===== NUMBER OPERATORS (NumberOperator) =====
|
|
200
|
-
greaterThan(value) {
|
|
201
|
-
return {
|
|
202
|
-
field: this.fieldName,
|
|
203
|
-
operator: 'greaterThan',
|
|
204
|
-
value
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
lessThan(value) {
|
|
208
|
-
return {
|
|
209
|
-
field: this.fieldName,
|
|
210
|
-
operator: 'lessThan',
|
|
211
|
-
value
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
greaterThanOrEqual(value) {
|
|
215
|
-
return {
|
|
216
|
-
field: this.fieldName,
|
|
217
|
-
operator: 'greaterThanOrEqual',
|
|
218
|
-
value
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
lessThanOrEqual(value) {
|
|
222
|
-
return {
|
|
223
|
-
field: this.fieldName,
|
|
224
|
-
operator: 'lessThanOrEqual',
|
|
225
|
-
value
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
// ===== IP OPERATORS (IpOperator) =====
|
|
229
|
-
isLocalIp() {
|
|
230
|
-
return {
|
|
231
|
-
field: this.fieldName,
|
|
232
|
-
operator: 'isLocalIp',
|
|
233
|
-
value: true
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
isExternalIp() {
|
|
237
|
-
return {
|
|
238
|
-
field: this.fieldName,
|
|
239
|
-
operator: 'isExternalIp',
|
|
240
|
-
value: true
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
// ===== MISC OPERATORS (MiscOperator) =====
|
|
244
|
-
b64(value) {
|
|
245
|
-
return {
|
|
246
|
-
field: this.fieldName,
|
|
247
|
-
operator: 'b64',
|
|
248
|
-
value
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
inDataset(dataset) {
|
|
252
|
-
return {
|
|
253
|
-
field: this.fieldName,
|
|
254
|
-
operator: 'inDataset',
|
|
255
|
-
value: dataset
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
inCountry(countryCode) {
|
|
259
|
-
return {
|
|
260
|
-
field: this.fieldName,
|
|
261
|
-
operator: 'inCountry',
|
|
262
|
-
value: countryCode
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
cidr(cidr) {
|
|
266
|
-
return {
|
|
267
|
-
field: this.fieldName,
|
|
268
|
-
operator: 'CIDR',
|
|
269
|
-
value: cidr
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
// ===== BETWEEN OPERATOR =====
|
|
273
|
-
between(min, max) {
|
|
274
|
-
return {
|
|
275
|
-
field: this.fieldName,
|
|
276
|
-
operator: 'betweenOp',
|
|
277
|
-
value: { from: min, to: max }
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
// ===== CONVENIENCE METHODS =====
|
|
281
|
-
// Boolean checks (using base operators)
|
|
282
|
-
isTrue() {
|
|
283
|
-
return this.equals(true);
|
|
284
|
-
}
|
|
285
|
-
isFalse() {
|
|
286
|
-
return this.equals(false);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
exports.FieldConditionBuilder = FieldConditionBuilder;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import 'jest';
|
|
2
|
-
export declare const createMockResponse: (data: any) => {
|
|
3
|
-
data: {
|
|
4
|
-
records: any[];
|
|
5
|
-
total: number;
|
|
6
|
-
page: number;
|
|
7
|
-
limit: number;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export declare class MockHttpClient {
|
|
11
|
-
private responses;
|
|
12
|
-
setResponse(url: string, response: any): void;
|
|
13
|
-
post(url: string, data: any, headers?: Record<string, string>): Promise<any>;
|
|
14
|
-
clear(): void;
|
|
15
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Jest setup file for global test configuration
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.MockHttpClient = exports.createMockResponse = void 0;
|
|
5
|
-
// Extend Jest matchers if needed
|
|
6
|
-
require("jest");
|
|
7
|
-
// Global test timeout
|
|
8
|
-
jest.setTimeout(30000);
|
|
9
|
-
// Mock console methods for cleaner test output
|
|
10
|
-
const originalConsoleError = console.error;
|
|
11
|
-
const originalConsoleWarn = console.warn;
|
|
12
|
-
beforeAll(() => {
|
|
13
|
-
console.error = jest.fn();
|
|
14
|
-
console.warn = jest.fn();
|
|
15
|
-
});
|
|
16
|
-
afterAll(() => {
|
|
17
|
-
console.error = originalConsoleError;
|
|
18
|
-
console.warn = originalConsoleWarn;
|
|
19
|
-
});
|
|
20
|
-
// Helper function to create mock HTTP responses
|
|
21
|
-
const createMockResponse = (data) => ({
|
|
22
|
-
data: {
|
|
23
|
-
records: Array.isArray(data) ? data : [data],
|
|
24
|
-
total: Array.isArray(data) ? data.length : 1,
|
|
25
|
-
page: 1,
|
|
26
|
-
limit: 10
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
exports.createMockResponse = createMockResponse;
|
|
30
|
-
// Mock HTTP client for tests
|
|
31
|
-
class MockHttpClient {
|
|
32
|
-
constructor() {
|
|
33
|
-
this.responses = new Map();
|
|
34
|
-
}
|
|
35
|
-
setResponse(url, response) {
|
|
36
|
-
this.responses.set(url, response);
|
|
37
|
-
}
|
|
38
|
-
async post(url, data, headers) {
|
|
39
|
-
const response = this.responses.get(url) || (0, exports.createMockResponse)([]);
|
|
40
|
-
return Promise.resolve(response);
|
|
41
|
-
}
|
|
42
|
-
clear() {
|
|
43
|
-
this.responses.clear();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.MockHttpClient = MockHttpClient;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
preset: 'ts-jest',
|
|
3
|
-
testEnvironment: 'node',
|
|
4
|
-
roots: ['<rootDir>/tests'],
|
|
5
|
-
testMatch: [
|
|
6
|
-
'**/__tests__/**/*.ts',
|
|
7
|
-
'**/?(*.)+(spec|test).ts'
|
|
8
|
-
],
|
|
9
|
-
transform: {
|
|
10
|
-
'^.+\\.ts$': 'ts-jest',
|
|
11
|
-
},
|
|
12
|
-
collectCoverageFrom: [
|
|
13
|
-
'**/*.ts',
|
|
14
|
-
'!**/*.d.ts',
|
|
15
|
-
'!**/node_modules/**',
|
|
16
|
-
'!**/tests/**',
|
|
17
|
-
],
|
|
18
|
-
coverageDirectory: 'coverage',
|
|
19
|
-
coverageReporters: [
|
|
20
|
-
'text',
|
|
21
|
-
'lcov',
|
|
22
|
-
'html'
|
|
23
|
-
],
|
|
24
|
-
setupFilesAfterEnv: ['<rootDir>/tests/setup.ts']
|
|
25
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@scepter/typescript-sdk",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "TypeScript SDK for Scepter JSON query engine",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "jest",
|
|
9
|
-
"test:watch": "jest --watch",
|
|
10
|
-
"test:coverage": "jest --coverage",
|
|
11
|
-
"build": "tsc",
|
|
12
|
-
"lint": "eslint src/**/*.ts",
|
|
13
|
-
"prepare": "npm run build"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"query",
|
|
17
|
-
"json",
|
|
18
|
-
"database",
|
|
19
|
-
"typescript",
|
|
20
|
-
"sdk"
|
|
21
|
-
],
|
|
22
|
-
"author": "Scepter Team",
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@types/jest": "^30.0.0",
|
|
26
|
-
"@types/node": "^20.8.0",
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
28
|
-
"@typescript-eslint/parser": "^6.7.0",
|
|
29
|
-
"eslint": "^8.50.0",
|
|
30
|
-
"jest": "^29.7.0",
|
|
31
|
-
"ts-jest": "^29.4.4",
|
|
32
|
-
"typescript": "^5.2.0",
|
|
33
|
-
"yest": "^0.0.1"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"axios": "^1.5.0"
|
|
37
|
-
},
|
|
38
|
-
"peerDependencies": {
|
|
39
|
-
"axios": "^1.5.0"
|
|
40
|
-
},
|
|
41
|
-
"files": [
|
|
42
|
-
"dist/**/*",
|
|
43
|
-
"index.d.ts",
|
|
44
|
-
"README.md"
|
|
45
|
-
]
|
|
46
|
-
}
|