@xube/kit-aws-data-schema 0.0.74 → 0.0.76

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.
@@ -20,7 +20,6 @@ export declare const GetDataByDateRangeRequestSchema: z.ZodObject<{
20
20
  start: string;
21
21
  end: string;
22
22
  }>;
23
- email: z.ZodString;
24
23
  }, "strip", z.ZodTypeAny, {
25
24
  devices: {
26
25
  id: string;
@@ -30,7 +29,6 @@ export declare const GetDataByDateRangeRequestSchema: z.ZodObject<{
30
29
  start: string;
31
30
  end: string;
32
31
  };
33
- email: string;
34
32
  }, {
35
33
  devices: {
36
34
  id: string;
@@ -40,7 +38,6 @@ export declare const GetDataByDateRangeRequestSchema: z.ZodObject<{
40
38
  start: string;
41
39
  end: string;
42
40
  };
43
- email: string;
44
41
  }>;
45
42
  export type GetDataByDateRangeRequest = z.infer<typeof GetDataByDateRangeRequestSchema>;
46
43
  export declare const isGetDataByDateRangeRequest: (object: unknown) => object is {
@@ -52,7 +49,6 @@ export declare const isGetDataByDateRangeRequest: (object: unknown) => object is
52
49
  start: string;
53
50
  end: string;
54
51
  };
55
- email: string;
56
52
  };
57
53
  export declare const ComponentDataEntryResponseSchema: z.ZodObject<{
58
54
  seconds: z.ZodNumber;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GetDataByDateRangeResponseSchema = exports.DeviceDataEntryResponseSchema = exports.ComponentDataEntryResponseSchema = exports.isGetDataByDateRangeRequest = exports.GetDataByDateRangeRequestSchema = void 0;
4
+ const kit_log_1 = require("@xube/kit-log");
4
5
  const zod_1 = require("zod");
6
+ const zod_validation_error_1 = require("zod-validation-error");
5
7
  exports.GetDataByDateRangeRequestSchema = zod_1.z.object({
6
8
  devices: zod_1.z.array(zod_1.z.object({
7
9
  id: zod_1.z.string(),
@@ -11,11 +13,20 @@ exports.GetDataByDateRangeRequestSchema = zod_1.z.object({
11
13
  start: zod_1.z.string().datetime(),
12
14
  end: zod_1.z.string().datetime(),
13
15
  }),
14
- email: zod_1.z.string().email(),
16
+ // email: z.string().email(),
15
17
  });
16
18
  const isGetDataByDateRangeRequest = (object) => {
17
- return exports.GetDataByDateRangeRequestSchema.passthrough().safeParse(object)
18
- .success;
19
+ try {
20
+ exports.GetDataByDateRangeRequestSchema.parse(object);
21
+ return true;
22
+ }
23
+ catch (e) {
24
+ kit_log_1.XubeLog.getInstance().warn(`Failed to parse request: ${JSON.stringify(object)}`);
25
+ if (e instanceof zod_1.z.ZodError) {
26
+ (0, zod_validation_error_1.fromZodError)(e);
27
+ }
28
+ return false;
29
+ }
19
30
  };
20
31
  exports.isGetDataByDateRangeRequest = isGetDataByDateRangeRequest;
21
32
  exports.ComponentDataEntryResponseSchema = zod_1.z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xube/kit-aws-data-schema",
3
- "version": "0.0.74",
3
+ "version": "0.0.76",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -19,16 +19,17 @@
19
19
  "homepage": "https://github.com/XubeLtd/dev-kit#readme",
20
20
  "devDependencies": {
21
21
  "@types/node": "^20.4.7",
22
- "@xube/kit-build": "^0.0.74",
22
+ "@xube/kit-build": "^0.0.76",
23
23
  "ts-node": "^10.9.1",
24
24
  "typescript": "^5.1.6"
25
25
  },
26
26
  "dependencies": {
27
- "@xube/kit-aws-schema": "^0.0.74",
28
- "@xube/kit-constants": "^0.0.74",
29
- "@xube/kit-generator": "^0.0.74",
30
- "@xube/kit-log": "^0.0.74",
31
- "@xube/kit-schema": "^0.0.74",
32
- "zod": "^3.22.4"
27
+ "@xube/kit-aws-schema": "^0.0.76",
28
+ "@xube/kit-constants": "^0.0.76",
29
+ "@xube/kit-generator": "^0.0.76",
30
+ "@xube/kit-log": "^0.0.76",
31
+ "@xube/kit-schema": "^0.0.76",
32
+ "zod": "^3.22.4",
33
+ "zod-validation-error": "^2.0.0"
33
34
  }
34
35
  }
@@ -1,4 +1,6 @@
1
+ import { XubeLog } from "@xube/kit-log";
1
2
  import { z } from "zod";
3
+ import { fromZodError } from "zod-validation-error";
2
4
 
3
5
  export const GetDataByDateRangeRequestSchema = z.object({
4
6
  devices: z.array(
@@ -11,7 +13,7 @@ export const GetDataByDateRangeRequestSchema = z.object({
11
13
  start: z.string().datetime(),
12
14
  end: z.string().datetime(),
13
15
  }),
14
- email: z.string().email(),
16
+ // email: z.string().email(),
15
17
  });
16
18
  export type GetDataByDateRangeRequest = z.infer<
17
19
  typeof GetDataByDateRangeRequestSchema
@@ -19,8 +21,19 @@ export type GetDataByDateRangeRequest = z.infer<
19
21
  export const isGetDataByDateRangeRequest = (
20
22
  object: unknown
21
23
  ): object is GetDataByDateRangeRequest => {
22
- return GetDataByDateRangeRequestSchema.passthrough().safeParse(object)
23
- .success;
24
+ try {
25
+ GetDataByDateRangeRequestSchema.parse(object);
26
+ return true;
27
+ } catch (e) {
28
+ XubeLog.getInstance().warn(
29
+ `Failed to parse request: ${JSON.stringify(object)}`
30
+ );
31
+
32
+ if (e instanceof z.ZodError) {
33
+ fromZodError(e);
34
+ }
35
+ return false;
36
+ }
24
37
  };
25
38
 
26
39
  export const ComponentDataEntryResponseSchema = z.object({