@palmetto/pubsub 3.4.2 → 3.5.0

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,5 @@
1
1
  import { z } from "zod";
2
+ import { $ZodType } from "zod/v4/core";
2
3
  /**
3
4
  * The schema for the metadata of a message. This is added by the publisher if not provided, but can also be provided by the publisher if they want to set specific values.
4
5
  */
@@ -52,7 +53,7 @@ export interface PubSubConfiguration {
52
53
  /**
53
54
  * The schema for the message - the message is verfied during publish and subscribe
54
55
  */
55
- schema: z.ZodType;
56
+ schema: $ZodType<BaseMessage>;
56
57
  /**
57
58
  * The message transport to use (defined by the event-pubsub implementations)
58
59
  */
@@ -59,7 +59,7 @@ export declare class Publisher {
59
59
  addProvider(provider: PublisherProvider): void;
60
60
  removeProvider(providerOrTransport: PublisherProvider | string): boolean;
61
61
  init(config: PubSubConfiguration): Promise<void>;
62
- publish(config: PubSubConfiguration, message: BaseMessage | BaseMessage[], options?: PublishMessageOptions): Promise<void>;
62
+ publish<TMessage extends BaseMessage>(config: PubSubConfiguration, message: TMessage | TMessage[], options?: PublishMessageOptions): Promise<void>;
63
63
  private publishImpl;
64
64
  close(): Promise<void>;
65
65
  private getProvider;
package/dist/publisher.js CHANGED
@@ -89,7 +89,7 @@ class Publisher {
89
89
  msg.meta.schemaId = schemaId;
90
90
  msg.meta.createdAt = new Date().toISOString();
91
91
  }
92
- const check = schema.safeEncode(msg);
92
+ const check = zod_1.z.safeEncode(schema, msg);
93
93
  if (!check.success) {
94
94
  (0, message_logger_js_1.logMessage)({
95
95
  note: "Publish message failed schema validation",
@@ -15,6 +15,7 @@ const errors_js_1 = require("./errors.js");
15
15
  const events_1 = require("events");
16
16
  const message_logger_js_1 = require("./message-logger.js");
17
17
  const create_log_error_payload_js_1 = require("./create-log-error-payload.js");
18
+ const zod_1 = require("zod");
18
19
  class SubscribedMessage {
19
20
  constructor(stop) {
20
21
  this.stop = stop;
@@ -65,7 +66,7 @@ class Subscriber {
65
66
  };
66
67
  this.events.emit("messageReceived", messageReceivedEventContext);
67
68
  const jsonObject = JSON.parse(jsonStr);
68
- const decodeResult = schema.safeDecode(jsonObject);
69
+ const decodeResult = zod_1.z.safeDecode(schema, jsonObject);
69
70
  if (!decodeResult.success) {
70
71
  const durationMs = (0, message_logger_js_1.getDuration)(start);
71
72
  (0, message_logger_js_1.logMessage)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palmetto/pubsub",
3
- "version": "3.4.2",
3
+ "version": "3.5.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/palmetto/galaxy"