qlcodes 1.1.4 → 1.2.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/README.md +58 -54
- package/dist/index.mjs +70 -0
- package/dist/qlCodes.json +1 -0
- package/package.json +27 -15
- package/build.sh +0 -122
- package/qlCodes.json +0 -1
- package/references/IBM_states.csv +0 -710
- package/references/ORACLE_states.csv +0 -171
- package/references/PSQL_states.csv +0 -284
- package/src/compose.mjs +0 -114
- package/src/fileTransformer/sanitize.mjs +0 -10
- package/src/fileTransformer/sanitize2.mjs +0 -17
- package/src/fileTransformer/stopNamedKeys.mjs +0 -15
- package/src/generate.cjs +0 -42
- package/src/index.mjs +0 -37
- package/src/pretty.mjs +0 -18
- package/src/readFile.mjs +0 -4
- package/src/regex.mjs +0 -11
- package/src/utils/codeName.mjs +0 -55
- /package/{types → dist/types}/index.d.ts +0 -0
package/src/pretty.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { onstdin } from "onstdin";
|
|
3
|
-
import { reargv } from "reargv";
|
|
4
|
-
|
|
5
|
-
const isDebug = process.env.DEBUG === "true";
|
|
6
|
-
const argv = reargv();
|
|
7
|
-
|
|
8
|
-
if (argv.options.file || argv.files.length) {
|
|
9
|
-
const file = argv.options.file || argv.files[0];
|
|
10
|
-
|
|
11
|
-
onstdin((content) => {
|
|
12
|
-
fs.writeFile(
|
|
13
|
-
file,
|
|
14
|
-
JSON.stringify(JSON.parse(content), null, isDebug ? 2 : undefined),
|
|
15
|
-
(_) => {}
|
|
16
|
-
);
|
|
17
|
-
});
|
|
18
|
-
}
|
package/src/readFile.mjs
DELETED
package/src/regex.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const ERROR_CODE_HEADER_RGX =
|
|
2
|
-
/^(?:Table \d+\.\sClass\sCode|Class)\s+(?<class_code>[0-9A-Z]{2})[^\w]+(?<label>.+)\n?/;
|
|
3
|
-
|
|
4
|
-
// Class after generate header
|
|
5
|
-
export const CLASS_RE =
|
|
6
|
-
/^Class\s+(?<classCode>[0-9A-Z]{2})\s+—\s+(?<label>.+)$/;
|
|
7
|
-
|
|
8
|
-
export const CODE_RE =
|
|
9
|
-
/^(?<code>[0-9A-Z]{5})\*?(?<flags>[\w:]*)\s+(?<key>!?[a-z_]+)$/;
|
|
10
|
-
|
|
11
|
-
export const COMMENT_RE = /^\*/;
|
package/src/utils/codeName.mjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { reargv } from "reargv";
|
|
2
|
-
import toSnakeCase from "to-snake-case";
|
|
3
|
-
|
|
4
|
-
const argv = reargv();
|
|
5
|
-
|
|
6
|
-
export const normalizeCode = (raw, classCode) => {
|
|
7
|
-
if (raw === "0") return "00000";
|
|
8
|
-
if (raw.endsWith("xxx")) return `${classCode}000`;
|
|
9
|
-
if (!raw.length) return "";
|
|
10
|
-
return raw.padStart(5, "0");
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const getFlags = () => (argv.options.flag || "").split(",").join(":");
|
|
14
|
-
const isMakeKeys = process.env.MAKE_KEYS === "true";
|
|
15
|
-
export const newCode = (line, currentClassCode) => {
|
|
16
|
-
const flags = getFlags();
|
|
17
|
-
const [left, right] = line.split(";", 2);
|
|
18
|
-
|
|
19
|
-
const code = normalizeCode(left.trim(), currentClassCode);
|
|
20
|
-
const description = right.trim();
|
|
21
|
-
let key = toSnakeCase(description.split(".")[0]);
|
|
22
|
-
|
|
23
|
-
if (!isMakeKeys && !/^[a-z_]+/.test(description.split(".")[0])) {
|
|
24
|
-
key = "_";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return code.length
|
|
28
|
-
? [`${code}${flags ? "*" + flags : ""} !${key}`, description]
|
|
29
|
-
: [description];
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const insertHeadersAndFormat = (sanitized) => {
|
|
33
|
-
const lines = [];
|
|
34
|
-
let lastClass = "";
|
|
35
|
-
sanitized.split(/[\n]/g).forEach((line) => {
|
|
36
|
-
const match = /^(?<class_code>[0-9A-Z]{1,5});(?<label>.+)/.exec(line);
|
|
37
|
-
|
|
38
|
-
if (match) {
|
|
39
|
-
let { class_code, label } = match.groups;
|
|
40
|
-
class_code == "0" ? (class_code = "00000") : class_code;
|
|
41
|
-
if (class_code) {
|
|
42
|
-
const idClass = class_code.substring(0, 2);
|
|
43
|
-
if (lastClass != idClass) {
|
|
44
|
-
lines.push(`Class ${idClass} — ${label.split(";")[0]}`);
|
|
45
|
-
}
|
|
46
|
-
lastClass = idClass;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const [right, left] = line.split(";");
|
|
50
|
-
if (left) {
|
|
51
|
-
lines.push([right.padStart(5, "0"), left].join(";"));
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
return lines.join("\n");
|
|
55
|
-
};
|
|
File without changes
|