erpnext-queue-client 2.5.4 → 2.5.5

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.
@@ -1,4 +1,4 @@
1
1
  import { z, ZodObject, ZodRawShape } from "zod";
2
2
  export declare function validateData<T extends z.ZodTypeAny>(data: unknown, ValidationModel: T, isDebug?: boolean): z.infer<T>;
3
3
  export declare function pickFromSchema<T extends ZodRawShape, K extends keyof T>(schema: ZodObject<T>, keys: readonly K[]): ZodObject<Pick<T, K>>;
4
- export type KeysOf<T> = T extends ZodObject<any> ? keyof z.infer<T> : string;
4
+ export type KeysOf<T extends z.ZodTypeAny> = T extends z.ZodObject<any> ? keyof z.infer<T> : string;
@@ -4,12 +4,16 @@ exports.validateData = validateData;
4
4
  exports.pickFromSchema = pickFromSchema;
5
5
  const zod_1 = require("zod");
6
6
  const constants_1 = require("../constants");
7
+ const logger_1 = require("./logger");
7
8
  function validateData(data, ValidationModel, isDebug) {
8
9
  if (!ValidationModel.description)
9
10
  throw new Error("ValidationModel.description is required");
10
- // writeFileSync("test.json", JSON.stringify(data, null, 2));
11
- if (!(ValidationModel instanceof zod_1.ZodObject) &&
12
- !(ValidationModel instanceof zod_1.ZodArray)) {
11
+ // Avoid `instanceof` checks: they can fail when schemas come from a different
12
+ // zod package instance (e.g. host app vs this package dependency).
13
+ if (!ValidationModel ||
14
+ typeof ValidationModel !== "object" ||
15
+ typeof ValidationModel.safeParse !== "function") {
16
+ logger_1.lg.error("Invalid Zod Model", ValidationModel);
13
17
  throw new Error("Invalid Zod Model");
14
18
  }
15
19
  const validationResult = ValidationModel.safeParse(data);
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "winston": "^3.15.0",
31
31
  "zod": "3.25.76"
32
32
  },
33
- "version": "2.5.4",
33
+ "version": "2.5.5",
34
34
  "devDependencies": {
35
35
  "@types/crypto-js": "^4.2.2",
36
36
  "@types/lodash": "^4.17.13",