@hostwebhook/node 1.4.1 → 1.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.
package/dist/index.d.mts CHANGED
@@ -140,6 +140,30 @@ declare function createNestGuard(secret: string, options?: VerifyOptions): {
140
140
  */
141
141
  declare function fastifyHook(secret: string, options?: VerifyOptions): (req: ExpressRequest, reply: ExpressResponse, done: NextFn) => void;
142
142
 
143
+ /**
144
+ * Supported file event types for `sendWithFiles`.
145
+ * Each type corresponds to a File Transform operation in the pipeline.
146
+ * New types are added here as new operations are supported.
147
+ */
148
+ declare const FileEventType: {
149
+ readonly PDF_UPLOAD: "pdf_upload";
150
+ readonly CSV_UPLOAD: "csv_upload";
151
+ readonly IMAGE_RESIZE: "image_resize";
152
+ readonly IMAGE_COMPRESS: "image_compress";
153
+ };
154
+ /** Union of all supported file event types. */
155
+ type FileEventType = typeof FileEventType[keyof typeof FileEventType];
156
+ /**
157
+ * Payload for `sendWithFiles`. Enforces a valid `eventType` from `FileEventType`.
158
+ */
159
+ interface FilePayload extends Record<string, unknown> {
160
+ /** The file processing operation to perform. Must be a supported `FileEventType`. */
161
+ eventType: FileEventType;
162
+ /** Original file name (for logging and downstream nodes). */
163
+ fileName?: string;
164
+ /** File size in bytes (for logging). */
165
+ fileSize?: number;
166
+ }
143
167
  /** Static secret signature — sends the secret as-is in a header (no HMAC). */
144
168
  interface StaticSignature {
145
169
  type: 'static';
@@ -345,7 +369,7 @@ declare class HostWebhook {
345
369
  * );
346
370
  * ```
347
371
  */
348
- sendWithFiles(tokenOrPayload: string | Record<string, unknown>, payloadOrFiles: Record<string, unknown> | Record<string, {
372
+ sendWithFiles(tokenOrPayload: string | FilePayload, payloadOrFiles: FilePayload | Record<string, {
349
373
  data: Buffer | Blob | Uint8Array;
350
374
  fileName: string;
351
375
  mimeType: string;
@@ -408,4 +432,4 @@ declare class PipelineStream {
408
432
  */
409
433
  declare function send(config: HostWebhookConfig, payload: Record<string, unknown>, options?: SendOptions): Promise<SendResult>;
410
434
 
411
- export { HostWebhook, type HostWebhookConfig, type PipelineStep, PipelineStream, SendError, type SendOptions, type SendResult, type StaticSignature, VerificationError, type VerifyOptions, type WebhookHeaders, createNestGuard, expressMiddleware, fastifyHook, parseHeaders, send, verify };
435
+ export { FileEventType, type FilePayload, HostWebhook, type HostWebhookConfig, type PipelineStep, SendError, type SendOptions, type SendResult, type StaticSignature, VerificationError, type VerifyOptions, type WebhookHeaders, createNestGuard, expressMiddleware, fastifyHook, parseHeaders, send, verify };
package/dist/index.d.ts CHANGED
@@ -140,6 +140,30 @@ declare function createNestGuard(secret: string, options?: VerifyOptions): {
140
140
  */
141
141
  declare function fastifyHook(secret: string, options?: VerifyOptions): (req: ExpressRequest, reply: ExpressResponse, done: NextFn) => void;
142
142
 
143
+ /**
144
+ * Supported file event types for `sendWithFiles`.
145
+ * Each type corresponds to a File Transform operation in the pipeline.
146
+ * New types are added here as new operations are supported.
147
+ */
148
+ declare const FileEventType: {
149
+ readonly PDF_UPLOAD: "pdf_upload";
150
+ readonly CSV_UPLOAD: "csv_upload";
151
+ readonly IMAGE_RESIZE: "image_resize";
152
+ readonly IMAGE_COMPRESS: "image_compress";
153
+ };
154
+ /** Union of all supported file event types. */
155
+ type FileEventType = typeof FileEventType[keyof typeof FileEventType];
156
+ /**
157
+ * Payload for `sendWithFiles`. Enforces a valid `eventType` from `FileEventType`.
158
+ */
159
+ interface FilePayload extends Record<string, unknown> {
160
+ /** The file processing operation to perform. Must be a supported `FileEventType`. */
161
+ eventType: FileEventType;
162
+ /** Original file name (for logging and downstream nodes). */
163
+ fileName?: string;
164
+ /** File size in bytes (for logging). */
165
+ fileSize?: number;
166
+ }
143
167
  /** Static secret signature — sends the secret as-is in a header (no HMAC). */
144
168
  interface StaticSignature {
145
169
  type: 'static';
@@ -345,7 +369,7 @@ declare class HostWebhook {
345
369
  * );
346
370
  * ```
347
371
  */
348
- sendWithFiles(tokenOrPayload: string | Record<string, unknown>, payloadOrFiles: Record<string, unknown> | Record<string, {
372
+ sendWithFiles(tokenOrPayload: string | FilePayload, payloadOrFiles: FilePayload | Record<string, {
349
373
  data: Buffer | Blob | Uint8Array;
350
374
  fileName: string;
351
375
  mimeType: string;
@@ -408,4 +432,4 @@ declare class PipelineStream {
408
432
  */
409
433
  declare function send(config: HostWebhookConfig, payload: Record<string, unknown>, options?: SendOptions): Promise<SendResult>;
410
434
 
411
- export { HostWebhook, type HostWebhookConfig, type PipelineStep, PipelineStream, SendError, type SendOptions, type SendResult, type StaticSignature, VerificationError, type VerifyOptions, type WebhookHeaders, createNestGuard, expressMiddleware, fastifyHook, parseHeaders, send, verify };
435
+ export { FileEventType, type FilePayload, HostWebhook, type HostWebhookConfig, type PipelineStep, SendError, type SendOptions, type SendResult, type StaticSignature, VerificationError, type VerifyOptions, type WebhookHeaders, createNestGuard, expressMiddleware, fastifyHook, parseHeaders, send, verify };
package/dist/index.js CHANGED
@@ -28,8 +28,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
28
28
  // src/index.ts
29
29
  var index_exports = {};
30
30
  __export(index_exports, {
31
+ FileEventType: () => FileEventType,
31
32
  HostWebhook: () => HostWebhook,
32
- PipelineStream: () => PipelineStream,
33
33
  SendError: () => SendError,
34
34
  VerificationError: () => VerificationError,
35
35
  createNestGuard: () => createNestGuard,
@@ -196,6 +196,12 @@ function fastifyHook(secret, options) {
196
196
  var import_crypto2 = require("crypto");
197
197
 
198
198
  // src/send-types.ts
199
+ var FileEventType = {
200
+ PDF_UPLOAD: "pdf_upload",
201
+ CSV_UPLOAD: "csv_upload",
202
+ IMAGE_RESIZE: "image_resize",
203
+ IMAGE_COMPRESS: "image_compress"
204
+ };
199
205
  var SendError = class extends Error {
200
206
  constructor(message, statusCode, responseBody) {
201
207
  super(message);
@@ -397,7 +403,7 @@ doSend_fn = async function(token, payload, options) {
397
403
  }
398
404
  const headers = {
399
405
  "Content-Type": options?.contentType ?? "application/json",
400
- "User-Agent": `HostWebhook-SDK/${"1.4.1"}`,
406
+ "User-Agent": `HostWebhook-SDK/${"1.4.2"}`,
401
407
  "X-HostWebhook-Sent-At": (/* @__PURE__ */ new Date()).toISOString(),
402
408
  ...tz ? { "X-HostWebhook-Timezone": tz } : {},
403
409
  ...__privateGet(this, _defaultHeaders),
@@ -648,8 +654,8 @@ async function send(config, payload, options) {
648
654
  }
649
655
  // Annotate the CommonJS export names for ESM import in node:
650
656
  0 && (module.exports = {
657
+ FileEventType,
651
658
  HostWebhook,
652
- PipelineStream,
653
659
  SendError,
654
660
  VerificationError,
655
661
  createNestGuard,
package/dist/index.mjs CHANGED
@@ -162,6 +162,12 @@ function fastifyHook(secret, options) {
162
162
  import { createHmac as createHmac2 } from "crypto";
163
163
 
164
164
  // src/send-types.ts
165
+ var FileEventType = {
166
+ PDF_UPLOAD: "pdf_upload",
167
+ CSV_UPLOAD: "csv_upload",
168
+ IMAGE_RESIZE: "image_resize",
169
+ IMAGE_COMPRESS: "image_compress"
170
+ };
165
171
  var SendError = class extends Error {
166
172
  constructor(message, statusCode, responseBody) {
167
173
  super(message);
@@ -363,7 +369,7 @@ doSend_fn = async function(token, payload, options) {
363
369
  }
364
370
  const headers = {
365
371
  "Content-Type": options?.contentType ?? "application/json",
366
- "User-Agent": `HostWebhook-SDK/${"1.4.1"}`,
372
+ "User-Agent": `HostWebhook-SDK/${"1.4.2"}`,
367
373
  "X-HostWebhook-Sent-At": (/* @__PURE__ */ new Date()).toISOString(),
368
374
  ...tz ? { "X-HostWebhook-Timezone": tz } : {},
369
375
  ...__privateGet(this, _defaultHeaders),
@@ -613,8 +619,8 @@ async function send(config, payload, options) {
613
619
  return client.send(payload, options);
614
620
  }
615
621
  export {
622
+ FileEventType,
616
623
  HostWebhook,
617
- PipelineStream,
618
624
  SendError,
619
625
  VerificationError,
620
626
  createNestGuard,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostwebhook/node",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Official HostWebhook SDK — verify signatures, parse headers, and send webhooks",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",