@xube/kit-aws-hooks 0.2.7 → 0.2.12

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,85 +1,33 @@
1
1
  import { z } from "zod";
2
2
  export declare const CreateWebhookForAccountRequestSchema: z.ZodObject<{
3
3
  account: z.ZodString;
4
- ids: z.ZodArray<z.ZodString, "many">;
4
+ ids: z.ZodArray<z.ZodString>;
5
5
  endpoints: z.ZodArray<z.ZodObject<{
6
6
  url: z.ZodString;
7
7
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
8
- }, "strip", z.ZodTypeAny, {
9
- url: string;
10
- headers?: Record<string, string> | undefined;
11
- }, {
12
- url: string;
13
- headers?: Record<string, string> | undefined;
14
- }>, "many">;
8
+ }, z.core.$strip>>;
15
9
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
16
- type: z.ZodOptional<z.ZodNativeEnum<{
10
+ type: z.ZodOptional<z.ZodEnum<{
17
11
  readonly data: "data";
18
12
  readonly event: "event";
19
13
  }>>;
20
- }, "strip", z.ZodTypeAny, {
21
- account: string;
22
- ids: string[];
23
- endpoints: {
24
- url: string;
25
- headers?: Record<string, string> | undefined;
26
- }[];
27
- type?: "data" | "event" | undefined;
28
- headers?: Record<string, string> | undefined;
29
- }, {
30
- account: string;
31
- ids: string[];
32
- endpoints: {
33
- url: string;
34
- headers?: Record<string, string> | undefined;
35
- }[];
36
- type?: "data" | "event" | undefined;
37
- headers?: Record<string, string> | undefined;
38
- }>;
14
+ }, z.core.$strip>;
39
15
  export type CreateWebhookForAccountRequest = z.infer<typeof CreateWebhookForAccountRequestSchema>;
40
16
  export declare const isCreateWebhookForAccountRequest: (obj: unknown) => obj is CreateWebhookForAccountRequest;
41
17
  export declare const CreateWebhookForAccountResponseSchema: z.ZodObject<{
42
18
  success: z.ZodBoolean;
43
- }, "strip", z.ZodTypeAny, {
44
- success: boolean;
45
- }, {
46
- success: boolean;
47
- }>;
19
+ }, z.core.$strip>;
48
20
  export type CreateWebhookForAccountResponse = z.infer<typeof CreateWebhookForAccountResponseSchema>;
49
21
  export declare const CreateWebhookRequestSchema: z.ZodObject<{
50
22
  ids: z.ZodString;
51
23
  endpoints: z.ZodArray<z.ZodObject<{
52
24
  url: z.ZodString;
53
25
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
54
- }, "strip", z.ZodTypeAny, {
55
- url: string;
56
- headers?: Record<string, string> | undefined;
57
- }, {
58
- url: string;
59
- headers?: Record<string, string> | undefined;
60
- }>, "many">;
61
- headers: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodString>, "many">;
62
- }, "strip", z.ZodTypeAny, {
63
- headers: Record<string, string>[];
64
- ids: string;
65
- endpoints: {
66
- url: string;
67
- headers?: Record<string, string> | undefined;
68
- }[];
69
- }, {
70
- headers: Record<string, string>[];
71
- ids: string;
72
- endpoints: {
73
- url: string;
74
- headers?: Record<string, string> | undefined;
75
- }[];
76
- }>;
26
+ }, z.core.$strip>>;
27
+ headers: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodString>>;
28
+ }, z.core.$strip>;
77
29
  export declare const CreateWebhookResponseSchema: z.ZodObject<{
78
30
  success: z.ZodBoolean;
79
- }, "strip", z.ZodTypeAny, {
80
- success: boolean;
81
- }, {
82
- success: boolean;
83
- }>;
31
+ }, z.core.$strip>;
84
32
  export type CreateWebhookResponse = z.infer<typeof CreateWebhookResponseSchema>;
85
33
  //# sourceMappingURL=create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/schemas/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM/C,CAAC;AACH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAClD,OAAO,oCAAoC,CAC5C,CAAC;AACF,eAAO,MAAM,gCAAgC,QACtC,OAAO,KACX,GAAG,IAAI,8BAGT,CAAC;AAEF,eAAO,MAAM,qCAAqC;;;;;;EAEhD,CAAC;AACH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CACnD,OAAO,qCAAqC,CAC7C,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIrC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;EACD,CAAC;AACxC,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/schemas/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,oCAAoC;;;;;;;;;;;;iBAM/C,CAAC;AACH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAClD,OAAO,oCAAoC,CAC5C,CAAC;AACF,eAAO,MAAM,gCAAgC,QACtC,OAAO,KACX,GAAG,IAAI,8BAGT,CAAC;AAEF,eAAO,MAAM,qCAAqC;;iBAEhD,CAAC;AACH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CACnD,OAAO,qCAAqC,CAC7C,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;iBAIrC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;iBACD,CAAC;AACxC,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -4,12 +4,6 @@ export type HookEndpointHeader = z.infer<typeof HookEndpointHeaderSchema>;
4
4
  export declare const HookEndpointSchema: z.ZodObject<{
5
5
  url: z.ZodString;
6
6
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
7
- }, "strip", z.ZodTypeAny, {
8
- url: string;
9
- headers?: Record<string, string> | undefined;
10
- }, {
11
- url: string;
12
- headers?: Record<string, string> | undefined;
13
- }>;
7
+ }, z.core.$strip>;
14
8
  export type HookEndpoint = z.infer<typeof HookEndpointSchema>;
15
9
  //# sourceMappingURL=endpoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/schemas/endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,wBAAwB,uCAAuB,CAAC;AAC7D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,kBAAkB;;;;;;;;;EAG7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/schemas/endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,wBAAwB,uCAAmC,CAAC;AACzE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,kBAAkB;;;iBAG7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HookEndpointSchema = exports.HookEndpointHeaderSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- exports.HookEndpointHeaderSchema = zod_1.z.record(zod_1.z.string());
5
+ exports.HookEndpointHeaderSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.string());
6
6
  exports.HookEndpointSchema = zod_1.z.object({
7
7
  url: zod_1.z.string().url(),
8
8
  headers: exports.HookEndpointHeaderSchema.optional(),
@@ -3,78 +3,25 @@ export declare const WebhookEndpointSchema: z.ZodObject<{
3
3
  endpoints: z.ZodArray<z.ZodObject<{
4
4
  url: z.ZodString;
5
5
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
6
- }, "strip", z.ZodTypeAny, {
7
- url: string;
8
- headers?: Record<string, string> | undefined;
9
- }, {
10
- url: string;
11
- headers?: Record<string, string> | undefined;
12
- }>, "many">;
6
+ }, z.core.$strip>>;
13
7
  id: z.ZodString;
14
8
  account: z.ZodString;
15
- }, "strip", z.ZodTypeAny, {
16
- account: string;
17
- endpoints: {
18
- url: string;
19
- headers?: Record<string, string> | undefined;
20
- }[];
21
- id: string;
22
- }, {
23
- account: string;
24
- endpoints: {
25
- url: string;
26
- headers?: Record<string, string> | undefined;
27
- }[];
28
- id: string;
29
- }>;
9
+ }, z.core.$strip>;
30
10
  export type WebhookEndpoint = z.infer<typeof WebhookEndpointSchema>;
31
11
  export declare const isWebhookEndpoint: (obj: unknown) => obj is WebhookEndpoint;
32
- export declare const WebhookEndpointItemSchema: z.ZodObject<z.objectUtil.extendShape<{
12
+ export declare const WebhookEndpointItemSchema: z.ZodObject<{
33
13
  endpoints: z.ZodArray<z.ZodObject<{
34
14
  url: z.ZodString;
35
15
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
36
- }, "strip", z.ZodTypeAny, {
37
- url: string;
38
- headers?: Record<string, string> | undefined;
39
- }, {
40
- url: string;
41
- headers?: Record<string, string> | undefined;
42
- }>, "many">;
43
- id: z.ZodString;
16
+ }, z.core.$strip>>;
44
17
  account: z.ZodString;
45
- }, z.objectUtil.extendShape<{
46
18
  s: z.ZodNumber;
47
19
  us: z.ZodOptional<z.ZodNumber>;
48
20
  type: z.ZodString;
49
21
  id: z.ZodString;
50
- }, {
51
22
  PK: z.ZodString;
52
23
  SK: z.ZodString;
53
- }>>, "strip", z.ZodTypeAny, {
54
- type: string;
55
- account: string;
56
- endpoints: {
57
- url: string;
58
- headers?: Record<string, string> | undefined;
59
- }[];
60
- id: string;
61
- s: number;
62
- PK: string;
63
- SK: string;
64
- us?: number | undefined;
65
- }, {
66
- type: string;
67
- account: string;
68
- endpoints: {
69
- url: string;
70
- headers?: Record<string, string> | undefined;
71
- }[];
72
- id: string;
73
- s: number;
74
- PK: string;
75
- SK: string;
76
- us?: number | undefined;
77
- }>;
24
+ }, z.core.$strip>;
78
25
  export type WebhookEndpointItem = z.infer<typeof WebhookEndpointItemSchema>;
79
26
  export declare const isWebhookEndpointItem: (obj: unknown) => obj is WebhookEndpointItem;
80
27
  //# sourceMappingURL=webhook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/schemas/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,eAAO,MAAM,iBAAiB,QAAS,OAAO,KAAG,GAAG,IAAI,eACV,CAAC;AAE/C,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;OAXJ,EAAG,SAAS;QAE9C,EAAC,WAAW,CAAC,EAAE,SAAS;UAAa,EAAE,SACvC;QAAS,EAAI,SAAQ;;QAAc,EAAG,SACjC;QAAS,EACZ,SAAM;;;;;;;;;;;;;;;;;;;;;;;;;EAOsC,CAAC;AAC/C,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,eAAO,MAAM,qBAAqB,QAC3B,OAAO,KACX,GAAG,IAAI,mBACwC,CAAC"}
1
+ {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/schemas/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,qBAAqB;;;;;;;iBAIhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,eAAO,MAAM,iBAAiB,QAAS,OAAO,KAAG,GAAG,IAAI,eACV,CAAC;AAE/C,eAAO,MAAM,yBAAyB;;;;;;OAX7B,EAAG,SAAS;QAAS,EAAG,WAAW,CAAC,EAAE,SAC/C;UACW,EAAG,SAAS;QAAS,EAAG,SAAS;QACvC,EAAG,SAAS;QAAS,EAAG,SAAS;iBASQ,CAAC;AAC/C,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,eAAO,MAAM,qBAAqB,QAC3B,OAAO,KACX,GAAG,IAAI,mBACwC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAA6B,MAAM,kBAAkB,CAAC;AAEzE,eAAO,MAAM,gBAAgB,UAAW,SAAS,EAAE,SAElD,CAAC;AAEF,eAAO,MAAM,yBAAyB,UAC7B,SAAS,EAAE,QACb,OAAO,KACX,UAqEF,CAAC"}
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAA6B,MAAM,kBAAkB,CAAC;AAEzE,eAAO,MAAM,gBAAgB,UAAW,SAAS,EAAE,SAElD,CAAC;AAEF,eAAO,MAAM,yBAAyB,UAC7B,SAAS,EAAE,QACb,OAAO,KACX,UAuEF,CAAC"}
package/dist/transform.js CHANGED
@@ -17,7 +17,7 @@ const getTimeSeriesDataFromData = (items, log = kit_log_1.XubeLog.getInstance())
17
17
  log.info(JSON.stringify(items, null, 2));
18
18
  for (const item of itemsOrderedByMicrosecondsSinceEpoch) {
19
19
  if (!(0, kit_aws_data_schema_1.isReadingV1)(item)) {
20
- console.log(`${item.type} is not a currently supported type.`);
20
+ log.info(`Skipping non-v1 reading (v=${item.v ?? "?"}); webhook pipeline handles v1 only.`);
21
21
  continue;
22
22
  }
23
23
  const microsSinceEpoch = microsecondsSinceEpoch(item.s, item.us ?? 0);
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@ export declare const WebhookTypes: {
3
3
  readonly data: "data";
4
4
  readonly event: "event";
5
5
  };
6
- export declare const WebhookTypesSchema: z.ZodNativeEnum<{
6
+ export declare const WebhookTypesSchema: z.ZodEnum<{
7
7
  readonly data: "data";
8
8
  readonly event: "event";
9
9
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xube/kit-aws-hooks",
3
- "version": "0.2.7",
3
+ "version": "0.2.12",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,15 +17,15 @@
17
17
  },
18
18
  "homepage": "https://github.com/XubeLtd/dev-kit#readme",
19
19
  "devDependencies": {
20
- "@xube/kit-build": "^0.2.7"
20
+ "@xube/kit-build": "^0.2.12"
21
21
  },
22
22
  "dependencies": {
23
- "@xube/kit-aws": "^0.2.7",
24
- "@xube/kit-aws-data-schema": "^0.2.7",
25
- "@xube/kit-aws-schema": "^0.2.7",
26
- "@xube/kit-log": "^0.2.7",
27
- "@xube/kit-request": "^0.2.7",
28
- "@xube/kit-schema": "^0.2.7",
29
- "zod": "^3.23.8"
23
+ "@xube/kit-aws": "^0.2.12",
24
+ "@xube/kit-aws-data-schema": "^0.2.12",
25
+ "@xube/kit-aws-schema": "^0.2.12",
26
+ "@xube/kit-log": "^0.2.12",
27
+ "@xube/kit-request": "^0.2.12",
28
+ "@xube/kit-schema": "^0.2.12",
29
+ "zod": "^4.4.3"
30
30
  }
31
31
  }
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
 
3
- export const HookEndpointHeaderSchema = z.record(z.string());
3
+ export const HookEndpointHeaderSchema = z.record(z.string(), z.string());
4
4
  export type HookEndpointHeader = z.infer<typeof HookEndpointHeaderSchema>;
5
5
 
6
6
  export const HookEndpointSchema = z.object({
@@ -1,4 +1,8 @@
1
- import { DATA_TYPE, ReadingV1 } from "@xube/kit-aws-data-schema";
1
+ import {
2
+ DATA_TYPE,
3
+ READING_VERSION_1,
4
+ ReadingV1,
5
+ } from "@xube/kit-aws-data-schema";
2
6
  import { getTimeSeriesDataFromData } from "./transform";
3
7
  import { TableItem } from "@xube/kit-aws-schema";
4
8
  import { TimeSeries } from "@xube/kit-schema";
@@ -7,6 +11,7 @@ describe("getTimeSeriesDataFromData", () => {
7
11
  it("should return an array of objects with the time series shape", () => {
8
12
  const items: (ReadingV1 & TableItem)[] = [
9
13
  {
14
+ v: READING_VERSION_1,
10
15
  PK: "",
11
16
  SK: "",
12
17
  data: "S,+000.30,+001.74,M,00,33",
@@ -17,6 +22,7 @@ describe("getTimeSeriesDataFromData", () => {
17
22
  component: "component",
18
23
  },
19
24
  {
25
+ v: READING_VERSION_1,
20
26
  PK: "",
21
27
  SK: "",
22
28
  data: "S,+000.35,+001.84,M,00,39",
@@ -27,6 +33,7 @@ describe("getTimeSeriesDataFromData", () => {
27
33
  component: "component",
28
34
  },
29
35
  {
36
+ v: READING_VERSION_1,
30
37
  PK: "",
31
38
  SK: "",
32
39
  data: "S,+000.26,+002.00,M,00,34",
@@ -37,6 +44,7 @@ describe("getTimeSeriesDataFromData", () => {
37
44
  component: "component",
38
45
  },
39
46
  {
47
+ v: READING_VERSION_1,
40
48
  PK: "",
41
49
  SK: "",
42
50
  data: "S,+000.34,+001.88,M,00,34",
@@ -47,6 +55,7 @@ describe("getTimeSeriesDataFromData", () => {
47
55
  component: "component",
48
56
  },
49
57
  {
58
+ v: READING_VERSION_1,
50
59
  PK: "",
51
60
  SK: "",
52
61
  data: "S,+000.35,+001.82,M,00,3F",
@@ -65,8 +74,9 @@ describe("getTimeSeriesDataFromData", () => {
65
74
  v: "1",
66
75
  m: {
67
76
  id: "12345678",
77
+ component: "component",
68
78
  trigger: DATA_TYPE,
69
- source: "device",
79
+ source: "component",
70
80
  },
71
81
  t0: "2023-10-17T21:40:41.214581Z",
72
82
  dtt: "ms",
package/src/transform.ts CHANGED
@@ -26,7 +26,9 @@ export const getTimeSeriesDataFromData = (
26
26
 
27
27
  for (const item of itemsOrderedByMicrosecondsSinceEpoch) {
28
28
  if (!isReadingV1(item)) {
29
- console.log(`${item.type} is not a currently supported type.`);
29
+ log.info(
30
+ `Skipping non-v1 reading (v=${(item as { v?: unknown }).v ?? "?"}); webhook pipeline handles v1 only.`,
31
+ );
30
32
  continue;
31
33
  }
32
34