@forge/storage 2.0.2 → 2.0.3-experimental-04cc2b9
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/LICENSE.txt +1 -1
- package/package.json +11 -2
- package/README.md +0 -50
- package/out/__test__/errors.test.d.ts +0 -2
- package/out/__test__/errors.test.d.ts.map +0 -1
- package/out/__test__/errors.test.js +0 -34
- package/out/__test__/global-storage.test.d.ts +0 -2
- package/out/__test__/global-storage.test.d.ts.map +0 -1
- package/out/__test__/global-storage.test.js +0 -833
- package/out/__test__/list-api.test.d.ts +0 -2
- package/out/__test__/list-api.test.d.ts.map +0 -1
- package/out/__test__/list-api.test.js +0 -650
- package/out/conditions.d.ts +0 -3
- package/out/conditions.d.ts.map +0 -1
- package/out/conditions.js +0 -10
- package/out/eap/conditions.d.ts +0 -40
- package/out/eap/conditions.d.ts.map +0 -1
- package/out/eap/conditions.js +0 -112
- package/out/eap/index.d.ts +0 -2
- package/out/eap/index.d.ts.map +0 -1
- package/out/eap/index.js +0 -4
- package/out/entity-storage/index.d.ts +0 -2
- package/out/entity-storage/index.d.ts.map +0 -1
- package/out/entity-storage/index.js +0 -5
- package/out/entity-storage/query-api.d.ts +0 -48
- package/out/entity-storage/query-api.d.ts.map +0 -1
- package/out/entity-storage/query-api.js +0 -154
- package/out/entity-storage/storage-builder.d.ts +0 -20
- package/out/entity-storage/storage-builder.d.ts.map +0 -1
- package/out/entity-storage/storage-builder.js +0 -25
- package/out/errors.d.ts +0 -9
- package/out/errors.d.ts.map +0 -1
- package/out/errors.js +0 -41
- package/out/global-storage.d.ts +0 -50
- package/out/global-storage.d.ts.map +0 -1
- package/out/global-storage.js +0 -156
- package/out/gql-queries.d.ts +0 -81
- package/out/gql-queries.d.ts.map +0 -1
- package/out/gql-queries.js +0 -200
- package/out/index.d.ts +0 -49
- package/out/index.d.ts.map +0 -1
- package/out/index.js +0 -33
- package/out/query-api.d.ts +0 -14
- package/out/query-api.d.ts.map +0 -1
- package/out/query-api.js +0 -44
- package/out/query-interfaces.d.ts +0 -113
- package/out/query-interfaces.d.ts.map +0 -1
- package/out/query-interfaces.js +0 -8
- package/out/storage-adapter.d.ts +0 -42
- package/out/storage-adapter.d.ts.map +0 -1
- package/out/storage-adapter.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-api.test.d.ts","sourceRoot":"","sources":["../../src/__test__/list-api.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,650 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const query_api_1 = require("../query-api");
|
|
4
|
-
const query_api_2 = require("../entity-storage/query-api");
|
|
5
|
-
const conditions_1 = require("../conditions");
|
|
6
|
-
const conditions_2 = require("../eap/conditions");
|
|
7
|
-
const query_interfaces_1 = require("../query-interfaces");
|
|
8
|
-
describe('DefaultQueryBuilder Untyped entities', () => {
|
|
9
|
-
function newGlobalStorage() {
|
|
10
|
-
return {
|
|
11
|
-
list: jest.fn()
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
it('should fetch multiple values', async () => {
|
|
15
|
-
const globalStorage = newGlobalStorage();
|
|
16
|
-
const queryResults = [
|
|
17
|
-
{
|
|
18
|
-
key: 'test',
|
|
19
|
-
value: {}
|
|
20
|
-
}
|
|
21
|
-
];
|
|
22
|
-
globalStorage.list.mockResolvedValue({
|
|
23
|
-
results: queryResults,
|
|
24
|
-
nextCursor: 'next'
|
|
25
|
-
});
|
|
26
|
-
const { results, nextCursor } = await new query_api_1.DefaultQueryBuilder(globalStorage).getMany();
|
|
27
|
-
expect(results).toEqual(queryResults);
|
|
28
|
-
expect(nextCursor).toEqual('next');
|
|
29
|
-
expect(globalStorage.list).toHaveBeenCalledWith({});
|
|
30
|
-
});
|
|
31
|
-
describe('getSingle', () => {
|
|
32
|
-
it.each([
|
|
33
|
-
[{ key: 'test', value: {} }, [{ key: 'test', value: {} }]],
|
|
34
|
-
[undefined, []]
|
|
35
|
-
])('Should return %o when getting %o from list API', async (value, listResult) => {
|
|
36
|
-
const globalStorage = newGlobalStorage();
|
|
37
|
-
globalStorage.list.mockResolvedValue({
|
|
38
|
-
results: listResult
|
|
39
|
-
});
|
|
40
|
-
const result = await new query_api_1.DefaultQueryBuilder(globalStorage).getOne();
|
|
41
|
-
expect(result).toEqual(value);
|
|
42
|
-
expect(globalStorage.list).toHaveBeenCalledWith(expect.objectContaining({
|
|
43
|
-
limit: 1
|
|
44
|
-
}));
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
it('should allow specifying a cursor', async () => {
|
|
48
|
-
const globalStorage = newGlobalStorage();
|
|
49
|
-
await new query_api_1.DefaultQueryBuilder(globalStorage).cursor('cursor').getMany();
|
|
50
|
-
expect(globalStorage.list).toHaveBeenCalledWith(expect.objectContaining({
|
|
51
|
-
cursor: 'cursor'
|
|
52
|
-
}));
|
|
53
|
-
});
|
|
54
|
-
it('should allow specifying a "starts with" condition', async () => {
|
|
55
|
-
const globalStorage = newGlobalStorage();
|
|
56
|
-
await new query_api_1.DefaultQueryBuilder(globalStorage).where('key', (0, conditions_1.startsWith)('test')).getMany();
|
|
57
|
-
expect(globalStorage.list).toHaveBeenCalledWith(expect.objectContaining({
|
|
58
|
-
where: [
|
|
59
|
-
{
|
|
60
|
-
field: 'key',
|
|
61
|
-
condition: 'STARTS_WITH',
|
|
62
|
-
value: 'test'
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
}));
|
|
66
|
-
});
|
|
67
|
-
it('should allow specifying a "not equal to" condition', async () => {
|
|
68
|
-
const globalStorage = newGlobalStorage();
|
|
69
|
-
await new query_api_1.DefaultQueryBuilder(globalStorage).where('key', (0, conditions_2.isNotEqualTo)(['test', 'test2'])).getMany();
|
|
70
|
-
expect(globalStorage.list).toHaveBeenCalledWith(expect.objectContaining({
|
|
71
|
-
where: [
|
|
72
|
-
{
|
|
73
|
-
field: 'key',
|
|
74
|
-
condition: 'NOT_EQUAL_TO',
|
|
75
|
-
value: ['test', 'test2']
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
}));
|
|
79
|
-
});
|
|
80
|
-
it('should allow specifying an "is in" condition', async () => {
|
|
81
|
-
const globalStorage = newGlobalStorage();
|
|
82
|
-
await new query_api_1.DefaultQueryBuilder(globalStorage).where('key', (0, conditions_2.isIn)(['test', 'test2'])).getMany();
|
|
83
|
-
expect(globalStorage.list).toHaveBeenCalledWith(expect.objectContaining({
|
|
84
|
-
where: [
|
|
85
|
-
{
|
|
86
|
-
field: 'key',
|
|
87
|
-
condition: 'IN',
|
|
88
|
-
value: ['test', 'test2']
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
}));
|
|
92
|
-
});
|
|
93
|
-
it('should allow specifying a condition', async () => {
|
|
94
|
-
const globalStorage = newGlobalStorage();
|
|
95
|
-
await new query_api_1.DefaultQueryBuilder(globalStorage).where('key', (0, conditions_1.startsWith)('test')).getMany();
|
|
96
|
-
expect(globalStorage.list).toHaveBeenCalledWith(expect.objectContaining({
|
|
97
|
-
where: [
|
|
98
|
-
{
|
|
99
|
-
field: 'key',
|
|
100
|
-
condition: 'STARTS_WITH',
|
|
101
|
-
value: 'test'
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
}));
|
|
105
|
-
});
|
|
106
|
-
it('should allow specifying a limit', async () => {
|
|
107
|
-
const globalStorage = newGlobalStorage();
|
|
108
|
-
await new query_api_1.DefaultQueryBuilder(globalStorage).limit(10).getMany();
|
|
109
|
-
expect(globalStorage.list).toHaveBeenCalledWith(expect.objectContaining({
|
|
110
|
-
limit: 10
|
|
111
|
-
}));
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
describe('DefaultQueryBuilder CustomEntities', () => {
|
|
115
|
-
function newGlobalStorage() {
|
|
116
|
-
return {
|
|
117
|
-
listCustomEntities: jest.fn()
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
it('should only have "entity" as option for default base query builder', () => {
|
|
121
|
-
const globalStorage = newGlobalStorage();
|
|
122
|
-
const baseQueryBuilderInstance = new query_api_2.CustomEntityBuilder(globalStorage);
|
|
123
|
-
expect(baseQueryBuilderInstance).toHaveProperty('entity');
|
|
124
|
-
expect(baseQueryBuilderInstance).not.toHaveProperty('index');
|
|
125
|
-
expect(baseQueryBuilderInstance).not.toHaveProperty('where');
|
|
126
|
-
expect(baseQueryBuilderInstance).not.toHaveProperty('andFilter');
|
|
127
|
-
expect(baseQueryBuilderInstance).not.toHaveProperty('orFilter');
|
|
128
|
-
expect(baseQueryBuilderInstance).not.toHaveProperty('cursor');
|
|
129
|
-
expect(baseQueryBuilderInstance).not.toHaveProperty('limit');
|
|
130
|
-
expect(baseQueryBuilderInstance).not.toHaveProperty('getOne');
|
|
131
|
-
expect(baseQueryBuilderInstance).not.toHaveProperty('getMany');
|
|
132
|
-
expect(baseQueryBuilderInstance).not.toHaveProperty('sort');
|
|
133
|
-
});
|
|
134
|
-
it('should only have "index" as option once "entity" is initialized', () => {
|
|
135
|
-
const globalStorage = newGlobalStorage();
|
|
136
|
-
const baseQueryBuilderInstanceWithEntity = new query_api_2.CustomEntityBuilder(globalStorage).entity('books');
|
|
137
|
-
expect(baseQueryBuilderInstanceWithEntity).not.toHaveProperty('entity');
|
|
138
|
-
expect(baseQueryBuilderInstanceWithEntity).toHaveProperty('index');
|
|
139
|
-
expect(baseQueryBuilderInstanceWithEntity).not.toHaveProperty('where');
|
|
140
|
-
expect(baseQueryBuilderInstanceWithEntity).not.toHaveProperty('andFilter');
|
|
141
|
-
expect(baseQueryBuilderInstanceWithEntity).not.toHaveProperty('orFilter');
|
|
142
|
-
expect(baseQueryBuilderInstanceWithEntity).not.toHaveProperty('cursor');
|
|
143
|
-
expect(baseQueryBuilderInstanceWithEntity).not.toHaveProperty('limit');
|
|
144
|
-
expect(baseQueryBuilderInstanceWithEntity).not.toHaveProperty('getOne');
|
|
145
|
-
expect(baseQueryBuilderInstanceWithEntity).not.toHaveProperty('getMany');
|
|
146
|
-
expect(baseQueryBuilderInstanceWithEntity).not.toHaveProperty('sort');
|
|
147
|
-
});
|
|
148
|
-
it('should have "where", "andFilter", "orFilter", "cursor", "limit", "sort", "getOne", "getMany" as options once "index" is initialized', () => {
|
|
149
|
-
const globalStorage = newGlobalStorage();
|
|
150
|
-
const queryBuilderInstanceWithIndex = new query_api_2.CustomEntityBuilder(globalStorage).entity('books').index('by-key');
|
|
151
|
-
expect(queryBuilderInstanceWithIndex).not.toHaveProperty('entity');
|
|
152
|
-
expect(queryBuilderInstanceWithIndex).not.toHaveProperty('index');
|
|
153
|
-
expect(queryBuilderInstanceWithIndex).toHaveProperty('where');
|
|
154
|
-
expect(queryBuilderInstanceWithIndex).toHaveProperty('andFilter');
|
|
155
|
-
expect(queryBuilderInstanceWithIndex).toHaveProperty('orFilter');
|
|
156
|
-
expect(queryBuilderInstanceWithIndex).toHaveProperty('cursor');
|
|
157
|
-
expect(queryBuilderInstanceWithIndex).toHaveProperty('limit');
|
|
158
|
-
expect(queryBuilderInstanceWithIndex).toHaveProperty('sort');
|
|
159
|
-
expect(queryBuilderInstanceWithIndex).toHaveProperty('getOne');
|
|
160
|
-
expect(queryBuilderInstanceWithIndex).toHaveProperty('getMany');
|
|
161
|
-
});
|
|
162
|
-
it('should not have "orFilter" once "andFilter" is used', () => {
|
|
163
|
-
const globalStorage = newGlobalStorage();
|
|
164
|
-
const queryBuilderInstanceWithAndFilter = new query_api_2.CustomEntityBuilder(globalStorage)
|
|
165
|
-
.entity('books')
|
|
166
|
-
.index('by-key')
|
|
167
|
-
.andFilter('first_name', conditions_2.FilterConditions.beginsWith('John'));
|
|
168
|
-
expect(queryBuilderInstanceWithAndFilter).not.toHaveProperty('entity');
|
|
169
|
-
expect(queryBuilderInstanceWithAndFilter).not.toHaveProperty('index');
|
|
170
|
-
expect(queryBuilderInstanceWithAndFilter).not.toHaveProperty('orFilter');
|
|
171
|
-
expect(queryBuilderInstanceWithAndFilter).toHaveProperty('where');
|
|
172
|
-
expect(queryBuilderInstanceWithAndFilter).toHaveProperty('andFilter');
|
|
173
|
-
expect(queryBuilderInstanceWithAndFilter).toHaveProperty('cursor');
|
|
174
|
-
expect(queryBuilderInstanceWithAndFilter).toHaveProperty('limit');
|
|
175
|
-
expect(queryBuilderInstanceWithAndFilter).toHaveProperty('sort');
|
|
176
|
-
expect(queryBuilderInstanceWithAndFilter).toHaveProperty('getOne');
|
|
177
|
-
expect(queryBuilderInstanceWithAndFilter).toHaveProperty('getMany');
|
|
178
|
-
});
|
|
179
|
-
it('should not have "andFilter" once "orFilter" is used', () => {
|
|
180
|
-
const globalStorage = newGlobalStorage();
|
|
181
|
-
const queryBuilderInstanceWithOrFilter = new query_api_2.CustomEntityBuilder(globalStorage)
|
|
182
|
-
.entity('books')
|
|
183
|
-
.index('by-key')
|
|
184
|
-
.orFilter('first_name', conditions_2.FilterConditions.beginsWith('John'));
|
|
185
|
-
expect(queryBuilderInstanceWithOrFilter).not.toHaveProperty('entity');
|
|
186
|
-
expect(queryBuilderInstanceWithOrFilter).not.toHaveProperty('index');
|
|
187
|
-
expect(queryBuilderInstanceWithOrFilter).not.toHaveProperty('andFilter');
|
|
188
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('where');
|
|
189
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('orFilter');
|
|
190
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('cursor');
|
|
191
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('limit');
|
|
192
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('sort');
|
|
193
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('getOne');
|
|
194
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('getMany');
|
|
195
|
-
});
|
|
196
|
-
it('should be able to call "where", "cursor", "limit", "getOne", "getMany" after chaining multiple "orFilter"', async () => {
|
|
197
|
-
const globalStorage = newGlobalStorage();
|
|
198
|
-
const queryBuilderInstanceWithOrFilter = new query_api_2.CustomEntityBuilder(globalStorage)
|
|
199
|
-
.entity('books')
|
|
200
|
-
.index('by-rating-and-year', {
|
|
201
|
-
partition: [2019, 'John']
|
|
202
|
-
})
|
|
203
|
-
.orFilter('author', conditions_2.FilterConditions.contains('Doyle'))
|
|
204
|
-
.orFilter('genre', conditions_2.FilterConditions.equalsTo('horror'))
|
|
205
|
-
.where(conditions_2.WhereConditions.beginsWith('harry'))
|
|
206
|
-
.cursor('DUMMY_CURSOR_1234')
|
|
207
|
-
.limit(10)
|
|
208
|
-
.sort(query_interfaces_1.SortOrder.DESC);
|
|
209
|
-
expect(queryBuilderInstanceWithOrFilter).not.toHaveProperty('entity');
|
|
210
|
-
expect(queryBuilderInstanceWithOrFilter).not.toHaveProperty('index');
|
|
211
|
-
expect(queryBuilderInstanceWithOrFilter).not.toHaveProperty('andFilter');
|
|
212
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('where');
|
|
213
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('orFilter');
|
|
214
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('cursor');
|
|
215
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('limit');
|
|
216
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('sort');
|
|
217
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('getOne');
|
|
218
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('getMany');
|
|
219
|
-
await queryBuilderInstanceWithOrFilter.getMany();
|
|
220
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
221
|
-
sort: query_interfaces_1.SortOrder.DESC,
|
|
222
|
-
entityName: 'books',
|
|
223
|
-
indexName: 'by-rating-and-year',
|
|
224
|
-
partition: [2019, 'John'],
|
|
225
|
-
filterOperator: 'or',
|
|
226
|
-
range: {
|
|
227
|
-
condition: 'BEGINS_WITH',
|
|
228
|
-
values: ['harry']
|
|
229
|
-
},
|
|
230
|
-
filters: [
|
|
231
|
-
{
|
|
232
|
-
property: 'author',
|
|
233
|
-
condition: 'CONTAINS',
|
|
234
|
-
values: ['Doyle']
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
property: 'genre',
|
|
238
|
-
condition: 'EQUAL_TO',
|
|
239
|
-
values: ['horror']
|
|
240
|
-
}
|
|
241
|
-
],
|
|
242
|
-
limit: 10,
|
|
243
|
-
cursor: 'DUMMY_CURSOR_1234'
|
|
244
|
-
}));
|
|
245
|
-
});
|
|
246
|
-
it('should be able to call "where", "cursor", "limit", "getOne", "getMany" after chaining multiple "andFilter"', async () => {
|
|
247
|
-
const globalStorage = newGlobalStorage();
|
|
248
|
-
const queryBuilderInstanceWithOrFilter = new query_api_2.CustomEntityBuilder(globalStorage)
|
|
249
|
-
.entity('books')
|
|
250
|
-
.index('by-rating-and-year', {
|
|
251
|
-
partition: [2019, 'John']
|
|
252
|
-
})
|
|
253
|
-
.andFilter('author', conditions_2.FilterConditions.contains('Doyle'))
|
|
254
|
-
.andFilter('genre', conditions_2.FilterConditions.equalsTo('horror'))
|
|
255
|
-
.where(conditions_2.WhereConditions.beginsWith('harry'))
|
|
256
|
-
.cursor('DUMMY_CURSOR_1234')
|
|
257
|
-
.limit(10)
|
|
258
|
-
.sort(query_interfaces_1.SortOrder.DESC);
|
|
259
|
-
expect(queryBuilderInstanceWithOrFilter).not.toHaveProperty('entity');
|
|
260
|
-
expect(queryBuilderInstanceWithOrFilter).not.toHaveProperty('index');
|
|
261
|
-
expect(queryBuilderInstanceWithOrFilter).not.toHaveProperty('orFilter');
|
|
262
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('where');
|
|
263
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('andFilter');
|
|
264
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('cursor');
|
|
265
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('limit');
|
|
266
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('sort');
|
|
267
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('getOne');
|
|
268
|
-
expect(queryBuilderInstanceWithOrFilter).toHaveProperty('getMany');
|
|
269
|
-
await queryBuilderInstanceWithOrFilter.getMany();
|
|
270
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
271
|
-
sort: query_interfaces_1.SortOrder.DESC,
|
|
272
|
-
entityName: 'books',
|
|
273
|
-
indexName: 'by-rating-and-year',
|
|
274
|
-
partition: [2019, 'John'],
|
|
275
|
-
filterOperator: 'and',
|
|
276
|
-
range: {
|
|
277
|
-
condition: 'BEGINS_WITH',
|
|
278
|
-
values: ['harry']
|
|
279
|
-
},
|
|
280
|
-
filters: [
|
|
281
|
-
{
|
|
282
|
-
property: 'author',
|
|
283
|
-
condition: 'CONTAINS',
|
|
284
|
-
values: ['Doyle']
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
property: 'genre',
|
|
288
|
-
condition: 'EQUAL_TO',
|
|
289
|
-
values: ['horror']
|
|
290
|
-
}
|
|
291
|
-
],
|
|
292
|
-
limit: 10,
|
|
293
|
-
cursor: 'DUMMY_CURSOR_1234'
|
|
294
|
-
}));
|
|
295
|
-
});
|
|
296
|
-
it('should pass when BETWEEN filter and range are passed', async () => {
|
|
297
|
-
const globalStorage = newGlobalStorage();
|
|
298
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
299
|
-
.entity('books')
|
|
300
|
-
.index('by-author')
|
|
301
|
-
.where(conditions_2.WhereConditions.between([1, 2]))
|
|
302
|
-
.andFilter('author', conditions_2.FilterConditions.between([3, 4]))
|
|
303
|
-
.getMany();
|
|
304
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
305
|
-
entityName: 'books',
|
|
306
|
-
indexName: 'by-author',
|
|
307
|
-
filterOperator: 'and',
|
|
308
|
-
range: {
|
|
309
|
-
condition: 'BETWEEN',
|
|
310
|
-
values: [1, 2]
|
|
311
|
-
},
|
|
312
|
-
filters: [
|
|
313
|
-
{
|
|
314
|
-
property: 'author',
|
|
315
|
-
condition: 'BETWEEN',
|
|
316
|
-
values: [3, 4]
|
|
317
|
-
}
|
|
318
|
-
]
|
|
319
|
-
}));
|
|
320
|
-
});
|
|
321
|
-
it('should pass when BEGINS_WITH filter and range are passed', async () => {
|
|
322
|
-
const globalStorage = newGlobalStorage();
|
|
323
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
324
|
-
.entity('books')
|
|
325
|
-
.index('by-author')
|
|
326
|
-
.where(conditions_2.WhereConditions.beginsWith(1))
|
|
327
|
-
.andFilter('author', conditions_2.FilterConditions.beginsWith(2))
|
|
328
|
-
.getMany();
|
|
329
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
330
|
-
entityName: 'books',
|
|
331
|
-
indexName: 'by-author',
|
|
332
|
-
filterOperator: 'and',
|
|
333
|
-
range: {
|
|
334
|
-
condition: 'BEGINS_WITH',
|
|
335
|
-
values: [1]
|
|
336
|
-
},
|
|
337
|
-
filters: [
|
|
338
|
-
{
|
|
339
|
-
property: 'author',
|
|
340
|
-
condition: 'BEGINS_WITH',
|
|
341
|
-
values: [2]
|
|
342
|
-
}
|
|
343
|
-
]
|
|
344
|
-
}));
|
|
345
|
-
});
|
|
346
|
-
it('should pass when EXISTS filter is passed', async () => {
|
|
347
|
-
const globalStorage = newGlobalStorage();
|
|
348
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
349
|
-
.entity('books')
|
|
350
|
-
.index('by-rating')
|
|
351
|
-
.andFilter('rating', conditions_2.FilterConditions.exists())
|
|
352
|
-
.getMany();
|
|
353
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
354
|
-
entityName: 'books',
|
|
355
|
-
indexName: 'by-rating',
|
|
356
|
-
filterOperator: 'and',
|
|
357
|
-
filters: [
|
|
358
|
-
{
|
|
359
|
-
property: 'rating',
|
|
360
|
-
condition: 'EXISTS',
|
|
361
|
-
values: [true]
|
|
362
|
-
}
|
|
363
|
-
]
|
|
364
|
-
}));
|
|
365
|
-
});
|
|
366
|
-
it('should pass when DOES_NOT_EXIST filter is passed', async () => {
|
|
367
|
-
const globalStorage = newGlobalStorage();
|
|
368
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
369
|
-
.entity('books')
|
|
370
|
-
.index('by-rating')
|
|
371
|
-
.andFilter('rating', conditions_2.FilterConditions.doesNotExist())
|
|
372
|
-
.getMany();
|
|
373
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
374
|
-
entityName: 'books',
|
|
375
|
-
indexName: 'by-rating',
|
|
376
|
-
filterOperator: 'and',
|
|
377
|
-
filters: [
|
|
378
|
-
{
|
|
379
|
-
property: 'rating',
|
|
380
|
-
condition: 'NOT_EXISTS',
|
|
381
|
-
values: [true]
|
|
382
|
-
}
|
|
383
|
-
]
|
|
384
|
-
}));
|
|
385
|
-
});
|
|
386
|
-
it('should pass when GREATER_THAN filter is passed', async () => {
|
|
387
|
-
const globalStorage = newGlobalStorage();
|
|
388
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
389
|
-
.entity('books')
|
|
390
|
-
.index('by-author')
|
|
391
|
-
.where(conditions_2.WhereConditions.isGreaterThan(1))
|
|
392
|
-
.andFilter('rating', conditions_2.FilterConditions.isGreaterThan(1))
|
|
393
|
-
.getMany();
|
|
394
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
395
|
-
entityName: 'books',
|
|
396
|
-
indexName: 'by-author',
|
|
397
|
-
range: {
|
|
398
|
-
condition: 'GREATER_THAN',
|
|
399
|
-
values: [1]
|
|
400
|
-
},
|
|
401
|
-
filterOperator: 'and',
|
|
402
|
-
filters: [
|
|
403
|
-
{
|
|
404
|
-
property: 'rating',
|
|
405
|
-
condition: 'GREATER_THAN',
|
|
406
|
-
values: [1]
|
|
407
|
-
}
|
|
408
|
-
]
|
|
409
|
-
}));
|
|
410
|
-
});
|
|
411
|
-
it('should pass when GREATER_THAN_EQUAL_TO filter is passed', async () => {
|
|
412
|
-
const globalStorage = newGlobalStorage();
|
|
413
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
414
|
-
.entity('books')
|
|
415
|
-
.index('by-author')
|
|
416
|
-
.where(conditions_2.WhereConditions.isGreaterThanEqualTo(1))
|
|
417
|
-
.andFilter('rating', conditions_2.FilterConditions.isGreaterThanEqualTo(1))
|
|
418
|
-
.getMany();
|
|
419
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
420
|
-
entityName: 'books',
|
|
421
|
-
indexName: 'by-author',
|
|
422
|
-
range: {
|
|
423
|
-
condition: 'GREATER_THAN_EQUAL_TO',
|
|
424
|
-
values: [1]
|
|
425
|
-
},
|
|
426
|
-
filterOperator: 'and',
|
|
427
|
-
filters: [
|
|
428
|
-
{
|
|
429
|
-
property: 'rating',
|
|
430
|
-
condition: 'GREATER_THAN_EQUAL_TO',
|
|
431
|
-
values: [1]
|
|
432
|
-
}
|
|
433
|
-
]
|
|
434
|
-
}));
|
|
435
|
-
});
|
|
436
|
-
it('should pass when LESS_THAN filter is passed', async () => {
|
|
437
|
-
const globalStorage = newGlobalStorage();
|
|
438
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
439
|
-
.entity('books')
|
|
440
|
-
.index('by-author')
|
|
441
|
-
.where(conditions_2.WhereConditions.isLessThan(1))
|
|
442
|
-
.andFilter('rating', conditions_2.FilterConditions.isLessThan(1))
|
|
443
|
-
.getMany();
|
|
444
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
445
|
-
entityName: 'books',
|
|
446
|
-
indexName: 'by-author',
|
|
447
|
-
range: {
|
|
448
|
-
condition: 'LESS_THAN',
|
|
449
|
-
values: [1]
|
|
450
|
-
},
|
|
451
|
-
filterOperator: 'and',
|
|
452
|
-
filters: [
|
|
453
|
-
{
|
|
454
|
-
property: 'rating',
|
|
455
|
-
condition: 'LESS_THAN',
|
|
456
|
-
values: [1]
|
|
457
|
-
}
|
|
458
|
-
]
|
|
459
|
-
}));
|
|
460
|
-
});
|
|
461
|
-
it('should pass when LESS_THAN_EQUAL_TO filter is passed', async () => {
|
|
462
|
-
const globalStorage = newGlobalStorage();
|
|
463
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
464
|
-
.entity('books')
|
|
465
|
-
.index('by-author')
|
|
466
|
-
.where(conditions_2.WhereConditions.isLessThanEqualTo(1))
|
|
467
|
-
.andFilter('rating', conditions_2.FilterConditions.isLessThanEqualTo(1))
|
|
468
|
-
.getMany();
|
|
469
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
470
|
-
entityName: 'books',
|
|
471
|
-
indexName: 'by-author',
|
|
472
|
-
range: {
|
|
473
|
-
condition: 'LESS_THAN_EQUAL_TO',
|
|
474
|
-
values: [1]
|
|
475
|
-
},
|
|
476
|
-
filterOperator: 'and',
|
|
477
|
-
filters: [
|
|
478
|
-
{
|
|
479
|
-
property: 'rating',
|
|
480
|
-
condition: 'LESS_THAN_EQUAL_TO',
|
|
481
|
-
values: [1]
|
|
482
|
-
}
|
|
483
|
-
]
|
|
484
|
-
}));
|
|
485
|
-
});
|
|
486
|
-
it('should pass when CONTAINS filter is passed', async () => {
|
|
487
|
-
const globalStorage = newGlobalStorage();
|
|
488
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
489
|
-
.entity('books')
|
|
490
|
-
.index('by-author')
|
|
491
|
-
.andFilter('rating', conditions_2.FilterConditions.contains('Conan'))
|
|
492
|
-
.getMany();
|
|
493
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
494
|
-
entityName: 'books',
|
|
495
|
-
indexName: 'by-author',
|
|
496
|
-
filterOperator: 'and',
|
|
497
|
-
filters: [
|
|
498
|
-
{
|
|
499
|
-
property: 'rating',
|
|
500
|
-
condition: 'CONTAINS',
|
|
501
|
-
values: ['Conan']
|
|
502
|
-
}
|
|
503
|
-
]
|
|
504
|
-
}));
|
|
505
|
-
});
|
|
506
|
-
it('should pass when NOT_CONTAINS filter is passed', async () => {
|
|
507
|
-
const globalStorage = newGlobalStorage();
|
|
508
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
509
|
-
.entity('books')
|
|
510
|
-
.index('by-author')
|
|
511
|
-
.andFilter('rating', conditions_2.FilterConditions.doesNotContain('Conan'))
|
|
512
|
-
.getMany();
|
|
513
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
514
|
-
entityName: 'books',
|
|
515
|
-
indexName: 'by-author',
|
|
516
|
-
filterOperator: 'and',
|
|
517
|
-
filters: [
|
|
518
|
-
{
|
|
519
|
-
property: 'rating',
|
|
520
|
-
condition: 'NOT_CONTAINS',
|
|
521
|
-
values: ['Conan']
|
|
522
|
-
}
|
|
523
|
-
]
|
|
524
|
-
}));
|
|
525
|
-
});
|
|
526
|
-
it('should pass when EQUAL_TO filter is passed', async () => {
|
|
527
|
-
const globalStorage = newGlobalStorage();
|
|
528
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
529
|
-
.entity('books')
|
|
530
|
-
.index('by-author')
|
|
531
|
-
.andFilter('rating', conditions_2.FilterConditions.equalsTo('Conan'))
|
|
532
|
-
.getMany();
|
|
533
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
534
|
-
entityName: 'books',
|
|
535
|
-
indexName: 'by-author',
|
|
536
|
-
filterOperator: 'and',
|
|
537
|
-
filters: [
|
|
538
|
-
{
|
|
539
|
-
property: 'rating',
|
|
540
|
-
condition: 'EQUAL_TO',
|
|
541
|
-
values: ['Conan']
|
|
542
|
-
}
|
|
543
|
-
]
|
|
544
|
-
}));
|
|
545
|
-
});
|
|
546
|
-
it('should pass when NOT_EQUAL_TO filter is passed', async () => {
|
|
547
|
-
const globalStorage = newGlobalStorage();
|
|
548
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
549
|
-
.entity('books')
|
|
550
|
-
.index('by-author')
|
|
551
|
-
.andFilter('rating', conditions_2.FilterConditions.notEqualsTo('Conan'))
|
|
552
|
-
.getMany();
|
|
553
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
554
|
-
entityName: 'books',
|
|
555
|
-
indexName: 'by-author',
|
|
556
|
-
filterOperator: 'and',
|
|
557
|
-
filters: [
|
|
558
|
-
{
|
|
559
|
-
property: 'rating',
|
|
560
|
-
condition: 'NOT_EQUAL_TO',
|
|
561
|
-
values: ['Conan']
|
|
562
|
-
}
|
|
563
|
-
]
|
|
564
|
-
}));
|
|
565
|
-
});
|
|
566
|
-
it('should pass when filter operator is passed', async () => {
|
|
567
|
-
const globalStorage = newGlobalStorage();
|
|
568
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
569
|
-
.entity('books')
|
|
570
|
-
.index('by-author')
|
|
571
|
-
.where(conditions_2.WhereConditions.between([1, 2]))
|
|
572
|
-
.orFilter('author', conditions_2.FilterConditions.between([3, 4]))
|
|
573
|
-
.getMany();
|
|
574
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
575
|
-
entityName: 'books',
|
|
576
|
-
indexName: 'by-author',
|
|
577
|
-
filterOperator: 'or',
|
|
578
|
-
range: {
|
|
579
|
-
condition: 'BETWEEN',
|
|
580
|
-
values: [1, 2]
|
|
581
|
-
},
|
|
582
|
-
filters: [
|
|
583
|
-
{
|
|
584
|
-
property: 'author',
|
|
585
|
-
condition: 'BETWEEN',
|
|
586
|
-
values: [3, 4]
|
|
587
|
-
}
|
|
588
|
-
]
|
|
589
|
-
}));
|
|
590
|
-
});
|
|
591
|
-
it('should pass when ASC sort is passed', async () => {
|
|
592
|
-
const globalStorage = newGlobalStorage();
|
|
593
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
594
|
-
.entity('books')
|
|
595
|
-
.index('by-rating-and-year', {
|
|
596
|
-
partition: [2019]
|
|
597
|
-
})
|
|
598
|
-
.where(conditions_2.WhereConditions.between([1, 2]))
|
|
599
|
-
.sort(query_interfaces_1.SortOrder.ASC)
|
|
600
|
-
.limit(10)
|
|
601
|
-
.cursor('DUMMY_CURSOR_1234')
|
|
602
|
-
.getMany();
|
|
603
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
604
|
-
sort: query_interfaces_1.SortOrder.ASC,
|
|
605
|
-
entityName: 'books',
|
|
606
|
-
indexName: 'by-rating-and-year',
|
|
607
|
-
partition: [2019],
|
|
608
|
-
range: {
|
|
609
|
-
condition: 'BETWEEN',
|
|
610
|
-
values: [1, 2]
|
|
611
|
-
},
|
|
612
|
-
limit: 10,
|
|
613
|
-
cursor: 'DUMMY_CURSOR_1234'
|
|
614
|
-
}));
|
|
615
|
-
});
|
|
616
|
-
it('should pass when All entity queries operator are passed', async () => {
|
|
617
|
-
const globalStorage = newGlobalStorage();
|
|
618
|
-
await new query_api_2.CustomEntityBuilder(globalStorage)
|
|
619
|
-
.entity('books')
|
|
620
|
-
.index('by-rating-and-year', {
|
|
621
|
-
partition: [2019, 'John']
|
|
622
|
-
})
|
|
623
|
-
.where(conditions_2.WhereConditions.between([1, 2]))
|
|
624
|
-
.sort(query_interfaces_1.SortOrder.DESC)
|
|
625
|
-
.orFilter('author', conditions_2.FilterConditions.contains('Doyle'))
|
|
626
|
-
.limit(10)
|
|
627
|
-
.cursor('DUMMY_CURSOR_1234')
|
|
628
|
-
.getMany();
|
|
629
|
-
expect(globalStorage.listCustomEntities).toHaveBeenCalledWith(expect.objectContaining({
|
|
630
|
-
sort: query_interfaces_1.SortOrder.DESC,
|
|
631
|
-
entityName: 'books',
|
|
632
|
-
indexName: 'by-rating-and-year',
|
|
633
|
-
partition: [2019, 'John'],
|
|
634
|
-
filterOperator: 'or',
|
|
635
|
-
range: {
|
|
636
|
-
condition: 'BETWEEN',
|
|
637
|
-
values: [1, 2]
|
|
638
|
-
},
|
|
639
|
-
filters: [
|
|
640
|
-
{
|
|
641
|
-
property: 'author',
|
|
642
|
-
condition: 'CONTAINS',
|
|
643
|
-
values: ['Doyle']
|
|
644
|
-
}
|
|
645
|
-
],
|
|
646
|
-
limit: 10,
|
|
647
|
-
cursor: 'DUMMY_CURSOR_1234'
|
|
648
|
-
}));
|
|
649
|
-
});
|
|
650
|
-
});
|
package/out/conditions.d.ts
DELETED
package/out/conditions.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../src/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAKnD"}
|
package/out/conditions.js
DELETED