@nymphjs/nymph 1.0.0-beta.0 → 1.0.0-beta.2
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/Entity.js +55 -64
- package/dist/Entity.js.map +1 -1
- package/dist/Entity.test.js +73 -86
- package/dist/Entity.test.js.map +1 -1
- package/dist/Nymph.js +137 -187
- package/dist/Nymph.js.map +1 -1
- package/dist/Nymph.types.d.ts +19 -19
- package/dist/Nymph.types.js.map +1 -1
- package/dist/driver/NymphDriver.js +123 -141
- package/dist/driver/NymphDriver.js.map +1 -1
- package/dist/driver/testArtifacts.js +510 -535
- package/dist/driver/testArtifacts.js.map +1 -1
- package/dist/testArtifacts.js +4 -23
- package/dist/testArtifacts.js.map +1 -1
- package/dist/testMocks.js +30 -47
- package/dist/testMocks.js.map +1 -1
- package/dist/utils.js +3 -4
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/Nymph.ts +19 -19
- package/src/Nymph.types.ts +25 -19
- package/tsconfig.json +2 -0
package/src/Nymph.ts
CHANGED
|
@@ -190,7 +190,7 @@ export default class Nymph {
|
|
|
190
190
|
const result = this.driver.connect();
|
|
191
191
|
for (let callback of this.connectCallbacks) {
|
|
192
192
|
if (callback) {
|
|
193
|
-
callback(this, result);
|
|
193
|
+
await callback(this, result);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
return await result;
|
|
@@ -205,7 +205,7 @@ export default class Nymph {
|
|
|
205
205
|
const result = this.driver.disconnect();
|
|
206
206
|
for (let callback of this.disconnectCallbacks) {
|
|
207
207
|
if (callback) {
|
|
208
|
-
callback(this, result);
|
|
208
|
+
await callback(this, result);
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
return await result;
|
|
@@ -220,7 +220,7 @@ export default class Nymph {
|
|
|
220
220
|
) {
|
|
221
221
|
for (let callback of this.queryCallbacks) {
|
|
222
222
|
if (callback) {
|
|
223
|
-
callback(this, options, selectors);
|
|
223
|
+
await callback(this, options, selectors);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
}
|
|
@@ -292,13 +292,13 @@ export default class Nymph {
|
|
|
292
292
|
public async newUID(name: string): Promise<number | null> {
|
|
293
293
|
for (let callback of this.beforeNewUIDCallbacks) {
|
|
294
294
|
if (callback) {
|
|
295
|
-
callback(this, name);
|
|
295
|
+
await callback(this, name);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
const result = this.driver.newUID(name);
|
|
299
299
|
for (let callback of this.afterNewUIDCallbacks) {
|
|
300
300
|
if (callback) {
|
|
301
|
-
callback(this, result);
|
|
301
|
+
await callback(this, result);
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
return await result;
|
|
@@ -323,13 +323,13 @@ export default class Nymph {
|
|
|
323
323
|
public async setUID(name: string, value: number): Promise<boolean> {
|
|
324
324
|
for (let callback of this.beforeSetUIDCallbacks) {
|
|
325
325
|
if (callback) {
|
|
326
|
-
callback(this, name, value);
|
|
326
|
+
await callback(this, name, value);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
const result = this.driver.setUID(name, value);
|
|
330
330
|
for (let callback of this.afterSetUIDCallbacks) {
|
|
331
331
|
if (callback) {
|
|
332
|
-
callback(this, result);
|
|
332
|
+
await callback(this, result);
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
return await result;
|
|
@@ -344,13 +344,13 @@ export default class Nymph {
|
|
|
344
344
|
public async deleteUID(name: string): Promise<boolean> {
|
|
345
345
|
for (let callback of this.beforeDeleteUIDCallbacks) {
|
|
346
346
|
if (callback) {
|
|
347
|
-
callback(this, name);
|
|
347
|
+
await callback(this, name);
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
const result = this.driver.deleteUID(name);
|
|
351
351
|
for (let callback of this.afterDeleteUIDCallbacks) {
|
|
352
352
|
if (callback) {
|
|
353
|
-
callback(this, result);
|
|
353
|
+
await callback(this, result);
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
return await result;
|
|
@@ -366,13 +366,13 @@ export default class Nymph {
|
|
|
366
366
|
public async renameUID(oldName: string, newName: string): Promise<boolean> {
|
|
367
367
|
for (let callback of this.beforeRenameUIDCallbacks) {
|
|
368
368
|
if (callback) {
|
|
369
|
-
callback(this, oldName, newName);
|
|
369
|
+
await callback(this, oldName, newName);
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
const result = this.driver.renameUID(oldName, newName);
|
|
373
373
|
for (let callback of this.afterRenameUIDCallbacks) {
|
|
374
374
|
if (callback) {
|
|
375
|
-
callback(this, result);
|
|
375
|
+
await callback(this, result);
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
return await result;
|
|
@@ -392,13 +392,13 @@ export default class Nymph {
|
|
|
392
392
|
public async saveEntity(entity: EntityInterface): Promise<boolean> {
|
|
393
393
|
for (let callback of this.beforeSaveEntityCallbacks) {
|
|
394
394
|
if (callback) {
|
|
395
|
-
callback(this, entity);
|
|
395
|
+
await callback(this, entity);
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
const result = this.driver.saveEntity(entity);
|
|
399
399
|
for (let callback of this.afterSaveEntityCallbacks) {
|
|
400
400
|
if (callback) {
|
|
401
|
-
callback(this, result);
|
|
401
|
+
await callback(this, result);
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
return await result;
|
|
@@ -581,7 +581,7 @@ export default class Nymph {
|
|
|
581
581
|
): Promise<ReturnType<T['factorySync']>[] | string[] | number> {
|
|
582
582
|
for (let callback of this.beforeGetEntitiesCallbacks) {
|
|
583
583
|
if (callback) {
|
|
584
|
-
callback(this, options, selectors);
|
|
584
|
+
await callback(this, options, selectors);
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
587
|
return await this.driver.getEntities(options, ...selectors);
|
|
@@ -631,7 +631,7 @@ export default class Nymph {
|
|
|
631
631
|
options.limit = 1;
|
|
632
632
|
for (let callback of this.beforeGetEntityCallbacks) {
|
|
633
633
|
if (callback) {
|
|
634
|
-
callback(this, options, selectors as Selector[]);
|
|
634
|
+
await callback(this, options, selectors as Selector[]);
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
637
|
const entities = await this.driver.getEntities(
|
|
@@ -656,13 +656,13 @@ export default class Nymph {
|
|
|
656
656
|
public async deleteEntity(entity: EntityInterface): Promise<boolean> {
|
|
657
657
|
for (let callback of this.beforeDeleteEntityCallbacks) {
|
|
658
658
|
if (callback) {
|
|
659
|
-
callback(this, entity);
|
|
659
|
+
await callback(this, entity);
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
662
|
const result = this.driver.deleteEntity(entity);
|
|
663
663
|
for (let callback of this.afterDeleteEntityCallbacks) {
|
|
664
664
|
if (callback) {
|
|
665
|
-
callback(this, result);
|
|
665
|
+
await callback(this, result);
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
return await result;
|
|
@@ -681,13 +681,13 @@ export default class Nymph {
|
|
|
681
681
|
): Promise<boolean> {
|
|
682
682
|
for (let callback of this.beforeDeleteEntityByIDCallbacks) {
|
|
683
683
|
if (callback) {
|
|
684
|
-
callback(this, guid, className);
|
|
684
|
+
await callback(this, guid, className);
|
|
685
685
|
}
|
|
686
686
|
}
|
|
687
687
|
const result = this.driver.deleteEntityByID(guid, className);
|
|
688
688
|
for (let callback of this.afterDeleteEntityByIDCallbacks) {
|
|
689
689
|
if (callback) {
|
|
690
|
-
callback(this, result);
|
|
690
|
+
await callback(this, result);
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
693
|
return await result;
|
package/src/Nymph.types.ts
CHANGED
|
@@ -24,80 +24,86 @@ export type NymphEventType =
|
|
|
24
24
|
export type NymphConnectCallback = (
|
|
25
25
|
nymph: Nymph,
|
|
26
26
|
result: Promise<boolean>
|
|
27
|
-
) => void
|
|
27
|
+
) => Promise<void>;
|
|
28
28
|
export type NymphDisconnectCallback = (
|
|
29
29
|
nymph: Nymph,
|
|
30
30
|
result: Promise<boolean>
|
|
31
|
-
) => void
|
|
31
|
+
) => Promise<void>;
|
|
32
32
|
/** The NymphQueryCallback will be called on both top level and qref queries. */
|
|
33
33
|
export type NymphQueryCallback = (
|
|
34
34
|
nymph: Nymph,
|
|
35
35
|
options: Options,
|
|
36
36
|
selectors: FormattedSelector[]
|
|
37
|
-
) => void
|
|
37
|
+
) => Promise<void>;
|
|
38
38
|
export type NymphBeforeGetEntityCallback = (
|
|
39
39
|
nymph: Nymph,
|
|
40
40
|
options: Options,
|
|
41
41
|
selectors: Selector[]
|
|
42
|
-
) => void
|
|
42
|
+
) => Promise<void>;
|
|
43
43
|
export type NymphBeforeGetEntitiesCallback = (
|
|
44
44
|
nymph: Nymph,
|
|
45
45
|
options: Options,
|
|
46
46
|
selectors: Selector[]
|
|
47
|
-
) => void
|
|
47
|
+
) => Promise<void>;
|
|
48
48
|
export type NymphBeforeSaveEntityCallback = (
|
|
49
49
|
nymph: Nymph,
|
|
50
50
|
entity: EntityInterface
|
|
51
|
-
) => void
|
|
51
|
+
) => Promise<void>;
|
|
52
52
|
export type NymphAfterSaveEntityCallback = (
|
|
53
53
|
nymph: Nymph,
|
|
54
54
|
result: Promise<boolean>
|
|
55
|
-
) => void
|
|
55
|
+
) => Promise<void>;
|
|
56
56
|
export type NymphBeforeDeleteEntityCallback = (
|
|
57
57
|
nymph: Nymph,
|
|
58
58
|
entity: EntityInterface
|
|
59
|
-
) => void
|
|
59
|
+
) => Promise<void>;
|
|
60
60
|
export type NymphAfterDeleteEntityCallback = (
|
|
61
61
|
nymph: Nymph,
|
|
62
62
|
result: Promise<boolean>
|
|
63
|
-
) => void
|
|
63
|
+
) => Promise<void>;
|
|
64
64
|
export type NymphBeforeDeleteEntityByIDCallback = (
|
|
65
65
|
nymph: Nymph,
|
|
66
66
|
guid: string,
|
|
67
67
|
className?: string
|
|
68
|
-
) => void
|
|
68
|
+
) => Promise<void>;
|
|
69
69
|
export type NymphAfterDeleteEntityByIDCallback = (
|
|
70
70
|
nymph: Nymph,
|
|
71
71
|
result: Promise<boolean>
|
|
72
|
-
) => void
|
|
73
|
-
export type NymphBeforeNewUIDCallback = (
|
|
72
|
+
) => Promise<void>;
|
|
73
|
+
export type NymphBeforeNewUIDCallback = (
|
|
74
|
+
nymph: Nymph,
|
|
75
|
+
name: string
|
|
76
|
+
) => Promise<void>;
|
|
74
77
|
export type NymphAfterNewUIDCallback = (
|
|
75
78
|
nymph: Nymph,
|
|
76
79
|
result: Promise<number | null>
|
|
77
|
-
) => void
|
|
80
|
+
) => Promise<void>;
|
|
78
81
|
export type NymphBeforeSetUIDCallback = (
|
|
79
82
|
nymph: Nymph,
|
|
80
83
|
name: string,
|
|
81
84
|
value: number
|
|
82
|
-
) => void
|
|
85
|
+
) => Promise<void>;
|
|
83
86
|
export type NymphAfterSetUIDCallback = (
|
|
84
87
|
nymph: Nymph,
|
|
85
88
|
result: Promise<boolean>
|
|
86
|
-
) => void
|
|
89
|
+
) => Promise<void>;
|
|
87
90
|
export type NymphBeforeRenameUIDCallback = (
|
|
88
91
|
nymph: Nymph,
|
|
89
92
|
oldName: string,
|
|
90
93
|
newName: string
|
|
91
|
-
) => void
|
|
94
|
+
) => Promise<void>;
|
|
92
95
|
export type NymphAfterRenameUIDCallback = (
|
|
93
96
|
nymph: Nymph,
|
|
94
97
|
result: Promise<boolean>
|
|
95
|
-
) => void
|
|
96
|
-
export type NymphBeforeDeleteUIDCallback = (
|
|
98
|
+
) => Promise<void>;
|
|
99
|
+
export type NymphBeforeDeleteUIDCallback = (
|
|
100
|
+
nymph: Nymph,
|
|
101
|
+
name: string
|
|
102
|
+
) => Promise<void>;
|
|
97
103
|
export type NymphAfterDeleteUIDCallback = (
|
|
98
104
|
nymph: Nymph,
|
|
99
105
|
result: Promise<boolean>
|
|
100
|
-
) => void
|
|
106
|
+
) => Promise<void>;
|
|
101
107
|
|
|
102
108
|
export type Options<T extends EntityConstructor = EntityConstructor> = {
|
|
103
109
|
class?: T;
|