@dynamic-entity/server 2.0.2 → 2.1.1
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/express.js +5 -2
- package/express.js.map +1 -1
- package/express.mjs +5 -2
- package/express.mjs.map +1 -1
- package/index.js.map +1 -1
- package/index.mjs.map +1 -1
- package/package.json +2 -2
package/express.mjs
CHANGED
|
@@ -923,6 +923,9 @@ function checkLookups(entity, config, lookups) {
|
|
|
923
923
|
Pass them as \`lookups\` to createImportRouter. Without them those columns would store the raw cell text, which renders correctly and matches nothing.`
|
|
924
924
|
);
|
|
925
925
|
}
|
|
926
|
+
function ownValue(map, key) {
|
|
927
|
+
return Object.hasOwn(map, key) ? map[key] : void 0;
|
|
928
|
+
}
|
|
926
929
|
function readFormat(value) {
|
|
927
930
|
if (value === void 0 || value === "csv") return "csv";
|
|
928
931
|
if (value === "xlsx") return "xlsx";
|
|
@@ -973,7 +976,7 @@ function createImportRouter(options) {
|
|
|
973
976
|
const languageOf = (request) => typeof options.lang === "function" ? options.lang(request) : options.lang ?? "en";
|
|
974
977
|
const configFor = async (request) => {
|
|
975
978
|
const entity = String(request.params["entity"] ?? "");
|
|
976
|
-
const config = typeof options.configs === "function" ? await options.configs(entity, request) : options.configs
|
|
979
|
+
const config = typeof options.configs === "function" ? await options.configs(entity, request) : ownValue(options.configs, entity);
|
|
977
980
|
if (!config) throw new ImportError("UNKNOWN_ENTITY", "No import is configured for that entity.");
|
|
978
981
|
if (typeof options.configs === "function") checkLookups(entity, config, options.lookups);
|
|
979
982
|
return { entity, config };
|
|
@@ -1063,7 +1066,7 @@ function createImportRouter(options) {
|
|
|
1063
1066
|
filename: upload.filename,
|
|
1064
1067
|
plan,
|
|
1065
1068
|
config,
|
|
1066
|
-
rules: routerOptions.rules
|
|
1069
|
+
rules: routerOptions.rules && ownValue(routerOptions.rules, entity),
|
|
1067
1070
|
lookups: routerOptions.lookups,
|
|
1068
1071
|
lang: language(request),
|
|
1069
1072
|
limits: resolved,
|