@hostwebhook/node 1.4.2 → 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, 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, 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,6 +28,7 @@ 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
33
  SendError: () => SendError,
33
34
  VerificationError: () => VerificationError,
@@ -195,6 +196,12 @@ function fastifyHook(secret, options) {
195
196
  var import_crypto2 = require("crypto");
196
197
 
197
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
+ };
198
205
  var SendError = class extends Error {
199
206
  constructor(message, statusCode, responseBody) {
200
207
  super(message);
@@ -647,6 +654,7 @@ async function send(config, payload, options) {
647
654
  }
648
655
  // Annotate the CommonJS export names for ESM import in node:
649
656
  0 && (module.exports = {
657
+ FileEventType,
650
658
  HostWebhook,
651
659
  SendError,
652
660
  VerificationError,
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);
@@ -613,6 +619,7 @@ async function send(config, payload, options) {
613
619
  return client.send(payload, options);
614
620
  }
615
621
  export {
622
+ FileEventType,
616
623
  HostWebhook,
617
624
  SendError,
618
625
  VerificationError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostwebhook/node",
3
- "version": "1.4.2",
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",