@samet-digital/be-oracle-common 1.0.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/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Samet Global
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.
22
+
23
+ Web: https://sametglobal.com
24
+ Responsible: Mustafa Yelmer (mustafay@samet.com.tr)
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ ```
2
+ ▗▄▖ ▗▄▄▖ ▗▄▖ ▗▄▄▖▗▖ ▗▄▄▄▖ ▗▄▄▖ ▗▄▖ ▗▖ ▗▖▗▖ ▗▖ ▗▄▖ ▗▖ ▗▖
3
+ ▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌ ▐▌ ▐▌ ▐▌ ▐▌▐▛▚▞▜▌▐▛▚▞▜▌▐▌ ▐▌▐▛▚▖▐▌
4
+ ▐▌ ▐▌▐▛▀▚▖▐▛▀▜▌▐▌ ▐▌ ▐▛▀▀▘ ▐▌ ▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌▐▌ ▝▜▌
5
+ ▝▚▄▞▘▐▌ ▐▌▐▌ ▐▌▝▚▄▄▖▐▙▄▄▖▐▙▄▄▖ ▝▚▄▄▖▝▚▄▞▘▐▌ ▐▌▐▌ ▐▌▝▚▄▞▘▐▌ ▐▌
6
+ ```
7
+ - `EN`: It should be used by another oracle based component, don't use directly!
8
+ - `TR`: Bu bileşeni sadece oracle'a bağlanan başka bir bileşen kullanmalıdır, direkt kullanmayınız.
9
+
10
+ ## Usage
11
+ - `EN`: How to add into your project?
12
+ - `TR`: Projene nasıl eklersin?
13
+
14
+ ```shell
15
+ npm i @samet-digital/be-oracle-common
16
+ ```
17
+
18
+ ## Environments
19
+ > @see [Config](./src/config/oracle-common.config.ts)
20
+ >
21
+ | Name | Type | Default | Required |
22
+ |----------------------------------|---------|---------------------------------------------|----------|
23
+ | `ORA_USER` | string | _fake_user_ | false |
24
+ | `ORA_PASS` | string | _fake_pass_ | false |
25
+ | `ORA_HOST` | string | _localhost_ | false |
26
+ | `ORA_PORT` | integer | _1521_ | false |
27
+ | `ORA_SID` | boolean | _fake_sid_ | false |
28
+ | `ORA_DIR` | string | _C://projects/samet-digital/instant-client_ | false |
29
+ | `ORA_ACQUIRE_CONNECTION_TIMEOUT` | integer | _10_000_ | false |
30
+ | `ORA_USE_NULL_AS_DEFAULT` | boolean | _true_ | false |
31
+ | `ORA_POOL_MIN` | integer | _2_ | false |
32
+ | `ORA_POOL_MAX` | integer | _10_ | false |
33
+ | `ORA_POOL_IDLE_TIMEOUT_MILLIS` | integer | _60_000_ | false |
34
+
35
+ ## Contents
36
+ - [oracleCommonConfig](./src/config/oracle-common.config.ts) : Oracle connection defaults
37
+ - [oracleClient](./src/client/oracle.client.ts) : Oracle client for connection
38
+
39
+ ## Development
40
+ > You can start to develop on it
41
+ >
42
+ ### Step 1
43
+ - `EN`: Go to your project folder
44
+ - `TR`: Bilgisayarında proje klasörüne git
45
+ ```shell
46
+ # Windows
47
+ cd C:\\projects\samet-digital
48
+ ```
49
+ ```shell
50
+ # Mac
51
+ cd /Users/{user}/projects/samet-digital
52
+ ```
53
+
54
+ ### Step 2
55
+ - `EN`: Clone the project
56
+ - `TR`: Projeyi bilgisiyarına çek
57
+ ```shell
58
+ git clone https://github.com/samet-digital/oracle-common.git -b development
59
+ ```
60
+
61
+ ## Dependencies
62
+ - [base-common](https://github.com/samet-digital/base-common) - `samet-digital`
63
+ - [oracledb](https://github.com/oracle/node-oracledb) - `oracle`
64
+
65
+ ## Commands
66
+ ```shell
67
+ # Collects all dependencies
68
+ npm i
69
+
70
+ # Builds project dist (TS -> JS, src -> dist)
71
+ npm run build
72
+
73
+ # Publishes component on http://npmjs.com/
74
+ npm run publish:public
75
+
76
+ # Clears `dist` and `coverage` folders
77
+ npm run clear
78
+
79
+ # Clear `node_modules` folder
80
+ npm run clear:nm
81
+
82
+ # Validates lint for only errors @see (./eslint.config.mjs) for rules
83
+ npm run lint
84
+
85
+ # Validates lint with warnings
86
+ npm run lint:verbose
87
+
88
+ # Runs test cases
89
+ npm run test
90
+
91
+ # Exports coverage report, @see (./coverage/lcov-report/index.html)
92
+ npm run coverage
93
+
94
+ # Finds outdated/legacy dependencies
95
+ npm outdated
96
+ ```
97
+
98
+ ## Standards
99
+ ```diff
100
+ + language: TS
101
+ + lint: eslint
102
+ + inspections: intelli-j code inspections
103
+ + ddd: domain driven development
104
+ + edd: exception driven development
105
+ ! tdd: test driven development
106
+ + ldd: log driven development
107
+ + ddd: document driven development
108
+ ```
109
+
110
+ ## History
111
+ | Date | Developer | Info | Ticket |
112
+ |------------|----------------|--------------|----------------|
113
+ | 2025-08-12 | Mustafa Yelmer | _Created_ | ~~[none](./)~~ |
114
+ | 2025-08-14 | Mustafa Yelmer | _Documented_ | ~~[none](./)~~ |
File without changes
@@ -0,0 +1,2 @@
1
+ export * from './oracle.client';
2
+ export * from './index.types';
@@ -0,0 +1,18 @@
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("./oracle.client"), exports);
18
+ __exportStar(require("./index.types"), exports);
@@ -0,0 +1,19 @@
1
+ import oracledb from "oracledb";
2
+ /**
3
+ * Handles oracle connection
4
+ * */
5
+ export interface OracleClientLike {
6
+ /**
7
+ * Native oracle instance
8
+ * */
9
+ readonly native: OracleDb;
10
+ /**
11
+ * Initializes oracle instant client
12
+ * */
13
+ initialize(libDir: string): void;
14
+ /**
15
+ * Is oracle instant client already initialized?
16
+ * */
17
+ get isInitialized(): boolean;
18
+ }
19
+ export type OracleDb = typeof oracledb;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { OracleClientLike } from "./index.types";
2
+ export declare const oracleClient: OracleClientLike;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.oracleClient = void 0;
7
+ const oracledb_1 = __importDefault(require("oracledb"));
8
+ /** {@inheritDoc} */
9
+ class OracleClient {
10
+ constructor() {
11
+ /** {@inheritDoc} */
12
+ this.native = oracledb_1.default;
13
+ }
14
+ /** {@inheritDoc} */
15
+ get isInitialized() {
16
+ return this._initialized;
17
+ }
18
+ /** {@inheritDoc} */
19
+ initialize(libDir) {
20
+ if (!this._initialized) {
21
+ this.native.initOracleClient({ libDir });
22
+ }
23
+ this._initialized = true;
24
+ }
25
+ }
26
+ exports.oracleClient = new OracleClient();
@@ -0,0 +1 @@
1
+ export * from './oracle-common.config';
@@ -0,0 +1,17 @@
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("./oracle-common.config"), exports);
@@ -0,0 +1,37 @@
1
+ import { EnvBase } from "@leyyo/env";
2
+ export type OracleCommonConfKeys = keyof OracleCommonConf;
3
+ export interface OracleCommonConf extends EnvBase {
4
+ /**
5
+ * Oracle local client folder
6
+ * */
7
+ readonly ORA_DIR: string;
8
+ /**
9
+ * DB port number
10
+ * */
11
+ readonly ORA_PORT: number;
12
+ /**
13
+ * Timeout for acquiring a new connection from pool
14
+ * */
15
+ readonly ORA_ACQUIRE_CONNECTION_TIMEOUT: number;
16
+ /**
17
+ * Binds values as null in spite of undefined
18
+ * */
19
+ readonly ORA_USE_NULL_AS_DEFAULT: boolean;
20
+ /**
21
+ * Minimum connections in the pool
22
+ * */
23
+ readonly ORA_POOL_MIN: number;
24
+ /**
25
+ * Maximum connections in the pool
26
+ * */
27
+ readonly ORA_POOL_MAX: number;
28
+ /**
29
+ * Idle timeout to clear unused connections in the pool
30
+ * */
31
+ readonly ORA_POOL_IDLE_TIMEOUT_MILLIS: number;
32
+ }
33
+ type Rename<P, E extends string> = `${string & E}_${string & P}`;
34
+ export type OracleConf<E extends string> = {
35
+ readonly [P in keyof OracleCommonConf as Rename<P, E>]: OracleCommonConf[P];
36
+ };
37
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import type { OracleCommonConf } from "./index.types";
2
+ export declare const oracleCommonConfig: import("@leyyo/env").EnvPackageLike<OracleCommonConf>;
@@ -0,0 +1,65 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.oracleCommonConfig = void 0;
37
+ const os = __importStar(require("node:os"));
38
+ const env_1 = require("@leyyo/env");
39
+ const common_1 = require("@leyyo/common");
40
+ const getLibraryFolder = () => {
41
+ let user;
42
+ try {
43
+ user = os.userInfo().username;
44
+ }
45
+ catch (_e) {
46
+ user = 'samet';
47
+ }
48
+ switch (process.platform) {
49
+ case 'win32':
50
+ return `C://projects/samet-digital/instant-client`;
51
+ case 'darwin':
52
+ return `/Users/${user}/projects/samet-digital/instant-client`;
53
+ default:
54
+ return `/home/${user}/projects/samet-digital/instant-client`;
55
+ }
56
+ };
57
+ // noinspection JSUnusedGlobalSymbols
58
+ exports.oracleCommonConfig = env_1.envCore.pck('OracleCommon')
59
+ .field('ORA_DIR').assert(v => common_1.$assert.text(v, { field: 'ORA_DIR' })).def(getLibraryFolder()).end()
60
+ .field('ORA_PORT').assert(v => common_1.$assert.positiveIntegerOptional(v, { field: 'ORA_PORT' })).def(1521).end()
61
+ .field('ORA_ACQUIRE_CONNECTION_TIMEOUT').assert(v => common_1.$assert.positiveIntegerOptional(v, { field: 'ORA_ACQUIRE_CONNECTION_TIMEOUT' })).def(10000).end()
62
+ .field('ORA_USE_NULL_AS_DEFAULT').assert(v => common_1.$assert.booleanOptional(v, { field: 'ORA_USE_NULL_AS_DEFAULT' })).def(true).end()
63
+ .field('ORA_POOL_MIN').assert(v => common_1.$assert.positiveIntegerOptional(v, { field: 'ORA_POOL_MIN' })).def(2).end()
64
+ .field('ORA_POOL_MAX').assert(v => common_1.$assert.positiveIntegerOptional(v, { field: 'ORA_POOL_MAX' })).def(10).end()
65
+ .field('ORA_POOL_IDLE_TIMEOUT_MILLIS').assert(v => common_1.$assert.nonNegativeIntegerOptional(v, { field: 'ORA_POOL_IDLE_TIMEOUT_MILLIS' })).def(60000).end();
@@ -0,0 +1,2 @@
1
+ export * from './config';
2
+ export * from './client';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
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("./config"), exports);
18
+ __exportStar(require("./client"), exports);
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@samet-digital/be-oracle-common",
3
+ "version": "1.0.2",
4
+ "description": "Oracle common component",
5
+ "keywords": [
6
+ "samet"
7
+ ],
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/samet-digital/be-oracle-common.git"
11
+ },
12
+ "bugs": {
13
+ "email": "mustafay@samet.com.tr",
14
+ "url": "https://https://github.com/samet-digital/be-oracle-common/issues"
15
+ },
16
+ "homepage": "https://https://github.com/samet-digital/be-oracle-common#readme",
17
+ "author": {
18
+ "name": "Mustafa Yelmer",
19
+ "email": "mustafay@samet.com.tr"
20
+ },
21
+ "main": "dist/index.js",
22
+ "type": "commonjs",
23
+ "scripts": {
24
+ "clear": "rimraf dist && rimraf coverage",
25
+ "clear:nm": "rimraf node_modules && npm run clear",
26
+ "lint": "eslint src/**/*.ts --quiet",
27
+ "lint:verbose": "eslint src/**/*.ts",
28
+ "asset": "node -r ts-node/register commands/assets.ts",
29
+ "build": "npm run clear && tsc && npm run asset",
30
+ "test": "jest --config=jest.json --detectOpenHandles",
31
+ "coverage": "rimraf coverage && jest --config=jest.json --coverage --coverageDirectory=coverage",
32
+ "sample": "node -r ts-node/register src/sample.ts",
33
+ "publish:public": "npm run build && npm publish -access=public"
34
+ },
35
+ "files": [
36
+ "dist/*"
37
+ ],
38
+ "license": "ISC",
39
+ "devDependencies": {
40
+ "@babel/preset-env": "^7.28.0",
41
+ "@babel/preset-typescript": "^7.27.1",
42
+ "@eslint/js": "^9.33.0",
43
+ "@types/jest": "^30.0.0",
44
+ "@types/node": "^24.2.1",
45
+ "@types/oracledb": "^6.9.1",
46
+ "@typescript-eslint/eslint-plugin": "^8.39.1",
47
+ "@typescript-eslint/parser": "^8.39.1",
48
+ "eslint": "^9.33.0",
49
+ "eslint-config-prettier": "^10.1.8",
50
+ "eslint-config-standard": "^17.1.0",
51
+ "eslint-plugin-import": "^2.32.0",
52
+ "eslint-plugin-jsdoc": "^54.0.0",
53
+ "eslint-plugin-node": "^11.1.0",
54
+ "husky": "^9.1.7",
55
+ "jest": "^29.7.0",
56
+ "prettier": "^3.6.2",
57
+ "rimraf": "^6.0.1",
58
+ "test": "^3.3.0",
59
+ "ts-jest": "^29.4.1",
60
+ "ts-node": "^10.9.2",
61
+ "typescript": "^5.9.2",
62
+ "typescript-eslint": "^8.39.1"
63
+ },
64
+ "overrides": {
65
+ "eslint-config-standard": {
66
+ "eslint": "^9.33.0"
67
+ }
68
+ },
69
+ "dependencies": {
70
+ "@leyyo/common": "^1.0.10",
71
+ "@leyyo/env": "^1.0.2",
72
+ "@samet-digital/base-common": "^1.0.2",
73
+ "oracledb": "^6.8.0"
74
+ }
75
+ }