@hostwebhook/node 1.4.2 → 1.5.1

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);
@@ -332,7 +339,14 @@ var HostWebhook = class {
332
339
  if (!confirmRes.ok) throw new SendError(`Failed to confirm upload for ${fieldName}`, confirmRes.status, await confirmRes.text());
333
340
  const confirmed = await confirmRes.json();
334
341
  enrichedPayload[fieldName] = {
335
- _file: { id: confirmed.id, key, originalName: confirmed.originalName, mimeType: confirmed.mimeType, size: confirmed.size }
342
+ _file: {
343
+ id: confirmed.id,
344
+ key,
345
+ originalName: confirmed.originalName,
346
+ mimeType: confirmed.mimeType,
347
+ size: confirmed.size,
348
+ ...confirmed.downloadUrl && { downloadUrl: confirmed.downloadUrl }
349
+ }
336
350
  };
337
351
  }
338
352
  return __privateMethod(this, _HostWebhook_instances, doSend_fn).call(this, token, enrichedPayload, options);
@@ -396,7 +410,7 @@ doSend_fn = async function(token, payload, options) {
396
410
  }
397
411
  const headers = {
398
412
  "Content-Type": options?.contentType ?? "application/json",
399
- "User-Agent": `HostWebhook-SDK/${"1.4.2"}`,
413
+ "User-Agent": `HostWebhook-SDK/${"1.5.0"}`,
400
414
  "X-HostWebhook-Sent-At": (/* @__PURE__ */ new Date()).toISOString(),
401
415
  ...tz ? { "X-HostWebhook-Timezone": tz } : {},
402
416
  ...__privateGet(this, _defaultHeaders),
@@ -647,6 +661,7 @@ async function send(config, payload, options) {
647
661
  }
648
662
  // Annotate the CommonJS export names for ESM import in node:
649
663
  0 && (module.exports = {
664
+ FileEventType,
650
665
  HostWebhook,
651
666
  SendError,
652
667
  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);
@@ -299,7 +305,14 @@ var HostWebhook = class {
299
305
  if (!confirmRes.ok) throw new SendError(`Failed to confirm upload for ${fieldName}`, confirmRes.status, await confirmRes.text());
300
306
  const confirmed = await confirmRes.json();
301
307
  enrichedPayload[fieldName] = {
302
- _file: { id: confirmed.id, key, originalName: confirmed.originalName, mimeType: confirmed.mimeType, size: confirmed.size }
308
+ _file: {
309
+ id: confirmed.id,
310
+ key,
311
+ originalName: confirmed.originalName,
312
+ mimeType: confirmed.mimeType,
313
+ size: confirmed.size,
314
+ ...confirmed.downloadUrl && { downloadUrl: confirmed.downloadUrl }
315
+ }
303
316
  };
304
317
  }
305
318
  return __privateMethod(this, _HostWebhook_instances, doSend_fn).call(this, token, enrichedPayload, options);
@@ -363,7 +376,7 @@ doSend_fn = async function(token, payload, options) {
363
376
  }
364
377
  const headers = {
365
378
  "Content-Type": options?.contentType ?? "application/json",
366
- "User-Agent": `HostWebhook-SDK/${"1.4.2"}`,
379
+ "User-Agent": `HostWebhook-SDK/${"1.5.0"}`,
367
380
  "X-HostWebhook-Sent-At": (/* @__PURE__ */ new Date()).toISOString(),
368
381
  ...tz ? { "X-HostWebhook-Timezone": tz } : {},
369
382
  ...__privateGet(this, _defaultHeaders),
@@ -613,6 +626,7 @@ async function send(config, payload, options) {
613
626
  return client.send(payload, options);
614
627
  }
615
628
  export {
629
+ FileEventType,
616
630
  HostWebhook,
617
631
  SendError,
618
632
  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.1",
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",