@nymphjs/nymph 1.0.0-beta.103 → 1.0.0-beta.105
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 +12 -0
- package/dist/Nymph.d.ts +58 -4
- package/dist/Nymph.js +55 -0
- package/dist/Nymph.js.map +1 -1
- package/dist/Nymph.types.d.ts +5 -1
- package/dist/Nymph.types.js.map +1 -1
- package/dist/driver/NymphDriver.d.ts +12 -3
- package/dist/driver/NymphDriver.js +5 -0
- package/dist/driver/NymphDriver.js.map +1 -1
- package/dist/driver/testArtifacts.js +89 -1
- package/dist/driver/testArtifacts.js.map +1 -1
- package/dist/errors/QueryFailedError.d.ts +2 -1
- package/dist/errors/QueryFailedError.js +3 -1
- package/dist/errors/QueryFailedError.js.map +1 -1
- package/package.json +3 -3
- package/src/Nymph.ts +75 -4
- package/src/Nymph.types.ts +5 -1
- package/src/driver/NymphDriver.ts +28 -3
- package/src/driver/testArtifacts.ts +125 -1
- package/src/errors/QueryFailedError.ts +3 -1
|
@@ -189,6 +189,119 @@ export function EntitiesTest(
|
|
|
189
189
|
expect(await testEntity.$delete()).toEqual(true);
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
+
it('create, list, and delete indexes', async () => {
|
|
193
|
+
// Delete existing indexes.
|
|
194
|
+
const existingIndexes = await nymph.getIndexes(TestModel.ETYPE);
|
|
195
|
+
for (let index of existingIndexes) {
|
|
196
|
+
await nymph.deleteIndex(TestModel.ETYPE, index.scope, index.name);
|
|
197
|
+
}
|
|
198
|
+
const existingBIndexes = await nymph.getIndexes(TestBModel.ETYPE);
|
|
199
|
+
for (let index of existingBIndexes) {
|
|
200
|
+
await nymph.deleteIndex(TestBModel.ETYPE, index.scope, index.name);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const sortByName = (arr: { name: string }[]) => {
|
|
204
|
+
arr.sort((a, b) => a.name.localeCompare(b.name));
|
|
205
|
+
return arr;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
expect(
|
|
209
|
+
await nymph.addIndex(TestModel.ETYPE, {
|
|
210
|
+
scope: 'data',
|
|
211
|
+
name: 'testindex',
|
|
212
|
+
property: 'test',
|
|
213
|
+
}),
|
|
214
|
+
).toEqual(true);
|
|
215
|
+
|
|
216
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
217
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
218
|
+
]);
|
|
219
|
+
|
|
220
|
+
expect(
|
|
221
|
+
await nymph.addIndex(TestModel.ETYPE, {
|
|
222
|
+
scope: 'data',
|
|
223
|
+
name: 'secondone',
|
|
224
|
+
property: 'match',
|
|
225
|
+
}),
|
|
226
|
+
).toEqual(true);
|
|
227
|
+
|
|
228
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
229
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
230
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
231
|
+
]);
|
|
232
|
+
|
|
233
|
+
expect(
|
|
234
|
+
await nymph.addIndex(TestModel.ETYPE, {
|
|
235
|
+
scope: 'references',
|
|
236
|
+
name: 'refone',
|
|
237
|
+
property: 'reference',
|
|
238
|
+
}),
|
|
239
|
+
).toEqual(true);
|
|
240
|
+
|
|
241
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
242
|
+
{ scope: 'references', name: 'refone', property: 'reference' },
|
|
243
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
244
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
245
|
+
]);
|
|
246
|
+
|
|
247
|
+
expect(
|
|
248
|
+
await nymph.addIndex(TestModel.ETYPE, {
|
|
249
|
+
scope: 'tokens',
|
|
250
|
+
name: 'tokenone',
|
|
251
|
+
property: 'search',
|
|
252
|
+
}),
|
|
253
|
+
).toEqual(true);
|
|
254
|
+
|
|
255
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
256
|
+
{ scope: 'references', name: 'refone', property: 'reference' },
|
|
257
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
258
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
259
|
+
{ scope: 'tokens', name: 'tokenone', property: 'search' },
|
|
260
|
+
]);
|
|
261
|
+
|
|
262
|
+
expect(
|
|
263
|
+
await nymph.addIndex(TestBModel.ETYPE, {
|
|
264
|
+
scope: 'data',
|
|
265
|
+
name: 'flooflab',
|
|
266
|
+
property: 'string',
|
|
267
|
+
}),
|
|
268
|
+
).toEqual(true);
|
|
269
|
+
|
|
270
|
+
expect(sortByName(await nymph.getIndexes(TestBModel.ETYPE))).toEqual([
|
|
271
|
+
{ scope: 'data', name: 'flooflab', property: 'string' },
|
|
272
|
+
]);
|
|
273
|
+
|
|
274
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
275
|
+
{ scope: 'references', name: 'refone', property: 'reference' },
|
|
276
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
277
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
278
|
+
{ scope: 'tokens', name: 'tokenone', property: 'search' },
|
|
279
|
+
]);
|
|
280
|
+
|
|
281
|
+
expect(
|
|
282
|
+
await nymph.deleteIndex(TestBModel.ETYPE, 'data', 'flooflab'),
|
|
283
|
+
).toEqual(true);
|
|
284
|
+
|
|
285
|
+
expect(await nymph.getIndexes(TestBModel.ETYPE)).toEqual([]);
|
|
286
|
+
|
|
287
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
288
|
+
{ scope: 'references', name: 'refone', property: 'reference' },
|
|
289
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
290
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
291
|
+
{ scope: 'tokens', name: 'tokenone', property: 'search' },
|
|
292
|
+
]);
|
|
293
|
+
|
|
294
|
+
expect(
|
|
295
|
+
await nymph.deleteIndex(TestModel.ETYPE, 'data', 'testindex'),
|
|
296
|
+
).toEqual(true);
|
|
297
|
+
|
|
298
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
299
|
+
{ scope: 'references', name: 'refone', property: 'reference' },
|
|
300
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
301
|
+
{ scope: 'tokens', name: 'tokenone', property: 'search' },
|
|
302
|
+
]);
|
|
303
|
+
});
|
|
304
|
+
|
|
192
305
|
it('transactions', async () => {
|
|
193
306
|
await createTestEntities();
|
|
194
307
|
|
|
@@ -282,7 +395,7 @@ export function EntitiesTest(
|
|
|
282
395
|
await createTestEntities();
|
|
283
396
|
|
|
284
397
|
// Testing entity order, offset, limit...
|
|
285
|
-
|
|
398
|
+
let resultEntities = await nymph.getEntities(
|
|
286
399
|
{
|
|
287
400
|
class: TestModel,
|
|
288
401
|
reverse: true,
|
|
@@ -294,6 +407,17 @@ export function EntitiesTest(
|
|
|
294
407
|
);
|
|
295
408
|
expect(resultEntities.length).toEqual(1);
|
|
296
409
|
expect(testEntity.$is(resultEntities[0])).toEqual(true);
|
|
410
|
+
|
|
411
|
+
// Testing null sort...
|
|
412
|
+
resultEntities = await nymph.getEntities(
|
|
413
|
+
{
|
|
414
|
+
class: TestModel,
|
|
415
|
+
reverse: true,
|
|
416
|
+
sort: null,
|
|
417
|
+
},
|
|
418
|
+
{ type: '&', tag: 'test' },
|
|
419
|
+
);
|
|
420
|
+
expect(testEntity.$inArray(resultEntities)).toEqual(true);
|
|
297
421
|
});
|
|
298
422
|
|
|
299
423
|
it('guid and tags', async () => {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export class QueryFailedError extends Error {
|
|
2
2
|
private query?: string;
|
|
3
|
+
public errorCode?: number;
|
|
3
4
|
|
|
4
|
-
constructor(message: string, query?: string) {
|
|
5
|
+
constructor(message: string, query?: string, errorCode?: number) {
|
|
5
6
|
super(message);
|
|
6
7
|
this.name = 'QueryFailedError';
|
|
7
8
|
this.query = query;
|
|
9
|
+
this.errorCode = errorCode;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
public getQuery() {
|