web_plsql 1.8.11 → 1.8.16

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.
@@ -6,7 +6,7 @@
6
6
  <title>web_plsql Admin Console</title>
7
7
  <link rel="icon" type="image/svg+xml" href="/admin/assets/favicon-mQAM4tVu.svg" />
8
8
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
9
- <script type="module" crossorigin src="/admin/assets/main-CpZh2T4P.js"></script>
9
+ <script type="module" crossorigin src="/admin/assets/main-Dl5zxsZM.js"></script>
10
10
  <link rel="stylesheet" crossorigin href="/admin/assets/main-k8GNR9Ye.css">
11
11
  </head>
12
12
  <body class="dark">
Binary file
Binary file
package/dist/index.mjs CHANGED
@@ -321,7 +321,7 @@ globalThis.__VERSION__ ??= "**development**";
321
321
  * Returns the current library version
322
322
  * @returns {string} - Version.
323
323
  */
324
- const getVersion = () => "1.8.11";
324
+ const getVersion = () => "1.8.16";
325
325
  //#endregion
326
326
  //#region src/backend/server/printBanner.ts
327
327
  const IS_TTY = process.stdout.isTTY === true;
@@ -335,7 +335,7 @@ const ICON_GEAR = "🔧";
335
335
  const ICON_HOME = "🏠";
336
336
  const W = 80;
337
337
  const LABEL_W = 35;
338
- const VALUE_W = W - LABEL_W - 5;
338
+ const VALUE_W = 40;
339
339
  const BOX = {
340
340
  h: "─",
341
341
  v: "│",
@@ -352,9 +352,9 @@ const padTo = (s, w) => {
352
352
  return delta > 0 ? s + " ".repeat(delta) : s;
353
353
  };
354
354
  const truncateTo = (s, w) => w > 0 ? sliceAnsi(s, 0, w) : "";
355
- const divider = () => IS_TTY ? chalk.dim(BOX.ml + BOX.h.repeat(W - 2) + BOX.mr) : "-".repeat(W);
356
- const borderOpen = () => IS_TTY ? chalk.dim(BOX.tl + BOX.h.repeat(W - 2) + BOX.tr) : divider();
357
- const borderClose = () => IS_TTY ? chalk.dim(BOX.bl + BOX.h.repeat(W - 2) + BOX.br) : divider();
355
+ const divider = () => IS_TTY ? chalk.dim(BOX.ml + BOX.h.repeat(78) + BOX.mr) : "-".repeat(W);
356
+ const borderOpen = () => IS_TTY ? chalk.dim(BOX.tl + BOX.h.repeat(78) + BOX.tr) : divider();
357
+ const borderClose = () => IS_TTY ? chalk.dim(BOX.bl + BOX.h.repeat(78) + BOX.br) : divider();
358
358
  /**
359
359
  * Single key/value row.
360
360
  * @param key - Label text.
@@ -381,7 +381,7 @@ const printBanner = (cfg) => {
381
381
  const lines = [];
382
382
  lines.push(borderOpen());
383
383
  const title = `NODE PL/SQL SERVER ${getVersion()}`;
384
- const pad = W - 2 - displayWidth(title);
384
+ const pad = 78 - displayWidth(title);
385
385
  lines.push(IS_TTY ? chalk.dim(BOX.v) + " ".repeat(Math.floor(pad / 2)) + chalk.bold.cyan(title) + " ".repeat(Math.ceil(pad / 2)) + chalk.dim(BOX.v) : title);
386
386
  lines.push(divider());
387
387
  lines.push(row("Port", cfg.port, ICON_GLOBE));
@@ -483,14 +483,15 @@ const startServer = async (config, ssl) => {
483
483
  devMode: internalConfig.devMode
484
484
  }, adminContext));
485
485
  for (const i of internalConfig.routePlSql) {
486
- const handler = handlerWebPlSql(await createPool({
486
+ const pool = await createPool({
487
487
  user: i.user,
488
488
  password: i.password,
489
489
  connectString: i.connectString,
490
490
  poolMin: internalConfig.oracle.poolMin,
491
491
  poolMax: internalConfig.oracle.poolMax,
492
492
  poolIncrement: internalConfig.oracle.poolIncrement
493
- }), i, adminContext);
493
+ });
494
+ const handler = handlerWebPlSql(pool, i, adminContext);
494
495
  app.use([`${i.route}/:name`, i.route], (req, res, next) => {
495
496
  const start = process.hrtime();
496
497
  res.on("finish", () => {
@@ -1792,19 +1793,20 @@ const getBinding = (argName, argValue, argType) => {
1792
1793
  * @returns The text.
1793
1794
  */
1794
1795
  const inspectBindings = (argObj, argTypes) => {
1795
- const { text } = toTable([
1796
- "id",
1797
- "value",
1798
- "value type",
1799
- "argument type"
1800
- ], Object.entries(argObj).map(([key, value]) => {
1796
+ const rows = Object.entries(argObj).map(([key, value]) => {
1801
1797
  return [
1802
1798
  key,
1803
1799
  value.toString(),
1804
1800
  typeof value,
1805
1801
  argTypes[key.toLowerCase()] ?? "unknown"
1806
1802
  ];
1807
- }));
1803
+ });
1804
+ const { text } = toTable([
1805
+ "id",
1806
+ "value",
1807
+ "value type",
1808
+ "argument type"
1809
+ ], rows);
1808
1810
  return text;
1809
1811
  };
1810
1812
  /**
@@ -1831,11 +1833,14 @@ const getProcedureNamed = async (req, procName, argObj, databaseConnection, argu
1831
1833
  val: argValue
1832
1834
  };
1833
1835
  if (argType) bind = getBinding(key, argValue, argType);
1834
- else warningMessage({
1835
- type: "warning",
1836
- message: `Error in named parameter "${key}": invalid binding type "${argType}"\n\n${inspectBindings(argObj, argTypes)}`,
1837
- req
1838
- });
1836
+ else {
1837
+ const text = inspectBindings(argObj, argTypes);
1838
+ warningMessage({
1839
+ type: "warning",
1840
+ message: `Error in named parameter "${key}": invalid binding type "${argType}"\n\n${text}`,
1841
+ req
1842
+ });
1843
+ }
1839
1844
  sqlParameter.push(`${key}=>:${parameterName}`);
1840
1845
  bindings[parameterName] = bind;
1841
1846
  }
@@ -1923,9 +1928,7 @@ const parsePage = (text) => {
1923
1928
  debug$8(`oracle header "location" with value "${page.head.statusCode}" was parsed`);
1924
1929
  break;
1925
1930
  case "x-oracle-ignore": break;
1926
- default:
1927
- page.head.otherHeaders[header.name] = header.value;
1928
- break;
1931
+ default: page.head.otherHeaders[header.name] = header.value;
1929
1932
  }
1930
1933
  });
1931
1934
  return page;
@@ -2611,7 +2614,8 @@ const getProcedure = async (req, procName, argObj, options, databaseConnection,
2611
2614
  };
2612
2615
  }
2613
2616
  const useVariableArguments = procName.startsWith("!");
2614
- const sanitizedProcName = await sanitizeProcName(useVariableArguments ? procName.slice(1) : procName, databaseConnection, options, procedureNameCache);
2617
+ const rawName = useVariableArguments ? procName.slice(1) : procName;
2618
+ const sanitizedProcName = await sanitizeProcName(rawName, databaseConnection, options, procedureNameCache);
2615
2619
  return useVariableArguments ? {
2616
2620
  ...getProcedureVariable(req, sanitizedProcName, argObj),
2617
2621
  resolvedName: sanitizedProcName
@@ -2774,10 +2778,12 @@ const invokeProcedure = async (req, res, argObj, cgiObj, filesToUpload, options,
2774
2778
  };
2775
2779
  try {
2776
2780
  debug$4(`invokeProcedure: upload "${filesToUpload.length}" files`);
2777
- if (filesToUpload.length > 0) if (typeof options.documentTable === "string" && options.documentTable.length > 0) {
2778
- const { documentTable } = options;
2779
- await Promise.all(filesToUpload.map((file) => uploadFile(file, documentTable, databaseConnection)));
2780
- } else console.warn(`Unable to upload "${filesToUpload.length}" files because the option ""doctable" has not been defined`);
2781
+ if (filesToUpload.length > 0) {
2782
+ if (typeof options.documentTable === "string" && options.documentTable.length > 0) {
2783
+ const { documentTable } = options;
2784
+ await Promise.all(filesToUpload.map((file) => uploadFile(file, documentTable, databaseConnection)));
2785
+ } else console.warn(`Unable to upload "${filesToUpload.length}" files because the option ""doctable" has not been defined`);
2786
+ }
2781
2787
  debug$4("invokeProcedure: get procedure to execute and the arguments");
2782
2788
  const rawProcName = Array.isArray(req.params.name) ? req.params.name[0] : req.params.name;
2783
2789
  if (!rawProcName) throw new RequestError("No procedure name provided");
@@ -2834,7 +2840,7 @@ const invokeProcedure = async (req, res, argObj, cgiObj, filesToUpload, options,
2834
2840
  pageComponents.body = streamInstance;
2835
2841
  if (traceData) {
2836
2842
  let htmlBuffer = typeof pageComponents.body === "string" ? pageComponents.body : lines.join("");
2837
- const MAX_HTML_SIZE = 1024 * 1024;
2843
+ const MAX_HTML_SIZE = 1048576;
2838
2844
  const originalPush = streamInstance.push.bind(streamInstance);
2839
2845
  streamInstance.push = (chunk) => {
2840
2846
  if (chunk !== null && htmlBuffer.length < MAX_HTML_SIZE) {
@@ -2933,7 +2939,8 @@ const getCookieString = (req) => {
2933
2939
  * @returns The DAD structure.
2934
2940
  */
2935
2941
  const getPath = (req) => {
2936
- const pathname = new URL$1(`${req.protocol}://${os.hostname()}${req.originalUrl}`).pathname;
2942
+ const validUrl = `${req.protocol}://${os.hostname()}${req.originalUrl}`;
2943
+ const pathname = new URL$1(validUrl).pathname;
2937
2944
  const tmp = trimPath(pathname.slice(0, Math.max(0, pathname.lastIndexOf("/") + 1)));
2938
2945
  return {
2939
2946
  script: `/${tmp}`,
@@ -3210,13 +3217,14 @@ const requestHandler = async (req, res, _next, connectionPool, options, procedur
3210
3217
  return;
3211
3218
  }
3212
3219
  }
3213
- if (typeof req.params.name !== "string" || req.params.name.length === 0) if (typeof options.defaultPage === "string" && options.defaultPage.length > 0) {
3214
- const currentUrl = new URL(req.originalUrl, "http://localhost");
3215
- const newUrl = `${currentUrl.pathname.endsWith("/") ? currentUrl.pathname : `${currentUrl.pathname}/`}${options.defaultPage.replace(/^\/+/u, "")}${currentUrl.search}`;
3216
- debug$1(`Redirect to the url "${newUrl}"`);
3217
- res.redirect(newUrl);
3218
- } else errorPage(req, res, options, new RequestError("No procedure name given and no default page has been specified"));
3219
- else await processRequest(req, res, options, connectionPool, procedureNameCache, argumentCache, authenticatedUser);
3220
+ if (typeof req.params.name !== "string" || req.params.name.length === 0) {
3221
+ if (typeof options.defaultPage === "string" && options.defaultPage.length > 0) {
3222
+ const currentUrl = new URL(req.originalUrl, "http://localhost");
3223
+ const newUrl = `${currentUrl.pathname.endsWith("/") ? currentUrl.pathname : `${currentUrl.pathname}/`}${options.defaultPage.replace(/^\/+/u, "")}${currentUrl.search}`;
3224
+ debug$1(`Redirect to the url "${newUrl}"`);
3225
+ res.redirect(newUrl);
3226
+ } else errorPage(req, res, options, new RequestError("No procedure name given and no default page has been specified"));
3227
+ } else await processRequest(req, res, options, connectionPool, procedureNameCache, argumentCache, authenticatedUser);
3220
3228
  } catch (err) {
3221
3229
  errorPage(req, res, options, err);
3222
3230
  }