qlcodes 1.1.2 → 1.1.4

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/README.md CHANGED
@@ -2,24 +2,16 @@
2
2
 
3
3
  A small utility that unifies SQL codes describing states (SQLSTATE) from different DBMS into a single, normalized structure through a curated dataset constructed at build time.
4
4
 
5
- The module is built from authoritative vendor documentation (IBM, PostgreSQL, Oracle) and generates static reference data at build time. Find references bellow.
6
-
7
- ## References
8
-
9
- - IBM
10
- [Listing of SQLSTATE values](https://www.ibm.com/docs/en/i/7.6.0?topic=codes-listing-sqlstate-values#cc__classcode00)
11
- (Last Updated: 2025-09-29)
12
-
13
- - Postgres codes
14
- [Appendix A. PostgreSQL Error Codes](https://www.postgresql.org/docs/10/static/errcodes-appendix.html)
15
- (V.10)
5
+ The module is built from authoritative vendor documentation (IBM, PostgreSQL, Oracle) and generates static reference data at build time. [Find references bellow](/#user-content-references).
16
6
 
7
+ ## SQLSTATES coverage
17
8
 
18
- - Oracle
19
- [Oracle appendix](https://docs.oracle.com/cd/E15817_01/appdev.111/b31228/appd.htm)
20
- 11g Release 1 (11.1)
9
+ The project aims to cover sql states for most of RDBMS [drivers supported by **Typeorm** such as Google Spanner](https://typeorm.io/docs/drivers/google-spanner).
10
+ Find bellow the actual coverage:
21
11
 
22
- ---
12
+ 🕓 MySQL | 🕓 MariaDB | ✅ PostgreSQL | 🕓 CockroachDB (Postgres-compatible)
13
+ 🕓 Microsoft SQL Server | ✅ Oracle | 🕓 SQLite | 🕓 SAP HANA | 🕓 Google Spanner | ✅ IBM*
14
+ >( \* ) IBM defines and publishes SQLSTATE codes as part of the SQL standard, so their The codes should covere IBM products such as DB2, IBM Informix, IBM Netezza, IBM i (AS/400) .
23
15
 
24
16
  ## Installation
25
17
 
@@ -116,6 +108,7 @@ Output:
116
108
  ## API
117
109
 
118
110
  `lens(code: string): QLLens`
111
+
119
112
  |Parameters|Returns|
120
113
  |-|-|
121
114
  |**code** SQLSTATE status code | A structured status description|
@@ -151,25 +144,46 @@ $ npm install
151
144
  > unless you know what you know what you are doing.
152
145
 
153
146
  3) Rebuild the module
147
+
154
148
  ```bash
155
149
  $ npm run build
156
150
  ```
157
151
 
158
152
  ### Quality of life
153
+
159
154
  You may pass argument to the build script to enforce a few behaviours to help you seing through the process...
155
+
160
156
  |argument|effect|
161
157
  |-|-|
162
158
  |`--debug`|prevents the cleanup of middle stage file created during the data processing|
163
159
  |`--make-keys`|allows the creation of keys when a description is given...through the 'generate' step (`generate.cjs`)|
164
160
 
165
-
166
-
167
161
  Use your customized build via a local dependency or a forked package.
168
162
 
169
163
  ---
170
- ## Showcase
164
+
165
+ ## Showcase
166
+
171
167
  [in stackblitz](https://stackblitz.com/edit/stackblitz-starters-vjcs3q7x?file=index.js)
168
+
169
+ ---
170
+
171
+ ## References
172
+
173
+ - IBM
174
+ [Listing of SQLSTATE values](https://www.ibm.com/docs/en/i/7.6.0?topic=codes-listing-sqlstate-values#cc__classcode00)
175
+ (Last Updated: 2025-09-29)
176
+
177
+ - Postgres codes
178
+ [Appendix A. PostgreSQL Error Codes](https://www.postgresql.org/docs/10/static/errcodes-appendix.html)
179
+ (V.10)
180
+
181
+ - Oracle
182
+ [Oracle appendix](https://docs.oracle.com/cd/E15817_01/appdev.111/b31228/appd.htm)
183
+ 11g Release 1 (11.1)
184
+
172
185
  ---
173
186
 
174
187
  ## License
188
+
175
189
  [MIT 2025](https://github.com/ManuUseGitHub/QLCodes?tab=MIT-1-ov-file#readme)
package/build.sh CHANGED
@@ -99,7 +99,7 @@ node generate.cjs --flag "oracle"> "$DIR/output3.txt"
99
99
  echo -e "$CHECK done"
100
100
 
101
101
  echo -e "${BLUE}Composition of the JSON file at $DIR/qlCodes.json${NC}"
102
- echo {} | node compose.mjs --file "$DIR/output1.txt"|\
102
+ node compose.mjs --file "$DIR/output1.txt"|\
103
103
  node compose.mjs --file "$DIR/output2.txt" |\
104
104
  node compose.mjs --file "$DIR/output3.txt" |\
105
105
  node pretty.mjs --file "$DIR/qlCodes.json"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qlcodes",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "main": "src/index.mjs",
5
5
  "scripts": {
6
6
  "build": "chmod +x ./build.sh; ./build.sh"
@@ -23,5 +23,10 @@
23
23
  ],
24
24
  "repository": {
25
25
  "url": "git+https://github.com/ManuUseGitHub/QLCodes.git"
26
+ },
27
+ "dependencies": {
28
+ "onstdin": "^1.0.0",
29
+ "reargv": "^1.0.2",
30
+ "to-snake-case": "^1.0.0"
26
31
  }
27
32
  }
package/src/compose.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from "fs";
2
- import { onStdIn } from "./utils/io.mjs";
2
+ import { onstdin } from "onstdin";
3
3
  import { CODE_RE, CLASS_RE, COMMENT_RE } from "./regex.mjs";
4
- import { reargv } from "./utils/args.mjs";
4
+ import { reargv } from "reargv";
5
5
  const argv = reargv();
6
6
  function flushBuffer(buffer, currentClass, currentCode) {
7
7
  if (!buffer.length) return buffer;
@@ -95,10 +95,11 @@ const debugInFile = (file, data = null) => {
95
95
  if (argv.options.file || argv.files.length) {
96
96
  const file = argv.options.file || argv.files[0];
97
97
 
98
- onStdIn((content) => {
98
+ onstdin((content) => {
99
99
  const isDebug = process.env.DEBUG;
100
100
  let states;
101
101
  try {
102
+ debugInFile(file, `content!${content}!`);
102
103
  states = JSON.parse(content ? content : "{}");
103
104
  } catch {
104
105
  states = {};
@@ -1,6 +1,6 @@
1
- import { onStdIn } from "../utils/io.mjs";
1
+ import { onstdin } from "onstdin";
2
2
 
3
- onStdIn((input) => {
3
+ onstdin((input) => {
4
4
  console.log(
5
5
  input
6
6
  .replaceAll("SQLSTATE Value;Meaning", "")
@@ -1,7 +1,7 @@
1
1
  import { insertHeadersAndFormat } from "../utils/codeName.mjs";
2
- import { onStdIn } from "../utils/io.mjs";
2
+ import { onstdin } from "onstdin";
3
3
 
4
- onStdIn((input) => {
4
+ onstdin((input) => {
5
5
  console.log(
6
6
  insertHeadersAndFormat(
7
7
  input
@@ -1,6 +1,6 @@
1
- import { onStdIn } from "../utils/io.mjs";
1
+ import { onstdin } from "onstdin";
2
2
 
3
- onStdIn((input) => {
3
+ onstdin((input) => {
4
4
  console.log(
5
5
  input
6
6
  .replaceAll(/ use_of_| the_| an_| a_|for_the_|_the|of_the_/gm, "")
package/src/generate.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  const fs = require("fs");
2
2
  const { ERROR_CODE_HEADER_RGX } = require("./regex.mjs");
3
3
  const { newCode } = require("./utils/codeName.mjs");
4
- const { reargv } = require("./utils/args.mjs");
5
- const { onStdIn } = require("./utils/io.mjs");
4
+ const { onstdin } = require("onstdin");
5
+ const { reargv } = require("reargv");
6
6
 
7
7
  const argv = reargv();
8
8
 
@@ -36,7 +36,7 @@ if (argv.options.file || argv.files.length) {
36
36
  const file = argv.options.file || argv.files[0];
37
37
  console.log(processCSVLines(fs.readFileSync(file, "utf8")));
38
38
  } else {
39
- onStdIn((csv) => {
39
+ onstdin((csv) => {
40
40
  console.log(processCSVLines(csv));
41
41
  });
42
42
  }
package/src/pretty.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import fs from "fs";
2
- import { reargv } from "./utils/args.mjs";
3
- import { onStdIn } from "./utils/io.mjs";
2
+ import { onstdin } from "onstdin";
3
+ import { reargv } from "reargv";
4
4
 
5
5
  const isDebug = process.env.DEBUG === "true";
6
6
  const argv = reargv();
@@ -8,7 +8,7 @@ const argv = reargv();
8
8
  if (argv.options.file || argv.files.length) {
9
9
  const file = argv.options.file || argv.files[0];
10
10
 
11
- onStdIn((content) => {
11
+ onstdin((content) => {
12
12
  fs.writeFile(
13
13
  file,
14
14
  JSON.stringify(JSON.parse(content), null, isDebug ? 2 : undefined),
package/src/readFile.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import fs from "fs";
2
- import { reargv } from "./utils/args.mjs";
2
+ import { reargv } from "reargv";
3
3
 
4
4
  console.log(fs.readFileSync(reargv().files[0], "utf8"));
@@ -1,5 +1,5 @@
1
- import { reargv } from "./args.mjs";
2
- import { toSnakeCase } from "./str.mjs";
1
+ import { reargv } from "reargv";
2
+ import toSnakeCase from "to-snake-case";
3
3
 
4
4
  const argv = reargv();
5
5
 
@@ -1,32 +0,0 @@
1
- export const reargv = () => {
2
- const args = process.argv.slice(2);
3
- const argvs = { misc: [], options: {}, files: [] };
4
- const len = args.length;
5
- let jump = 0;
6
- for (const [i, arg] of args.entries()) {
7
- if (jump) {
8
- jump--;
9
- continue;
10
- }
11
- if (arg.startsWith("--")) {
12
- const option = arg.replace(/^-+/g, "");
13
- if (i + 1 < len) {
14
- const nextArg = args[i + 1];
15
- if (!nextArg.startsWith("--")) {
16
- argvs.options[option] = args[i + 1];
17
- jump++;
18
- } else {
19
- argvs.options[option] = true;
20
- jump++;
21
- }
22
- } else {
23
- argvs.options[option] = true;
24
- }
25
- } else if (/(\.(?:[a-zA-Z]+)+)$/.test(arg)) {
26
- argvs.files.push(arg);
27
- } else {
28
- argvs.misc.push(arg);
29
- }
30
- }
31
- return argvs;
32
- };
package/src/utils/io.mjs DELETED
@@ -1,11 +0,0 @@
1
- export const onStdIn = (cb) => {
2
- let input = "";
3
- process.stdin.setEncoding("utf8");
4
- process.stdin.on("data", (chunk) => {
5
- input += chunk;
6
- });
7
-
8
- process.stdin.on("end", () => {
9
- cb(input);
10
- });
11
- };
package/src/utils/str.mjs DELETED
@@ -1,5 +0,0 @@
1
- export const toSnakeCase = (text) =>
2
- text
3
- .toLowerCase()
4
- .replace(/[^a-z0-9]+/g, "_")
5
- .replace(/^_|_$/g, "");