hotstaq 0.9.19 → 0.9.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hotstaq",
3
- "version": "0.9.19",
3
+ "version": "0.9.21",
4
4
  "description": "A friendly web framework that fits nicely into devops and CI/CD pipelines.",
5
5
  "bin": {
6
6
  "hotstaq": "./bin/hotstaq"
@@ -342,6 +342,41 @@ export interface TestCaseObject
342
342
  func: TestCaseFunction;
343
343
  }
344
344
 
345
+ /**
346
+ * Backwards-compat alias for the validator-name string. Re-introduced
347
+ * after 725eab8 removed it — `@hotstaq/userroute` and `@hotstaq/dataroute`
348
+ * still ship .d.ts files that import this name, so removing it breaks
349
+ * the TS build of every downstream package even when only the type
350
+ * surface changed and the runtime kept working.
351
+ *
352
+ * The enum values mirror the keys registered in HotStaq.valids[…]; any
353
+ * additional validator type can also be passed as a plain string.
354
+ */
355
+ export enum HotValidationType
356
+ {
357
+ UUID = "UUID",
358
+ Boolean = "boolean",
359
+ Number = "number",
360
+ Integer = "Integer",
361
+ Float = "Float",
362
+ Text = "Text",
363
+ Email = "Email",
364
+ Phone = "Phone",
365
+ URL = "URL",
366
+ IPv4 = "IPv4",
367
+ IP = "IP",
368
+ IPv6 = "IPv6",
369
+ Date = "Date",
370
+ Object = "Object",
371
+ Array = "Array",
372
+ Map = "Map",
373
+ Enum = "Enum",
374
+ JSON = "JSON",
375
+ JS = "JS",
376
+ Undefined = "undefined",
377
+ Null = "null"
378
+ }
379
+
345
380
  /**
346
381
  * Is chained together to create a validation chain.
347
382
  */
@@ -351,7 +386,7 @@ export interface HotValidation
351
386
  * The type of validation to perform.
352
387
  * @default Text
353
388
  */
354
- type?: string;
389
+ type?: string | HotValidationType;
355
390
  /**
356
391
  * The default value to set if the incoming input is null or undefined.
357
392
  */
package/src/HotStaq.ts CHANGED
@@ -238,7 +238,7 @@ export class HotStaq implements IHotStaq
238
238
  /**
239
239
  * The current version of HotStaq.
240
240
  */
241
- static version: string = "0.9.19";
241
+ static version: string = "0.9.21";
242
242
  /**
243
243
  * Indicates if this is a web build.
244
244
  */
@@ -1022,13 +1022,30 @@ export class HotStaq implements IHotStaq
1022
1022
  }
1023
1023
 
1024
1024
  /**
1025
- * Parse a boolean value.
1025
+ * Parse a boolean value. Accepts:
1026
+ * - boolean (returned as-is — the previously-missing branch was
1027
+ * dropping `true` to `false` because the function fell through
1028
+ * to the bottom `return (false)` for `typeof value === "boolean"`)
1029
+ * - number / bigint (0 → false, anything else → true)
1030
+ * - string (case-insensitive "true"/"yes"/"yep" → true,
1031
+ * "false"/"no"/"nah" / "" → false)
1032
+ * - null / undefined → false
1033
+ * - anything else → false
1026
1034
  */
1027
- static parseBoolean (value: string): boolean
1035
+ static parseBoolean (value: any): boolean
1028
1036
  {
1029
1037
  if (value == null)
1030
1038
  return (false);
1031
1039
 
1040
+ // `typeof true === "boolean"` — without this branch the function
1041
+ // fell through past the number/string arms to the trailing
1042
+ // `return (false)` on a literal boolean true. That silently
1043
+ // stripped boolean params validated through HotStaq.valids["boolean"]
1044
+ // because the validator calls parseBoolean on every value, including
1045
+ // JSON-booleans that arrive already-typed correctly.
1046
+ if (typeof (value) === "boolean")
1047
+ return (value);
1048
+
1032
1049
  if ((typeof(value) === "number") || (typeof(value) === "bigint"))
1033
1050
  {
1034
1051
  if (value === 0)
@@ -121,12 +121,22 @@ export function registerComponent (tag: string, elementOptions: ElementDefinitio
121
121
  htmlHandler = HotStaq.fixHTML (str);
122
122
 
123
123
  let childrenToReadd: Node[] = [];
124
-
124
+
125
125
  // Save the children from being replaced.
126
- for (let iIdx = (this.children.length - 1); iIdx > -1; iIdx--)
126
+ //
127
+ // Snapshot .children first (it's a live HTMLCollection that
128
+ // shrinks as we removeChild). Iterating the snapshot forward
129
+ // preserves source order in childrenToReadd, which the
130
+ // re-append loop below relies on. The previous reverse-index
131
+ // loop pushed nodes in reverse, then the forward-iterating
132
+ // re-append produced reversed children in the rendered DOM —
133
+ // e.g. <admin-form-field>s declared as [name, points, key]
134
+ // ended up rendered as [key, points, name].
135
+ const originalChildren: Node[] = Array.from (this.children);
136
+ for (let iIdx = 0; iIdx < originalChildren.length; iIdx++)
127
137
  {
128
- let child: Node = this.children[iIdx];
129
-
138
+ let child: Node = originalChildren[iIdx];
139
+
130
140
  childrenToReadd.push (this.removeChild (child));
131
141
  }
132
142
 
package/src/api.ts CHANGED
@@ -14,9 +14,9 @@ import { ValidationError, FalsyOptions, ValidationOptions } from "./HotProcessIn
14
14
  // Server stuff
15
15
  import { HotAPI, EventExecutionType, APItoLoad } from "./HotAPI";
16
16
  import { HotRoute } from "./HotRoute";
17
- import { HotRouteMethod, IHotRouteMethod, HotEventMethod, HotRouteMethodParameter,
18
- ServerAuthorizationFunction, ServerExecutionFunction, PassType,
19
- ServerRequest, IServerRequest, HotValidation } from "./HotRouteMethod";
17
+ import { HotRouteMethod, IHotRouteMethod, HotEventMethod, HotRouteMethodParameter,
18
+ ServerAuthorizationFunction, ServerExecutionFunction, PassType,
19
+ ServerRequest, IServerRequest, HotValidation, HotValidationType } from "./HotRouteMethod";
20
20
  import { HotServer, HotServerType } from "./HotServer";
21
21
  import { StaticRoute, HTTPHeader, ServableFileExtension, HotHTTPServer } from "./HotHTTPServer";
22
22
  import { HotMCPServer } from "./HotMCPServer";
@@ -95,7 +95,7 @@ export {
95
95
  HotEventMethod, HotRouteMethodParameter, PassType,
96
96
  ServerAuthorizationFunction,
97
97
  ServerExecutionFunction,
98
- IServerRequest, HotValidation,
98
+ IServerRequest, HotValidation, HotValidationType,
99
99
  ServerRequest,
100
100
  HotServer,
101
101
  HotServerType,