@wild-framework/database 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wild Framework contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @wild-framework/database
2
+
3
+ Database connection abstraction for [Wild Framework](https://github.com/your-org/wild-framework).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @wild-framework/database
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { Database } from "@wild-framework/database";
15
+
16
+ await db.connect();
17
+ db.insert("users", { id: 1, name: "John" });
18
+ const rows = db.all("users");
19
+ await db.close();
20
+ ```
21
+
22
+ Ships with an in-memory driver. For production, use `@wild-framework/database-drizzle`.
23
+
24
+ ## License
25
+
26
+ MIT
@@ -0,0 +1,30 @@
1
+ import type { DatabaseDriver, Row } from "./driver.js";
2
+ /**
3
+ * Database facade.
4
+ *
5
+ * Wraps a `DatabaseDriver` and exposes lifecycle plus the driver
6
+ * for ORM-specific operations. Data-capable drivers (implements
7
+ * `DatabaseStore`) also expose simple table operations.
8
+ *
9
+ * Resolved from the container: `app.resolve(Database)`.
10
+ */
11
+ export declare class Database {
12
+ readonly driver: DatabaseDriver;
13
+ constructor(driver: DatabaseDriver);
14
+ /** Establish the connection. */
15
+ connect(): Promise<void>;
16
+ /** Close the connection. */
17
+ close(): Promise<void>;
18
+ /** Whether the connection is currently open. */
19
+ isConnected(): boolean;
20
+ /** All rows in a table. */
21
+ all(table: string): Row[];
22
+ /** Insert a row and return it. */
23
+ insert(table: string, row: Row): Row;
24
+ /** Find rows matching a predicate. */
25
+ find(table: string, predicate: (row: Row) => boolean): Row[];
26
+ /** Remove rows matching a predicate. Returns the number removed. */
27
+ remove(table: string, predicate: (row: Row) => boolean): number;
28
+ private store;
29
+ }
30
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAiB,GAAG,EAAE,MAAM,aAAa,CAAC;AAEtE;;;;;;;;GAQG;AACH,qBAAa,QAAQ;aACW,MAAM,EAAE,cAAc;gBAAtB,MAAM,EAAE,cAAc;IAElD,gCAAgC;IAC1B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,4BAA4B;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,gDAAgD;IAChD,WAAW,IAAI,OAAO;IAQtB,2BAA2B;IAC3B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE;IAIzB,kCAAkC;IAClC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG;IAIpC,sCAAsC;IACtC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,GAAG,GAAG,EAAE;IAI5D,oEAAoE;IACpE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,GAAG,MAAM;IAI/D,OAAO,CAAC,KAAK;CAShB"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Database facade.
3
+ *
4
+ * Wraps a `DatabaseDriver` and exposes lifecycle plus the driver
5
+ * for ORM-specific operations. Data-capable drivers (implements
6
+ * `DatabaseStore`) also expose simple table operations.
7
+ *
8
+ * Resolved from the container: `app.resolve(Database)`.
9
+ */
10
+ export class Database {
11
+ driver;
12
+ constructor(driver) {
13
+ this.driver = driver;
14
+ }
15
+ /** Establish the connection. */
16
+ async connect() {
17
+ await this.driver.connect();
18
+ }
19
+ /** Close the connection. */
20
+ async close() {
21
+ await this.driver.close();
22
+ }
23
+ /** Whether the connection is currently open. */
24
+ isConnected() {
25
+ return this.driver.isConnected();
26
+ }
27
+ // -------------------------------------------------------------------
28
+ // Store operations (available when the driver implements DatabaseStore)
29
+ // -------------------------------------------------------------------
30
+ /** All rows in a table. */
31
+ all(table) {
32
+ return this.store().all(table);
33
+ }
34
+ /** Insert a row and return it. */
35
+ insert(table, row) {
36
+ return this.store().insert(table, row);
37
+ }
38
+ /** Find rows matching a predicate. */
39
+ find(table, predicate) {
40
+ return this.store().find(table, predicate);
41
+ }
42
+ /** Remove rows matching a predicate. Returns the number removed. */
43
+ remove(table, predicate) {
44
+ return this.store().remove(table, predicate);
45
+ }
46
+ store() {
47
+ const driver = this.driver;
48
+ if (!driver.all || !driver.insert) {
49
+ throw new Error("This database driver does not support store operations. Use the driver's ORM API instead.");
50
+ }
51
+ return driver;
52
+ }
53
+ }
54
+ //# sourceMappingURL=database.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.js","sourceRoot":"","sources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F,CAAC;QACN,CAAC;QACD,OAAO,MAAwC,CAAC;IACpD,CAAC;CACJ"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A single database row.
3
+ */
4
+ export type Row = Record<string, unknown>;
5
+ /**
6
+ * Store operations supported by data-capable drivers
7
+ * (e.g. the in-memory driver). ORM-backed drivers provide their
8
+ * own query API instead.
9
+ */
10
+ export interface DatabaseStore {
11
+ /** All rows in a table (empty array if the table doesn't exist). */
12
+ all(table: string): Row[];
13
+ /** Insert a row and return it. */
14
+ insert(table: string, row: Row): Row;
15
+ /** Find rows matching a predicate. */
16
+ find(table: string, predicate: (row: Row) => boolean): Row[];
17
+ /** Remove rows matching a predicate. Returns the number removed. */
18
+ remove(table: string, predicate: (row: Row) => boolean): number;
19
+ }
20
+ /**
21
+ * Database driver contract.
22
+ *
23
+ * Implement this for Drizzle, Prisma, or any DB client.
24
+ * App code depends on `Database`, never on a driver directly.
25
+ */
26
+ export interface DatabaseDriver {
27
+ /** Establish the connection. */
28
+ connect(): Promise<void>;
29
+ /** Close the connection. */
30
+ close(): Promise<void>;
31
+ /** Whether the connection is currently open. */
32
+ isConnected(): boolean;
33
+ }
34
+ //# sourceMappingURL=driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC1B,oEAAoE;IACpE,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC;IAC1B,kCAAkC;IAClC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC;IACrC,sCAAsC;IACtC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,GAAG,GAAG,EAAE,CAAC;IAC7D,oEAAoE;IACpE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,GAAG,MAAM,CAAC;CACnE;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC3B,gCAAgC;IAChC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,4BAA4B;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,gDAAgD;IAChD,WAAW,IAAI,OAAO,CAAC;CAC1B"}
package/dist/driver.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=driver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver.js","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import type { DatabaseDriver, DatabaseStore, Row } from "./driver.js";
2
+ /**
3
+ * Predicate used to filter rows.
4
+ */
5
+ type Predicate = (row: Row) => boolean;
6
+ /**
7
+ * In-memory database driver.
8
+ *
9
+ * Stores rows in memory. Intended for development and testing.
10
+ * Implements `DatabaseStore` for simple table operations.
11
+ */
12
+ export declare class InMemoryDatabaseDriver implements DatabaseDriver, DatabaseStore {
13
+ private tables;
14
+ private connected;
15
+ connect(): Promise<void>;
16
+ close(): Promise<void>;
17
+ isConnected(): boolean;
18
+ /** All rows in a table (empty array if the table doesn't exist). */
19
+ all(table: string): Row[];
20
+ /** Insert a row and return it. */
21
+ insert(table: string, row: Row): Row;
22
+ /** Find rows matching a predicate. */
23
+ find(table: string, predicate: Predicate): Row[];
24
+ /** Remove rows matching a predicate. Returns the number removed. */
25
+ remove(table: string, predicate: Predicate): number;
26
+ /** Remove all rows from a table. */
27
+ clear(table: string): void;
28
+ private getTable;
29
+ }
30
+ export {};
31
+ //# sourceMappingURL=in-memory-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-driver.d.ts","sourceRoot":"","sources":["../src/in-memory-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEtE;;GAEG;AACH,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC;AAEvC;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,cAAc,EAAE,aAAa;IACxE,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,SAAS,CAAS;IAEpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,WAAW,IAAI,OAAO;IAQtB,oEAAoE;IACpE,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE;IAIzB,kCAAkC;IAClC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG;IAMpC,sCAAsC;IACtC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,EAAE;IAIhD,oEAAoE;IACpE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM;IAQnD,oCAAoC;IACpC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ1B,OAAO,CAAC,QAAQ;CAQnB"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * In-memory database driver.
3
+ *
4
+ * Stores rows in memory. Intended for development and testing.
5
+ * Implements `DatabaseStore` for simple table operations.
6
+ */
7
+ export class InMemoryDatabaseDriver {
8
+ tables = new Map();
9
+ connected = false;
10
+ async connect() {
11
+ this.connected = true;
12
+ }
13
+ async close() {
14
+ this.connected = false;
15
+ }
16
+ isConnected() {
17
+ return this.connected;
18
+ }
19
+ // -------------------------------------------------------------------
20
+ // Store operations
21
+ // -------------------------------------------------------------------
22
+ /** All rows in a table (empty array if the table doesn't exist). */
23
+ all(table) {
24
+ return this.getTable(table);
25
+ }
26
+ /** Insert a row and return it. */
27
+ insert(table, row) {
28
+ const rows = this.getTable(table);
29
+ rows.push(row);
30
+ return row;
31
+ }
32
+ /** Find rows matching a predicate. */
33
+ find(table, predicate) {
34
+ return this.getTable(table).filter(predicate);
35
+ }
36
+ /** Remove rows matching a predicate. Returns the number removed. */
37
+ remove(table, predicate) {
38
+ const rows = this.getTable(table);
39
+ const before = rows.length;
40
+ const kept = rows.filter((r) => !predicate(r));
41
+ this.tables.set(table, kept);
42
+ return before - kept.length;
43
+ }
44
+ /** Remove all rows from a table. */
45
+ clear(table) {
46
+ this.tables.set(table, []);
47
+ }
48
+ // -------------------------------------------------------------------
49
+ // Internal
50
+ // -------------------------------------------------------------------
51
+ getTable(table) {
52
+ const existing = this.tables.get(table);
53
+ if (existing)
54
+ return existing;
55
+ const fresh = [];
56
+ this.tables.set(table, fresh);
57
+ return fresh;
58
+ }
59
+ }
60
+ //# sourceMappingURL=in-memory-driver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-driver.js","sourceRoot":"","sources":["../src/in-memory-driver.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IACvB,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;IAClC,SAAS,GAAG,KAAK,CAAC;IAE1B,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,KAAK;QACP,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,WAAW;QACP,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,sEAAsE;IACtE,mBAAmB;IACnB,sEAAsE;IAEtE,oEAAoE;IACpE,GAAG,CAAC,KAAa;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,kCAAkC;IA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+1,5 @@
1
+ export { Database } from "./database.js";
2
+ export { DatabaseProvider } from "./provider.js";
3
+ export { InMemoryDatabaseDriver } from "./in-memory-driver.js";
4
+ export type { DatabaseDriver, DatabaseStore, Row } from "./driver.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { Database } from "./database.js";
2
+ export { DatabaseProvider } from "./provider.js";
3
+ export { InMemoryDatabaseDriver } from "./in-memory-driver.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Provider, Application } from "@wild-framework/core";
2
+ /**
3
+ * Registers the database with the application.
4
+ *
5
+ * Binds a `Database` backed by the in-memory driver. Connects during
6
+ * boot and closes during shutdown. Swap drivers by implementing
7
+ * `DatabaseDriver` and binding a new `Database`.
8
+ */
9
+ export declare class DatabaseProvider implements Provider {
10
+ register(app: Application): void;
11
+ boot(app: Application): Promise<void>;
12
+ shutdown(app: Application): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKlE;;;;;;GAMG;AACH,qBAAa,gBAAiB,YAAW,QAAQ;IAC7C,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;IAM1B,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrC,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAIlD"}
@@ -0,0 +1,26 @@
1
+ import { Container } from "@wild-framework/container";
2
+ import { Database } from "./database.js";
3
+ import { InMemoryDatabaseDriver } from "./in-memory-driver.js";
4
+ /**
5
+ * Registers the database with the application.
6
+ *
7
+ * Binds a `Database` backed by the in-memory driver. Connects during
8
+ * boot and closes during shutdown. Swap drivers by implementing
9
+ * `DatabaseDriver` and binding a new `Database`.
10
+ */
11
+ export class DatabaseProvider {
12
+ register(app) {
13
+ const container = app.resolve(Container);
14
+ const database = new Database(new InMemoryDatabaseDriver());
15
+ container.singleton(Database, () => database);
16
+ }
17
+ async boot(app) {
18
+ const database = app.resolve(Database);
19
+ await database.connect();
20
+ }
21
+ async shutdown(app) {
22
+ const database = app.resolve(Database);
23
+ await database.close();
24
+ }
25
+ }
26
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IACzB,QAAQ,CAAC,GAAgB;QACrB,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC;QAC5D,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAgB;QACvB,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAW,QAAQ,CAAC,CAAC;QACjD,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAgB;QAC3B,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAW,QAAQ,CAAC,CAAC;QACjD,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACJ"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@wild-framework/database",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Sphah",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/KhandaSoftware/wild-framework.git"
24
+ },
25
+ "description": "Database connection abstraction for Wild Framework.",
26
+ "keywords": [
27
+ "wild",
28
+ "framework",
29
+ "database",
30
+ "db",
31
+ "orm"
32
+ ],
33
+ "dependencies": {
34
+ "@wild-framework/core": "0.1.0",
35
+ "@wild-framework/container": "0.1.0"
36
+ },
37
+ "scripts": {
38
+ "build": "tsc",
39
+ "clean": "rm -rf dist",
40
+ "test": "vitest run"
41
+ }
42
+ }