@samet-it/be-db-common 1.1.1 → 1.1.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.
@@ -1,12 +1,11 @@
1
- import type { DbConnectionLike, DbExecOpt, DbQueryResultMore, DbQueryResultOne, DbConnOpt, DbMeta, DbOnAfter, DbConnProps } from "./index.types";
1
+ import { DbConnectionLike, DbExecOpt, DbQueryResultMore, DbQueryResultOne, DbConnOpt, DbMeta, DbOnAfter, DbConnProps, DbRepoLink } from "./index.types";
2
2
  import { LoggerLike } from "@samet-it/be-base-common";
3
3
  import type { DbLines } from "../line";
4
- import type { DbRepoDef } from "../repo";
5
4
  import type { Opt } from "@leyyo/common";
6
5
  /**
7
6
  * DB connection abstract class
8
7
  * */
9
- export declare abstract class DbConnection<REPO extends DbRepoDef, META extends DbMeta, OPT extends DbExecOpt> implements DbConnectionLike<REPO, META, OPT> {
8
+ export declare abstract class DbConnection<LINK extends DbRepoLink, META extends DbMeta, OPT extends DbExecOpt> implements DbConnectionLike<LINK, META, OPT> {
10
9
  /**
11
10
  * Logger
12
11
  * */
@@ -60,9 +59,9 @@ export declare abstract class DbConnection<REPO extends DbRepoDef, META extends
60
59
  /** {@inheritDoc} */
61
60
  exec<T>(fn: Promise<T>, p1?: string | Omit<OPT, 'printSql'>): Promise<T>;
62
61
  /** {@inheritDoc} */
63
- abstract more<T>(repo: REPO, sql: string | DbLines, name?: string | DbExecOpt): Promise<DbQueryResultMore<T, META>>;
62
+ abstract more<T>(link: LINK, sql: string | DbLines, name?: string | DbExecOpt): Promise<DbQueryResultMore<T, META>>;
64
63
  /** {@inheritDoc} */
65
- abstract one<T>(repo: REPO, sql: string | DbLines, name?: string | DbExecOpt): Promise<DbQueryResultOne<T, META>>;
64
+ abstract one<T>(link: LINK, sql: string | DbLines, name?: string | DbExecOpt): Promise<DbQueryResultOne<T, META>>;
66
65
  /**
67
66
  * It will be called during module based systems
68
67
  * */
@@ -1,7 +1,6 @@
1
1
  import type { DbLines } from "../line";
2
- import type { DbRepoDef } from "../repo";
3
2
  import type { DbErrorOmit } from "../error";
4
- import { Opt } from "@leyyo/common";
3
+ import type { Opt } from "@leyyo/common";
5
4
  /**
6
5
  * DB query result
7
6
  * */
@@ -129,7 +128,7 @@ export interface DbConnectionBase<OPT extends DbExecOpt = DbExecOpt> {
129
128
  /**
130
129
  * DB connection interface
131
130
  * */
132
- export interface DbConnectionLike<REPO extends DbRepoDef, META extends DbMeta, OPT extends DbExecOpt> extends DbConnectionBase {
131
+ export interface DbConnectionLike<LINK extends DbRepoLink, META extends DbMeta, OPT extends DbExecOpt> extends DbConnectionBase {
133
132
  /**
134
133
  * Props on connection
135
134
  * */
@@ -171,23 +170,23 @@ export interface DbConnectionLike<REPO extends DbRepoDef, META extends DbMeta, O
171
170
  /**
172
171
  * Execute a sql and return rows
173
172
  *
174
- * @param {DbRepoLike} repo - repository instance
173
+ * @param {DbRepoLink} link - repository link
175
174
  * @param {(string|DbLines)} sql - sql or sql lines
176
175
  * @param {(DbExecOpt|string)?} opt - option or query name
177
176
  * @return {Promise<DbQueryResultMore>} - rows
178
177
  * @async
179
178
  * */
180
- more<T>(repo: REPO, sql: string | DbLines, opt?: string | OPT): Promise<DbQueryResultMore<T, META>>;
179
+ more<T>(link: LINK, sql: string | DbLines, opt?: string | OPT): Promise<DbQueryResultMore<T, META>>;
181
180
  /**
182
181
  * Execute a sql and return a row
183
182
  *
184
- * @param {DbRepoLike} repo - repository instance
183
+ * @param {DbRepoLink} link - repository link
185
184
  * @param {(string|DbLines)} sql - sql or sql lines
186
185
  * @param {(DbExecOpt|string)?} opt - option or query name
187
186
  * @return {Promise<DbQueryResultOne>} - row
188
187
  * @async
189
188
  * */
190
- one<T>(repo: REPO, sql: string | DbLines, opt?: string | OPT): Promise<DbQueryResultOne<T, META>>;
189
+ one<T>(link: LINK, sql: string | DbLines, opt?: string | OPT): Promise<DbQueryResultOne<T, META>>;
191
190
  /**
192
191
  * It will be called during module based systems
193
192
  *
@@ -292,3 +291,7 @@ export type DbOnAfter = () => Promise<void>;
292
291
  * DB connection events
293
292
  * */
294
293
  export type DbEvent = 'connected' | 'disconnected' | 'first-connected';
294
+ /** Repository Link */
295
+ export interface DbRepoLink {
296
+ path: string;
297
+ }
@@ -1,4 +1,4 @@
1
- import type { DbCheckKeysResult, DbRepoProps, DbRepoLike, DbRepoOpt, DbRepoDef, DbCheckKeysTuple } from "./index.types";
1
+ import type { DbCheckKeysResult, DbRepoProps, DbRepoLike, DbRepoOpt, DbCheckKeysTuple } from "./index.types";
2
2
  import type { DefDims, Entity, IdDocLike, LoggerLike, Pair, Portion, UrnDocLike, UrnTuple, View } from "@samet-it/be-base-common";
3
3
  import type { DbConnectionBase, DbExecOpt } from "../connection";
4
4
  import type { KeyValue, StrKey } from "@leyyo/common";
@@ -39,8 +39,6 @@ export declare abstract class DbRepo<CONN extends DbConnectionBase, OPT extends
39
39
  /** @inheritDoc */
40
40
  get props(): Readonly<DbRepoProps<CONN, ID, ENTITY>>;
41
41
  /** @inheritDoc */
42
- get $def(): DbRepoDef;
43
- /** @inheritDoc */
44
42
  $cast<T>(): T;
45
43
  protected _keyToUrn(key: KeyValue): string;
46
44
  /** @inheritDoc */
@@ -233,10 +233,6 @@ class DbRepo {
233
233
  return this._props;
234
234
  }
235
235
  /** @inheritDoc */
236
- get $def() {
237
- return this;
238
- }
239
- /** @inheritDoc */
240
236
  $cast() {
241
237
  return this;
242
238
  }
@@ -16,10 +16,6 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
16
16
  * Props on repository
17
17
  * */
18
18
  get props(): Readonly<DbRepoProps<CONN, ID, ENTITY>>;
19
- /**
20
- * Converts current instance to flatten instance with ignoring generics
21
- * */
22
- get $def(): DbRepoDef;
23
19
  /**
24
20
  * Casts current instance to given type
25
21
  * */
@@ -486,7 +482,6 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
486
482
  * */
487
483
  listPortions(keys: Array<KeyValue>, ignoreCheck?: boolean): Promise<Array<PORTION>>;
488
484
  }
489
- export type DbRepoDef = DbRepoLike<DbConnectionBase, DbExecOpt, KeyValue, Entity, UrnDocLike, keyof Entity, DefDims, Pair, View, Portion>;
490
485
  /**
491
486
  * DB repository option
492
487
  * */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samet-it/be-db-common",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Backend DB Common",
5
5
  "repository": {
6
6
  "type": "git",