inibase 1.0.0-rc.73 → 1.0.0-rc.75
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/dist/cli.js +3 -3
- package/dist/file.js +5 -2
- package/dist/index.js +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +7 -3
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "dotenv/config";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { basename, join } from "node:path";
|
|
3
5
|
import { createInterface } from "node:readline/promises";
|
|
4
6
|
import { parseArgs } from "node:util";
|
|
5
|
-
import { basename, join } from "node:path";
|
|
6
|
-
import { readFileSync } from "node:fs";
|
|
7
7
|
import Inison from "inison";
|
|
8
|
+
import { isExists } from "./file.js";
|
|
8
9
|
import Inibase from "./index.js";
|
|
9
10
|
import { isJSON, isNumber, setField, unsetField } from "./utils.js";
|
|
10
|
-
import { isExists } from "./file.js";
|
|
11
11
|
const textGreen = (input) => `\u001b[1;32m${input}\u001b[0m`;
|
|
12
12
|
const textRed = (input) => `\u001b[1;31m${input}\u001b[0m`;
|
|
13
13
|
const textBlue = (input) => `\u001b[1;34m${input}\u001b[0m`;
|
package/dist/file.js
CHANGED
|
@@ -76,8 +76,11 @@ export const isExists = async (path) => {
|
|
|
76
76
|
const secureString = (input) => {
|
|
77
77
|
if (["true", "false"].includes(String(input)))
|
|
78
78
|
return input ? 1 : 0;
|
|
79
|
-
if (typeof input !== "string")
|
|
79
|
+
if (typeof input !== "string") {
|
|
80
|
+
if (input === null || input === undefined)
|
|
81
|
+
return "";
|
|
80
82
|
return input;
|
|
83
|
+
}
|
|
81
84
|
let decodedInput = null;
|
|
82
85
|
try {
|
|
83
86
|
decodedInput = decodeURIComponent(input);
|
|
@@ -109,7 +112,7 @@ export const encode = (input) => Array.isArray(input)
|
|
|
109
112
|
*/
|
|
110
113
|
const unSecureString = (input) => {
|
|
111
114
|
if (isNumber(input))
|
|
112
|
-
return Number(input);
|
|
115
|
+
return String(input).at(0) === "0" ? input : Number(input);
|
|
113
116
|
if (typeof input === "string")
|
|
114
117
|
return input.replace(/\\n/g, "\n") || null;
|
|
115
118
|
return null;
|
package/dist/index.js
CHANGED
|
@@ -383,7 +383,7 @@ export default class Inibase {
|
|
|
383
383
|
const RETURN = {};
|
|
384
384
|
for (const field of schema) {
|
|
385
385
|
if (!Object.hasOwn(data, field.key)) {
|
|
386
|
-
if (formatOnlyAvailiableKeys
|
|
386
|
+
if (formatOnlyAvailiableKeys)
|
|
387
387
|
continue;
|
|
388
388
|
RETURN[field.key] = this.getDefaultValue(field);
|
|
389
389
|
continue;
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -118,7 +118,7 @@ export const isHTML = (input) => /<\/?\s*[a-z-][^>]*\s*>|(\&(?:[\w\d]+|#\d+|#x[a
|
|
|
118
118
|
* Note: Validates the input against being a number, boolean, email, URL, or IP address to ensure it's a general string.
|
|
119
119
|
*/
|
|
120
120
|
export const isString = (input) => Object.prototype.toString.call(input) === "[object String]" &&
|
|
121
|
-
!isNumber(input);
|
|
121
|
+
(!isNumber(input) || String(input).at(0) === "0");
|
|
122
122
|
/**
|
|
123
123
|
* Checks if the input is a valid IP address format.
|
|
124
124
|
*
|
|
@@ -208,6 +208,8 @@ export const detectFieldType = (input, availableTypes) => {
|
|
|
208
208
|
return "date";
|
|
209
209
|
if (availableTypes.includes("number"))
|
|
210
210
|
return "number";
|
|
211
|
+
if (availableTypes.includes("string") && String(input).at(0) === "0")
|
|
212
|
+
return "string";
|
|
211
213
|
}
|
|
212
214
|
else if (typeof input === "string") {
|
|
213
215
|
if (availableTypes.includes("table") && isValidID(input))
|
|
@@ -415,10 +417,12 @@ export function FormatObjectCriteriaValue(value) {
|
|
|
415
417
|
* @param {Schema} schema
|
|
416
418
|
*/
|
|
417
419
|
export function getField(keyPath, schema) {
|
|
418
|
-
let RETURN =
|
|
420
|
+
let RETURN = schema;
|
|
419
421
|
const keyPathSplited = keyPath.split(".");
|
|
420
422
|
for (const [index, key] of keyPathSplited.entries()) {
|
|
421
|
-
|
|
423
|
+
if (!isArrayOfObjects(RETURN))
|
|
424
|
+
return null;
|
|
425
|
+
const foundItem = RETURN.find((item) => item.key === key);
|
|
422
426
|
if (!foundItem)
|
|
423
427
|
return null;
|
|
424
428
|
if (index === keyPathSplited.length - 1)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inibase",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.75",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Karim Amahtil",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"dotenv": "^16.4.5",
|
|
77
|
-
"inison": "
|
|
77
|
+
"inison": "1.0.0-rc.3"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"build": "npx tsc",
|