@skillstew/common 1.0.21 → 1.0.23

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.
@@ -8,14 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  exports.Consumer = void 0;
16
13
  const EventMap_1 = require("./EventMap");
17
14
  const MessageQueueErrors_1 = require("../errors/MessageQueueErrors");
18
- const zod_1 = __importDefault(require("zod"));
19
15
  class Consumer {
20
16
  constructor() {
21
17
  this._initialized = false;
@@ -46,9 +42,8 @@ class Consumer {
46
42
  }
47
43
  const parseResult = schema.safeParse(event.data);
48
44
  if (!parseResult.success) {
49
- this._channel.ack(msg);
50
- const error = zod_1.default.prettifyError(parseResult.error);
51
- throw new MessageQueueErrors_1.InvalidEventPayloadError(eventName, error);
45
+ this._channel.nack(msg, false, false);
46
+ return;
52
47
  }
53
48
  // create typed app event
54
49
  const appEvent = Object.assign(Object.assign({}, event), { data: parseResult.data });
@@ -1,5 +1,12 @@
1
1
  import z from "zod";
2
2
  export declare const EventSchemas: {
3
+ readonly "skill.created": z.ZodObject<{
4
+ id: z.ZodUUID;
5
+ name: z.ZodString;
6
+ normalizedName: z.ZodString;
7
+ alternateNames: z.ZodArray<z.ZodString>;
8
+ status: z.ZodString;
9
+ }, z.core.$strip>;
3
10
  readonly "user.registered": z.ZodObject<{
4
11
  id: z.ZodUUID;
5
12
  email: z.ZodEmail;
@@ -2,5 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EventSchemas = void 0;
4
4
  const userEventsSchema_1 = require("./schemas/userEventsSchema");
5
+ const skillsEventSchemas_1 = require("./schemas/skillsEventSchemas");
5
6
  // Union of all app event schemas
6
- exports.EventSchemas = Object.assign({}, userEventsSchema_1.UserEventSchemas);
7
+ exports.EventSchemas = Object.assign(Object.assign({}, userEventsSchema_1.UserEventSchemas), skillsEventSchemas_1.SkillsEventSchemas);
@@ -0,0 +1,17 @@
1
+ import z from "zod";
2
+ export declare const skillCreatedSchema: z.ZodObject<{
3
+ id: z.ZodUUID;
4
+ name: z.ZodString;
5
+ normalizedName: z.ZodString;
6
+ alternateNames: z.ZodArray<z.ZodString>;
7
+ status: z.ZodString;
8
+ }, z.core.$strip>;
9
+ export declare const SkillsEventSchemas: {
10
+ readonly "skill.created": z.ZodObject<{
11
+ id: z.ZodUUID;
12
+ name: z.ZodString;
13
+ normalizedName: z.ZodString;
14
+ alternateNames: z.ZodArray<z.ZodString>;
15
+ status: z.ZodString;
16
+ }, z.core.$strip>;
17
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SkillsEventSchemas = exports.skillCreatedSchema = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ exports.skillCreatedSchema = zod_1.default.object({
9
+ id: zod_1.default.uuid(),
10
+ name: zod_1.default.string(),
11
+ normalizedName: zod_1.default.string(),
12
+ alternateNames: zod_1.default.array(zod_1.default.string()),
13
+ status: zod_1.default.string(),
14
+ });
15
+ exports.SkillsEventSchemas = {
16
+ "skill.created": exports.skillCreatedSchema,
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillstew/common",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "scripts": {
package/publish.sh CHANGED
@@ -18,7 +18,7 @@ git add .
18
18
  # Step 4: Prompt for a commit message
19
19
  echo "Enter commit message:"
20
20
  read COMMIT_MESSAGE
21
- git commit -m "[common] $COMMIT_MESSAGE"
21
+ git commit -m "$COMMIT_MESSAGE"
22
22
 
23
23
  # Step 5: Push to GitHub
24
24
  git push
@@ -3,10 +3,8 @@ import { EventName, EventSchemas } from "./EventMap";
3
3
  import { AnyAppEvent, AppEvent } from "./AppEvent";
4
4
  import {
5
5
  ConsumerUsedBeforeInitializationError,
6
- InvalidEventPayloadError,
7
6
  UnknownEventError,
8
7
  } from "../errors/MessageQueueErrors";
9
- import z from "zod";
10
8
 
11
9
  type EventHandler<T extends EventName> = (
12
10
  event: AppEvent<T>,
@@ -60,9 +58,8 @@ export class Consumer {
60
58
  }
61
59
  const parseResult = schema.safeParse(event.data);
62
60
  if (!parseResult.success) {
63
- this._channel.ack(msg);
64
- const error = z.prettifyError(parseResult.error);
65
- throw new InvalidEventPayloadError(eventName, error);
61
+ this._channel.nack(msg, false, false);
62
+ return;
66
63
  }
67
64
 
68
65
  // create typed app event
@@ -1,10 +1,12 @@
1
1
  import z from "zod";
2
2
  import { UserEventSchemas } from "./schemas/userEventsSchema";
3
+ import { SkillsEventSchemas } from "./schemas/skillsEventSchemas";
3
4
 
4
5
  // Union of all app event schemas
5
6
 
6
7
  export const EventSchemas = {
7
8
  ...UserEventSchemas,
9
+ ...SkillsEventSchemas,
8
10
  } as const;
9
11
 
10
12
  // Union of all app event names
@@ -0,0 +1,13 @@
1
+ import z from "zod";
2
+
3
+ export const skillCreatedSchema = z.object({
4
+ id: z.uuid(),
5
+ name: z.string(),
6
+ normalizedName: z.string(),
7
+ alternateNames: z.array(z.string()),
8
+ status: z.string(),
9
+ });
10
+
11
+ export const SkillsEventSchemas = {
12
+ "skill.created": skillCreatedSchema,
13
+ } as const;