@tstdl/base 0.85.21 → 0.85.23
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/browser/element-controller.d.ts +2 -0
- package/browser/element-controller.js +18 -1
- package/database/mongo/mongo-entity-repository.d.ts +3 -3
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +18 -0
- package/decorators/log.d.ts +2 -0
- package/decorators/log.js +49 -0
- package/function/index.d.ts +1 -0
- package/function/index.js +18 -0
- package/function/log.d.ts +6 -0
- package/function/log.js +37 -0
- package/package.json +12 -12
|
@@ -21,6 +21,8 @@ export declare class ElementController<T extends Locator | ElementHandle = Locat
|
|
|
21
21
|
readonly locatorOrHandle: T;
|
|
22
22
|
readonly options: ElementControllerOptions;
|
|
23
23
|
constructor(locatorOrHandle: T, options?: ElementControllerOptions);
|
|
24
|
+
getAll(): Promise<ElementController<Locator>[]>;
|
|
25
|
+
getAllHandles(): Promise<ElementController<ElementHandle>[]>;
|
|
24
26
|
/**
|
|
25
27
|
* Wait for element state
|
|
26
28
|
* @param state some states may only be usable for either locator or handle
|
|
@@ -32,6 +32,20 @@ class ElementController {
|
|
|
32
32
|
this.locatorOrHandle = locatorOrHandle;
|
|
33
33
|
this.options = options;
|
|
34
34
|
}
|
|
35
|
+
async getAll() {
|
|
36
|
+
if (!(0, import_utils.isLocator)(this.locatorOrHandle)) {
|
|
37
|
+
throw new Error("getAll only works with Locator");
|
|
38
|
+
}
|
|
39
|
+
const locators = await this.locatorOrHandle.all();
|
|
40
|
+
return locators.map((locator) => new ElementController(locator));
|
|
41
|
+
}
|
|
42
|
+
async getAllHandles() {
|
|
43
|
+
if (!(0, import_utils.isLocator)(this.locatorOrHandle)) {
|
|
44
|
+
throw new Error("getAllHandles only works with Locator");
|
|
45
|
+
}
|
|
46
|
+
const handles = await this.locatorOrHandle.elementHandles();
|
|
47
|
+
return handles.map((handle) => new ElementController(handle));
|
|
48
|
+
}
|
|
35
49
|
/**
|
|
36
50
|
* Wait for element state
|
|
37
51
|
* @param state some states may only be usable for either locator or handle
|
|
@@ -52,7 +66,10 @@ class ElementController {
|
|
|
52
66
|
try {
|
|
53
67
|
await this.waitFor(options?.state ?? "visible", { timeout: options?.timeout ?? 250 });
|
|
54
68
|
return true;
|
|
55
|
-
} catch {
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error instanceof Error && error.message.includes("violation")) {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
56
73
|
return false;
|
|
57
74
|
}
|
|
58
75
|
}
|
|
@@ -5,7 +5,7 @@ import { EntityRepository } from '../../database/index.js';
|
|
|
5
5
|
import type { Logger } from '../../logger/index.js';
|
|
6
6
|
import type { Collection } from './classes.js';
|
|
7
7
|
import { MongoBaseRepository } from './mongo-base.repository.js';
|
|
8
|
-
import type { TypedIndexDescription } from './types.js';
|
|
8
|
+
import type { Filter, TypedIndexDescription, UpdateFilter } from './types.js';
|
|
9
9
|
export type MongoEntityRepositoryOptions<T extends Entity<any>> = {
|
|
10
10
|
logger: Logger;
|
|
11
11
|
indexes?: TypedIndexDescription<T>[];
|
|
@@ -93,6 +93,6 @@ export declare class MongoEntityRepository<T extends Entity<any>, TDb extends En
|
|
|
93
93
|
deleteManyById(ids: string[]): Promise<number>;
|
|
94
94
|
deleteByFilter<U extends T = T>(filter: Query<U>): Promise<boolean>;
|
|
95
95
|
deleteManyByFilter<U extends T = T>(filter: Query<U>): Promise<number>;
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
transformFilter<U extends T = T>(filter: Query<U>): Filter<TDb>;
|
|
97
|
+
transformPatch<U extends T = T>(patch: EntityPatch<U>): UpdateFilter<TDb>;
|
|
98
98
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './log.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var decorators_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(decorators_exports);
|
|
18
|
+
__reExport(decorators_exports, require("./log.js"), module.exports);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var log_exports = {};
|
|
20
|
+
__export(log_exports, {
|
|
21
|
+
Log: () => Log
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(log_exports);
|
|
24
|
+
var import_log = require("../function/log.js");
|
|
25
|
+
var import_registry = require("../reflection/registry.js");
|
|
26
|
+
var import_utils = require("../reflection/utils.js");
|
|
27
|
+
var import_object = require("../utils/object/object.js");
|
|
28
|
+
var import_type_guards = require("../utils/type-guards.js");
|
|
29
|
+
const logWrapped = Symbol("logged wrapped");
|
|
30
|
+
function Log() {
|
|
31
|
+
return (0, import_utils.createDecorator)({ class: true, method: true }, (data, metadata) => {
|
|
32
|
+
if (metadata.data.has(logWrapped)) {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
metadata.data.set(logWrapped, true);
|
|
36
|
+
if (data.type == "method") {
|
|
37
|
+
return { value: (0, import_log.wrapLog)(data.descriptor.value) };
|
|
38
|
+
}
|
|
39
|
+
const staticProperties = (0, import_object.objectKeys)(data.constructor).filter((property) => property != "length" && property != "name" && property != "prototype" && (0, import_type_guards.isFunction)(data.constructor[property]) && !(import_registry.reflectionRegistry.getMetadata(data.constructor)?.staticMethods.get(property)?.data.has(logWrapped) ?? false));
|
|
40
|
+
const instanceProperties = (0, import_object.objectKeys)(data.prototype).filter((property) => property != "constructor" && (0, import_type_guards.isFunction)(data.prototype[property]) && !(import_registry.reflectionRegistry.getMetadata(data.constructor)?.methods.get(property)?.data.has(logWrapped) ?? false));
|
|
41
|
+
for (const property of staticProperties) {
|
|
42
|
+
data.constructor[property] = (0, import_log.wrapLog)(data.constructor[property], property);
|
|
43
|
+
}
|
|
44
|
+
for (const property of instanceProperties) {
|
|
45
|
+
data.prototype[property] = (0, import_log.wrapLog)(data.prototype[property], property);
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './log.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var function_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(function_exports);
|
|
18
|
+
__reExport(function_exports, require("./log.js"), module.exports);
|
package/function/log.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var log_exports = {};
|
|
20
|
+
__export(log_exports, {
|
|
21
|
+
wrapLog: () => wrapLog
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(log_exports);
|
|
24
|
+
var import_type_guards = require("../utils/type-guards.js");
|
|
25
|
+
var import_type_of = require("../utils/type-of.js");
|
|
26
|
+
function wrapLog(fn, options) {
|
|
27
|
+
const fnName = options?.fnName ?? fn.name;
|
|
28
|
+
const log = options?.logger?.trace.bind(options.logger) ?? console.log.bind(console);
|
|
29
|
+
const wrapped = {
|
|
30
|
+
[fnName](...args) {
|
|
31
|
+
const argString = args.map((arg) => (0, import_type_guards.isPrimitive)(arg) ? arg : (0, import_type_of.typeOf)(arg)).join(", ");
|
|
32
|
+
log(`[call: ${fnName}(${argString})]`);
|
|
33
|
+
return Reflect.apply(fn, this, args);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return wrapped[fnName];
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.85.
|
|
3
|
+
"version": "0.85.23",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"tsc-alias:watch": "tsc-alias --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"luxon": "^3.
|
|
23
|
+
"luxon": "^3.4",
|
|
24
24
|
"reflect-metadata": "^0.1",
|
|
25
25
|
"rxjs": "^7.8",
|
|
26
|
-
"type-fest": "^4.
|
|
26
|
+
"type-fest": "^4.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/chroma-js": "2.4",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"@types/mjml": "4.7",
|
|
34
34
|
"@types/node": "20",
|
|
35
35
|
"@types/nodemailer": "6.4",
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
37
|
-
"@typescript-eslint/parser": "6.
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "6.4",
|
|
37
|
+
"@typescript-eslint/parser": "6.4",
|
|
38
38
|
"concurrently": "8.2",
|
|
39
|
-
"esbuild": "0.
|
|
40
|
-
"eslint": "8.
|
|
41
|
-
"eslint-import-resolver-typescript": "3.
|
|
42
|
-
"eslint-plugin-import": "2.
|
|
39
|
+
"esbuild": "0.19",
|
|
40
|
+
"eslint": "8.47",
|
|
41
|
+
"eslint-import-resolver-typescript": "3.6",
|
|
42
|
+
"eslint-plugin-import": "2.28",
|
|
43
43
|
"tsc-alias": "1.8",
|
|
44
44
|
"typedoc": "0.24",
|
|
45
45
|
"typescript": "5.1"
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"mjml": "^4.14",
|
|
61
61
|
"mongodb": "^5.7",
|
|
62
62
|
"nodemailer": "^6.9",
|
|
63
|
-
"playwright": "^1.
|
|
64
|
-
"preact": "^10.
|
|
63
|
+
"playwright": "^1.37",
|
|
64
|
+
"preact": "^10.17",
|
|
65
65
|
"preact-render-to-string": "^6.2",
|
|
66
|
-
"undici": "^5.
|
|
66
|
+
"undici": "^5.23",
|
|
67
67
|
"urlpattern-polyfill": "^9.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependenciesMeta": {
|