@samet-it/be-db-common 1.3.1 → 1.3.3

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,2 +1,2 @@
1
- export * from './index.types';
2
- export * from './db.repo';
1
+ export * from './index.types.js';
2
+ export * from './db.repo.js';
@@ -1,18 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
18
- __exportStar(require("./db.repo"), exports);
1
+ export * from './index.types.js';
2
+ export * from './db.repo.js';
@@ -1,9 +1,9 @@
1
1
  import { DefDims, Entity, IdDocLike, Pair, Portion, UrnDef, UrnDocLike, UrnTuple, View } from "@samet-it/be-base-common";
2
- import { DbConnectionLike, UserFetcherLambda } from "../connection";
2
+ import { DbConnectionLike, UserFetcherLambda } from "../connection/index.js";
3
3
  import { QueryAny, QueryRegular } from "@leyyo/query";
4
4
  import { CacheChannelLike, CacheConnectionLike, CacheExecOpt } from "@samet-it/be-cache-common";
5
5
  import { KeyValue, OmitError, Opt, StrKey } from "@leyyo/common";
6
- import { DbLines } from "../line";
6
+ import { DbLines } from "../line/index.js";
7
7
  /**
8
8
  * DB repository interface
9
9
  *
@@ -245,6 +245,24 @@ export interface DbRepoLike<CONN extends DbConnectionLike, OPT extends DbExecOpt
245
245
  * @return {string} - urn
246
246
  * */
247
247
  toUrn(urnRec: URN): string;
248
+ /**
249
+
250
+ * Extract core urn key from document without prefix
251
+ * - It returns code part of urn `<prefix>:<code>`;
252
+ *
253
+ * @param {Partial<Entity>} doc - document
254
+ * @return {string} - key
255
+ * */
256
+ toUrnKey(doc: Partial<ENT>): string;
257
+ /**
258
+
259
+ * Extract core urn key from urn without prefix
260
+ * - It returns code part of urn `<prefix>:<code>`;
261
+ *
262
+ * @param {string} urn - urn
263
+ * @return {string} - key
264
+ * */
265
+ toUrnKey(urn: string): string;
248
266
  /**
249
267
  * Generates urn tuple
250
268
  *
@@ -662,6 +680,14 @@ export interface DbRepoLike<CONN extends DbConnectionLike, OPT extends DbExecOpt
662
680
  * @return {Promise<Array<IdDocLike>>} - dim objects
663
681
  * */
664
682
  listDims<R extends IdDocLike<ID>>(keys: Array<PORTION | KeyValue>, dim?: DIMS, ignoreCheck?: boolean): Promise<Array<R>>;
683
+ /**
684
+ * Convert document to pair
685
+ *
686
+ * @param {Entity} doc - document
687
+ * @return {Promise<Pair>} - pair object
688
+ * @async
689
+ * */
690
+ toPair(doc: ENT): Promise<PAIR>;
665
691
  /**
666
692
  * Get pair by key (primary or secondary)
667
693
  *
@@ -678,6 +704,14 @@ export interface DbRepoLike<CONN extends DbConnectionLike, OPT extends DbExecOpt
678
704
  * @return {Promise<Array<Pair>>} - pair objects
679
705
  * */
680
706
  listPairs(keys: Array<PORTION | KeyValue>, ignoreCheck?: boolean): Promise<Array<PAIR>>;
707
+ /**
708
+ * Convert document to view
709
+ *
710
+ * @param {Entity} doc - document
711
+ * @return {Promise<View>} - view object
712
+ * @async
713
+ * */
714
+ toView(doc: ENT): Promise<VIEW>;
681
715
  /**
682
716
  * Get view by key (primary or secondary)
683
717
  *
@@ -694,6 +728,14 @@ export interface DbRepoLike<CONN extends DbConnectionLike, OPT extends DbExecOpt
694
728
  * @return {Promise<Array<View>>} - view objects
695
729
  * */
696
730
  listViews(keys: Array<KeyValue>, ignoreCheck?: boolean): Promise<Array<VIEW>>;
731
+ /**
732
+ * Convert document to portion
733
+ *
734
+ * @param {Entity} doc - document
735
+ * @return {Promise<Portion>} - portion object
736
+ * @async
737
+ * */
738
+ toPortion(doc: ENT): Promise<PORTION>;
697
739
  /**
698
740
  * Get portion by key (primary or secondary)
699
741
  *
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samet-it/be-db-common",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Backend DB Common",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,13 +16,13 @@
16
16
  "email": "mustafay@samet.com.tr"
17
17
  },
18
18
  "main": "dist/index.js",
19
- "type": "commonjs",
19
+ "type": "module",
20
20
  "scripts": {
21
21
  "clear": "rimraf dist && rimraf coverage",
22
22
  "clear:nm": "rimraf node_modules && npm run clear",
23
23
  "lint": "eslint src/**/*.ts --quiet",
24
24
  "lint:verbose": "eslint src/**/*.ts",
25
- "asset": "node -r ts-node/register commands/assets.ts",
25
+ "asset": "node -r ts-node/register commands/assets.js",
26
26
  "build": "npm run clear && tsc && npm run asset",
27
27
  "test": "jest --config=jest.json --detectOpenHandles",
28
28
  "coverage": "rimraf coverage && jest --config=jest.json --coverage --coverageDirectory=coverage",