inibase 1.7.1 → 1.8.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/dist/index.js +5 -1
- package/dist/utils.d.ts +1 -4
- package/dist/utils.js +6 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24,7 +24,11 @@ export const ERROR_CODES = [
|
|
|
24
24
|
"INVALID_NAME",
|
|
25
25
|
];
|
|
26
26
|
// hide ExperimentalWarning glob()
|
|
27
|
-
|
|
27
|
+
// Guard against non-Node environments (e.g. accidental import in a browser bundle)
|
|
28
|
+
if (typeof process !== "undefined" &&
|
|
29
|
+
typeof process.removeAllListeners === "function") {
|
|
30
|
+
process.removeAllListeners("warning");
|
|
31
|
+
}
|
|
28
32
|
export const globalConfig = {};
|
|
29
33
|
/**
|
|
30
34
|
* @param {string} database - Database name
|
package/dist/utils.d.ts
CHANGED
|
@@ -220,10 +220,7 @@ export declare function addIdToSchema(schema: Schema, startWithID: {
|
|
|
220
220
|
}): Field[];
|
|
221
221
|
/**
|
|
222
222
|
* Translated error messages for every supported language and error code.
|
|
223
|
-
* The `{variable}` placeholder is replaced with the relevant value by
|
|
224
|
-
* {@link createError}. `NO_ENV` is resolved lazily by {@link createError}
|
|
225
|
-
* via {@link NO_ENV_MESSAGES} since it depends on the Node.js version and
|
|
226
|
-
* must stay safe to evaluate outside of Node (e.g. in a browser bundle).
|
|
223
|
+
* The `{variable}` placeholder is replaced with the relevant value by {@link createError}.
|
|
227
224
|
*/
|
|
228
225
|
export declare const ERROR_MESSAGES: Record<ErrorLang, Record<ErrorCode, string>>;
|
|
229
226
|
/**
|
package/dist/utils.js
CHANGED
|
@@ -628,29 +628,9 @@ export function addIdToSchema(schema, startWithID) {
|
|
|
628
628
|
const addIdToSchemaHelper = (schema) => schema.map(addIdToField);
|
|
629
629
|
return addIdToSchemaHelper(clonedSchema);
|
|
630
630
|
}
|
|
631
|
-
/**
|
|
632
|
-
* Whether the current Node.js runtime supports the `--env-file` CLI flag
|
|
633
|
-
* (added in Node 20.6, stabilized in later versions). Safe to call outside
|
|
634
|
-
* of Node (e.g. in a browser bundle), where it simply returns `false`.
|
|
635
|
-
*/
|
|
636
|
-
const supportsEnvFileFlag = () => {
|
|
637
|
-
if (typeof process === "undefined" || !process.versions?.node)
|
|
638
|
-
return false;
|
|
639
|
-
const [major] = process.versions.node.split(".").map(Number);
|
|
640
|
-
return major >= 20;
|
|
641
|
-
};
|
|
642
|
-
const NO_ENV_MESSAGES = {
|
|
643
|
-
en: ["please run with '--env-file=.env'", "please use dotenv"],
|
|
644
|
-
ar: ["يرجى التشغيل باستخدام '--env-file=.env'", "يرجى استخدام dotenv"],
|
|
645
|
-
fr: ["veuillez exécuter avec '--env-file=.env'", "veuillez utiliser dotenv"],
|
|
646
|
-
es: ["por favor ejecute con '--env-file=.env'", "por favor use dotenv"],
|
|
647
|
-
};
|
|
648
631
|
/**
|
|
649
632
|
* Translated error messages for every supported language and error code.
|
|
650
|
-
* The `{variable}` placeholder is replaced with the relevant value by
|
|
651
|
-
* {@link createError}. `NO_ENV` is resolved lazily by {@link createError}
|
|
652
|
-
* via {@link NO_ENV_MESSAGES} since it depends on the Node.js version and
|
|
653
|
-
* must stay safe to evaluate outside of Node (e.g. in a browser bundle).
|
|
633
|
+
* The `{variable}` placeholder is replaced with the relevant value by {@link createError}.
|
|
654
634
|
*/
|
|
655
635
|
export const ERROR_MESSAGES = {
|
|
656
636
|
en: {
|
|
@@ -666,7 +646,7 @@ export const ERROR_MESSAGES = {
|
|
|
666
646
|
INVALID_PARAMETERS: "The given parameters are not valid",
|
|
667
647
|
INVALID_REGEX_MATCH: "Field {variable} does not match the expected pattern",
|
|
668
648
|
INVALID_NAME: "Name {variable} is not valid",
|
|
669
|
-
NO_ENV: "",
|
|
649
|
+
NO_ENV: "No environment file found",
|
|
670
650
|
},
|
|
671
651
|
ar: {
|
|
672
652
|
TABLE_EMPTY: "الجدول {variable} فارغ",
|
|
@@ -681,7 +661,7 @@ export const ERROR_MESSAGES = {
|
|
|
681
661
|
INVALID_PARAMETERS: "المعلمات المقدمة غير صالحة",
|
|
682
662
|
INVALID_REGEX_MATCH: "الحقل {variable} لا يتطابق مع النمط المتوقع",
|
|
683
663
|
INVALID_NAME: "الاسم {variable} غير صالح",
|
|
684
|
-
NO_ENV: "",
|
|
664
|
+
NO_ENV: "لم يتم العثور على ملف البيئة",
|
|
685
665
|
},
|
|
686
666
|
fr: {
|
|
687
667
|
TABLE_EMPTY: "La table {variable} est vide",
|
|
@@ -696,7 +676,7 @@ export const ERROR_MESSAGES = {
|
|
|
696
676
|
INVALID_PARAMETERS: "Les paramètres donnés ne sont pas valides",
|
|
697
677
|
INVALID_REGEX_MATCH: "Le champ {variable} ne correspond pas au modèle attendu",
|
|
698
678
|
INVALID_NAME: "Le nom {variable} n'est pas valide",
|
|
699
|
-
NO_ENV: "",
|
|
679
|
+
NO_ENV: "Aucun fichier d'environnement trouvé",
|
|
700
680
|
},
|
|
701
681
|
es: {
|
|
702
682
|
TABLE_EMPTY: "La tabla {variable} está vacía",
|
|
@@ -711,7 +691,7 @@ export const ERROR_MESSAGES = {
|
|
|
711
691
|
INVALID_PARAMETERS: "Los parámetros proporcionados no son válidos",
|
|
712
692
|
INVALID_REGEX_MATCH: "El campo {variable} no coincide con el patrón esperado",
|
|
713
693
|
INVALID_NAME: "El nombre {variable} no es válido",
|
|
714
|
-
NO_ENV: "",
|
|
694
|
+
NO_ENV: "No se encontró el archivo de entorno",
|
|
715
695
|
},
|
|
716
696
|
};
|
|
717
697
|
/**
|
|
@@ -723,9 +703,7 @@ export const ERROR_MESSAGES = {
|
|
|
723
703
|
* @returns An `Error` whose `name` is the error code and `message` is translated.
|
|
724
704
|
*/
|
|
725
705
|
export const createError = (language, name, variable) => {
|
|
726
|
-
const errorMessage = name
|
|
727
|
-
? NO_ENV_MESSAGES[language]?.[supportsEnvFileFlag() ? 0 : 1]
|
|
728
|
-
: ERROR_MESSAGES[language]?.[name];
|
|
706
|
+
const errorMessage = ERROR_MESSAGES[language]?.[name];
|
|
729
707
|
if (!errorMessage)
|
|
730
708
|
return new Error("ERR");
|
|
731
709
|
const error = new Error(variable
|