@snyxex/pipex 1.0.2 → 1.0.3

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.
Files changed (77) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +238 -139
  3. package/dist/compression-2mm0MhWY.mjs +1 -0
  4. package/dist/compression-CtrHxa9G.d.mts +38 -0
  5. package/dist/compression-DnVFu8TM.d.cts +38 -0
  6. package/dist/compression-DrgzribA.cjs +1 -0
  7. package/dist/compression.cjs +1 -0
  8. package/dist/compression.d.cts +2 -0
  9. package/dist/compression.d.mts +2 -0
  10. package/dist/compression.mjs +1 -0
  11. package/dist/core-BOdvxKBq.mjs +2 -0
  12. package/dist/core-B_z1gN5W.cjs +2 -0
  13. package/dist/dataEngine-4m6GTOLe.mjs +1 -0
  14. package/dist/dataEngine-Bvl6amzP.cjs +1 -0
  15. package/dist/dataEngine-D-fIXgE7.d.cts +232 -0
  16. package/dist/dataEngine-DUEmWp7a.d.mts +232 -0
  17. package/dist/encryption-BmmNECIc.d.cts +44 -0
  18. package/dist/encryption-CnSL1BEY.d.mts +44 -0
  19. package/dist/encryption-CqxtoqAD.mjs +1 -0
  20. package/dist/encryption-DdP1zFYl.cjs +1 -0
  21. package/dist/encryption.cjs +1 -0
  22. package/dist/encryption.d.cts +2 -0
  23. package/dist/encryption.d.mts +2 -0
  24. package/dist/encryption.mjs +1 -0
  25. package/dist/hashing-B6xGcbQR.d.mts +33 -0
  26. package/dist/hashing-ChrADfcH.mjs +1 -0
  27. package/dist/hashing-JtOHPybU.cjs +1 -0
  28. package/dist/hashing-LY-8x66g.d.cts +33 -0
  29. package/dist/hashing.cjs +1 -0
  30. package/dist/hashing.d.cts +2 -0
  31. package/dist/hashing.d.mts +2 -0
  32. package/dist/hashing.mjs +1 -0
  33. package/dist/index.cjs +1 -0
  34. package/dist/index.d.cts +302 -0
  35. package/dist/index.d.mts +87 -550
  36. package/dist/index.mjs +1 -3
  37. package/dist/kms.cjs +1 -0
  38. package/dist/kms.d.cts +3 -0
  39. package/dist/kms.d.mts +3 -0
  40. package/dist/kms.mjs +1 -0
  41. package/dist/kms_encryption-Da-KqjKI.d.mts +33 -0
  42. package/dist/kms_encryption-Dh1LEHhk.d.cts +33 -0
  43. package/dist/kms_encryption-R9auKGW4.mjs +1 -0
  44. package/dist/kms_encryption-xyWi65rZ.cjs +1 -0
  45. package/dist/native.cjs +1 -0
  46. package/dist/native.d.cts +2 -0
  47. package/dist/native.d.mts +2 -0
  48. package/dist/native.mjs +1 -0
  49. package/dist/parallel.cjs +1 -0
  50. package/dist/parallel.d.cts +2 -0
  51. package/dist/parallel.d.mts +2 -0
  52. package/dist/parallel.mjs +1 -0
  53. package/dist/plugin-C9Kd9coY.d.cts +16 -0
  54. package/dist/plugin-CE94-p8P.d.mts +16 -0
  55. package/dist/resourceLimits-C1HHDwXQ.mjs +1 -0
  56. package/dist/resourceLimits-CI0Qrqdf.cjs +1 -0
  57. package/dist/types-Bytga6zd.d.mts +155 -0
  58. package/dist/types-ia4x-Dvp.d.cts +155 -0
  59. package/dist/validation-CqmhNHdW.d.cts +32 -0
  60. package/dist/validation-D17IkoHy.d.mts +32 -0
  61. package/dist/validation-P5WRSAUK.mjs +1 -0
  62. package/dist/validation-pEeJmCad.cjs +1 -0
  63. package/dist/validation.cjs +1 -0
  64. package/dist/validation.d.cts +2 -0
  65. package/dist/validation.d.mts +2 -0
  66. package/dist/validation.mjs +1 -0
  67. package/dist/worker-CbuCpSNc.d.cts +37 -0
  68. package/dist/worker-CgCC-BWG.d.mts +37 -0
  69. package/dist/worker-I_kqxWeK.cjs +1 -0
  70. package/dist/worker-c0_VZ9c7.mjs +1 -0
  71. package/package.json +120 -23
  72. package/SECURITY.md +0 -41
  73. package/dist/index.d.mts.map +0 -1
  74. package/dist/index.mjs.map +0 -1
  75. package/docs/architecture.md +0 -124
  76. package/docs/encryption-v4-migration.md +0 -45
  77. package/docs/enterprise.md +0 -280
package/dist/index.d.mts CHANGED
@@ -1,159 +1,15 @@
1
+ import { C as StreamPluginContext, S as Span, T as isManifest, _ as ProcessorContext, a as EngineEvents, b as RetryOptions, c as KmsOperation, d as KmsRequestOptions, f as Logger, g as PluginOperation, h as PluginCapabilities, i as EngineConfig, l as KmsProvider, m as PipeXManifest, n as AuditRecord, o as EngineLimits, p as OperationOptions, r as BinaryUndoOptions, s as EngineResult, t as AuditLogger, u as KmsProviderCapabilities, v as ProcessorPlugin, w as Tracer, x as SchemaRegistry, y as RegisteredPluginCapabilities } from "./types-Bytga6zd.mjs";
2
+ import { t as BasePlugin } from "./plugin-CE94-p8P.mjs";
3
+ import { i as CompressionType, n as CompressionOptions, r as CompressionPlugin } from "./compression-CtrHxa9G.mjs";
4
+ import { a as EncryptionPlugin, i as EncryptionOptions, o as EncryptionAlgorithm } from "./encryption-CnSL1BEY.mjs";
5
+ import { n as HashingOptions, r as HashingPlugin, t as HashAlgorithm } from "./hashing-B6xGcbQR.mjs";
6
+ import { n as KmsEncryptionPlugin, t as KmsEncryptionOptions } from "./kms_encryption-Da-KqjKI.mjs";
7
+ import { n as PluginConstructor, t as DataEngine } from "./dataEngine-DUEmWp7a.mjs";
8
+ import { n as WorkerPoolPlugin, t as WorkerPoolOptions } from "./worker-CgCC-BWG.mjs";
9
+ import { n as ValidationPlugin, t as ValidationOptions } from "./validation-D17IkoHy.mjs";
1
10
  import { Duplex, Readable, Transform, TransformCallback, Writable } from "node:stream";
2
11
  import { Packr, PackrStream, Unpackr, UnpackrStream } from "msgpackr";
3
- import { z } from "zod";
4
- import { EventEmitter } from "node:events";
5
12
 
6
- //#region src/core/types.d.ts
7
- interface Logger {
8
- info(message: string, context?: Record<string, unknown>): void;
9
- warn(message: string, context?: Record<string, unknown>): void;
10
- error(message: string, context?: Record<string, unknown>): void;
11
- debug(message: string, context?: Record<string, unknown>): void;
12
- }
13
- interface Span {
14
- setAttribute(key: string, value: unknown): this;
15
- addEvent(name: string, attributes?: Record<string, unknown>): this;
16
- end(): void;
17
- }
18
- interface Tracer {
19
- startSpan(name: string, context?: ProcessorContext): Span;
20
- }
21
- interface RetryOptions {
22
- attempts: number;
23
- backoff: 'exponential' | 'fixed';
24
- delayMs: number;
25
- }
26
- interface EngineLimits {
27
- maxInputBytes: number;
28
- maxOutputBytes: number;
29
- maxFrameBytes: number;
30
- maxFrames: number;
31
- maxConcurrentOperations: number;
32
- operationTimeoutMs: number;
33
- maxRetryAttempts: number;
34
- maxRetryDelayMs: number;
35
- /** Maximum provider-wrapped data-key bytes accepted in a KMS envelope. */
36
- maxKmsEncryptedKeyBytes: number;
37
- /** Maximum UTF-8 bytes accepted for a provider key identifier. */
38
- maxKmsKeyIdBytes: number;
39
- }
40
- interface OperationOptions {
41
- signal?: AbortSignal;
42
- timeoutMs?: number;
43
- }
44
- /** expectedType must come from trusted application configuration, never the received result. */
45
- interface BinaryUndoOptions extends OperationOptions {
46
- expectedType?: string;
47
- }
48
- interface StreamPluginContext {
49
- /** Engine-owned accounting for work that continues after cancellation. */
50
- readonly track?: (pending: Promise<unknown>) => void;
51
- readonly requestId: string;
52
- readonly signal: AbortSignal;
53
- readonly limits: Readonly<EngineLimits>;
54
- readonly logger?: Logger;
55
- readonly tracer?: Tracer;
56
- }
57
- interface AuditRecord {
58
- requestId: string;
59
- operation: 'pack' | 'unpack' | 'process' | 'reverse';
60
- pluginChain: string[];
61
- timestamp: number;
62
- metadata: Record<string, unknown>;
63
- }
64
- interface AuditLogger {
65
- log(record: AuditRecord): void | Promise<void>;
66
- }
67
- type KmsOperation = 'encrypt' | 'decrypt' | 'generateDataKey';
68
- interface KmsProviderCapabilities {
69
- readonly encrypt: boolean;
70
- readonly decrypt: boolean;
71
- readonly generateDataKey: boolean;
72
- }
73
- interface KmsProvider {
74
- /** Explicit false disables an operation even when a compatibility stub exists. */
75
- readonly capabilities?: Partial<KmsProviderCapabilities>;
76
- encrypt?(data: Buffer, keyId: string, options?: KmsRequestOptions): Promise<Buffer>;
77
- decrypt?(data: Buffer, keyId: string, options?: KmsRequestOptions): Promise<Buffer>;
78
- generateDataKey?(keyId: string, options?: KmsRequestOptions): Promise<{
79
- plaintext: Buffer;
80
- ciphertext: Buffer;
81
- }>;
82
- }
83
- interface KmsRequestOptions {
84
- signal?: AbortSignal;
85
- }
86
- interface SchemaRegistry {
87
- getSchema(subject: string, version?: number): Promise<z.ZodType<any>>;
88
- }
89
- interface EngineConfig {
90
- plugins?: {
91
- name: string;
92
- options?: unknown;
93
- }[];
94
- limits?: Partial<EngineLimits>;
95
- logger?: Logger;
96
- tracer?: Tracer;
97
- auditLogger?: AuditLogger;
98
- /** Optional caller-owned failure sink; `dlq` is retained for compatibility. */
99
- dlq?: Writable;
100
- schema?: z.ZodType<any>;
101
- schemaRegistry?: SchemaRegistry;
102
- }
103
- interface ProcessorContext {
104
- readonly requestId: string;
105
- readonly timestamp: number;
106
- readonly signal?: AbortSignal;
107
- readonly limits?: Readonly<EngineLimits>;
108
- metadata: Record<string, unknown>;
109
- logger?: Logger;
110
- span?: Span;
111
- }
112
- interface ProcessorPlugin {
113
- readonly name: string;
114
- readonly version: string;
115
- readonly reversible?: boolean;
116
- readonly streaming?: boolean;
117
- process(data: Buffer, ctx: ProcessorContext): Promise<Buffer> | Buffer;
118
- reverse?(data: Buffer, ctx: ProcessorContext): Promise<Buffer> | Buffer;
119
- createStream?(mode: 'compress' | 'decompress', context?: StreamPluginContext): Duplex;
120
- retryOptions?: RetryOptions;
121
- }
122
- type PluginOperation = 'process' | 'reverse' | 'stream';
123
- /** Normalized, runtime-validated operations exposed by a plugin. */
124
- interface PluginCapabilities {
125
- readonly process: true;
126
- readonly reverse: boolean;
127
- readonly streaming: boolean;
128
- readonly streamMode: 'native' | 'fallback' | 'none';
129
- }
130
- /** Capability view for a plugin registered with a DataEngine. */
131
- interface RegisteredPluginCapabilities extends PluginCapabilities {
132
- readonly plugin: string;
133
- }
134
- interface EngineResult {
135
- readonly data: Buffer;
136
- readonly originalType: string;
137
- readonly pipeline: string[];
138
- readonly metrics: {
139
- durationMs: number;
140
- steps: Record<string, number>;
141
- };
142
- }
143
- interface PipeXManifest {
144
- readonly __pipex_v: 1;
145
- readonly plugins: string[];
146
- readonly ts: number;
147
- }
148
- declare function isManifest(value: unknown): value is PipeXManifest;
149
- interface EngineEvents {
150
- start: [requestId: string];
151
- 'plugin:after': [name: string, durationMs: number];
152
- progress: [bytes: number, requestId: string];
153
- error: [err: Error, requestId: string];
154
- end: [requestId: string, durationMs: number];
155
- }
156
- //#endregion
157
13
  //#region src/core/frameLimits.d.ts
158
14
  declare function assertMessagePackFrameLimits(input: Buffer | Uint8Array, maxFrameBytes: number, maxFrames?: number): number;
159
15
  declare function buildFrameLimitTransform(maxFrameBytes: number, maxFrames: number): Transform;
@@ -248,251 +104,79 @@ declare function runPipeline(source: Readable, transforms: (Duplex | Transform |
248
104
  declare function assertExists(inputPath: string, allowedRoot?: string): string;
249
105
  declare function resolveOutputPath(outputPath: string, allowedRoot?: string): string;
250
106
  //#endregion
251
- //#region src/core/controllers/FileController.d.ts
252
- declare class FileController {
253
- #private;
254
- constructor(engine: DataEngine);
255
- /**
256
- * Source file → Plugin pipeline (compress) → Destination file.
257
- */
258
- process(inputPath: string, outputPath: string, allowedRoot?: string, options?: OperationOptions): Promise<void>;
107
+ //#region src/core/typedPipeline.d.ts
108
+ /** A synchronous or asynchronous transformation from Input to Output. */
109
+ type TypedTransform<Input, Output> = (input: Input, options: Readonly<OperationOptions>) => Output | Promise<Output>;
110
+ /** Cancellation options for typed application pipelines. */
111
+ type TypedPipelineOptions = Readonly<OperationOptions>;
112
+ /** An immutable pipeline whose input and output types are preserved across steps. */
113
+ declare class TypedPipeline<Input, Output> {
114
+ private readonly transforms;
115
+ private constructor();
259
116
  /**
260
- * Source file → Plugin pipeline (decompress, reversed) → Destination file.
117
+ * Start a pipeline from an initial typed transform.
118
+ * @param transform First transformation; its input type becomes the pipeline input.
261
119
  */
262
- reverse(inputPath: string, outputPath: string, allowedRoot?: string, options?: OperationOptions): Promise<void>;
120
+ static from<Input, Output>(transform: TypedTransform<Input, Output>): TypedPipeline<Input, Awaited<Output>>;
263
121
  /**
264
- * Source file → PackrStream → manifest header → Destination msgpack file.
265
- *
266
- * Output format: [ PipeXManifest frame ][ ...data frames ]
267
- * The serialization-only manifest declares an empty plugin chain.
122
+ * Append a transform. Its input must accept this pipeline's current output.
123
+ * The returned pipeline infers the appended asynchronous or synchronous output.
268
124
  */
269
- pack(inputPath: string, outputPath: string, allowedRoot?: string, options?: OperationOptions): Promise<void>;
270
- /**
271
- * Source msgpack file → UnpackrStream → manifest extraction → NDJSON → Destination file.
272
- *
273
- * Fires 'manifest' event with the recovered PipeXManifest before streaming data.
274
- */
275
- unpack(inputPath: string, outputPath: string, allowedRoot?: string, options?: OperationOptions): Promise<void>;
276
- }
277
- //#endregion
278
- //#region src/core/controllers/BinaryController.d.ts
279
- declare class BinaryController {
280
- #private;
281
- constructor(engine: DataEngine);
282
- /**
283
- * Serialise a supported JS value to a msgpack Buffer (synchronous).
284
- * For streaming large datasets use engine.stream or engine.file.pack instead.
285
- */
286
- pack(data: unknown): Buffer;
287
- /**
288
- * Deserialise a msgpack Buffer back to T (synchronous).
289
- */
290
- unpack<T = unknown>(input: Buffer | Uint8Array): T;
291
- run(input: unknown, options?: OperationOptions): Promise<EngineResult>;
292
- undo<T = unknown>(result: EngineResult, options?: BinaryUndoOptions): Promise<T>;
293
- undo<T = unknown>(input: Buffer, forceType: string, options?: OperationOptions): Promise<T>;
294
- /**
295
- * Pack data AND embed a manifest header as the first msgpack frame.
296
- * Mirrors what file.pack writes to disk — useful for in-memory transport.
297
- */
298
- packWithManifest(data: unknown): Buffer;
299
- /**
300
- * Unpack a buffer that begins with a PipeXManifest frame.
301
- * Returns { manifest, data } — callers can inspect the manifest to verify
302
- * the pipeline that produced the buffer before consuming data.
303
- */
304
- unpackWithManifest<T = unknown>(input: Buffer): {
305
- manifest: PipeXManifest;
306
- data: T;
307
- };
308
- }
309
- //#endregion
310
- //#region src/core/controllers/StreamController.d.ts
311
- declare class StreamController {
312
- #private;
313
- constructor(engine: DataEngine);
314
- /**
315
- * Returns a Writable that pumps incoming bytes through the plugin pipeline
316
- * (compress direction) and forwards them to `destination`.
317
- *
318
- * @example
319
- * readableSource.pipe(engine.stream.into(createWriteStream('out')));
320
- */
321
- into(destination: Writable, options?: OperationOptions): Writable;
322
- /**
323
- * Returns a Writable that pumps bytes through the reversed plugin pipeline
324
- * (decompress direction) and forwards to `destination`.
325
- *
326
- * @example
327
- * readableSource.pipe(engine.stream.reverseInto(createWriteStream('restored')));
328
- */
329
- reverseInto(destination: Writable, options?: OperationOptions): Writable;
330
- /**
331
- * Returns a PackrStream: write JS objects, read msgpack bytes.
332
- * A manifest header frame is prepended automatically.
333
- *
334
- * @example
335
- * objectSource.pipe(engine.stream.pack()).pipe(tcpSocket);
336
- */
337
- pack(options?: OperationOptions): Duplex;
338
- /**
339
- * Returns a GuardedUnpackrStream: write msgpack bytes, read JS objects.
340
- * Fires the engine's 'manifest' event when the header frame is detected.
341
- *
342
- * @example
343
- * tcpSocket.pipe(engine.stream.unpack()).on('data', obj => console.log(obj));
344
- */
345
- unpack(options?: OperationOptions): Duplex;
346
- /**
347
- * Orchestrate a complete pipeline: Readable → plugin chain → Writable.
348
- * This is the primary low-level entry point — file/binary controllers
349
- * build on top of this.
350
- *
351
- * @example
352
- * await engine.stream.pipe(
353
- * createReadStream('input.bin'),
354
- * createWriteStream('output.bin'),
355
- * );
356
- */
357
- pipe(source: Readable, destination: Writable, reverse?: boolean, options?: OperationOptions): Promise<void>;
358
- }
359
- //#endregion
360
- //#region src/core/dataEngine.d.ts
361
- interface PipeXEventMap {
362
- start: [requestId: string];
363
- 'plugin:after': [name: string, durationMs: number];
364
- progress: [bytes: number, requestId: string];
365
- error: [err: Error, requestId: string];
366
- end: [requestId: string, durationMs?: number];
367
- manifest: [manifest: unknown, requestId?: string];
368
- }
369
- type PluginConstructor<TOptions = unknown> = new (options: TOptions) => ProcessorPlugin;
370
- declare class DataEngine extends EventEmitter {
371
- #private;
372
- /** Built-in plugin registry for config-driven bootstrap. */
373
- private static readonly pluginRegistry;
374
- /** Register a plugin class for use in fromConfig(). */
375
- static registerPlugin<TOptions>(name: string, pluginClass: PluginConstructor<TOptions>): void;
376
- /**
377
- * Bootstrap a DataEngine from a configuration object.
378
- */
379
- static fromConfig(config: EngineConfig): Promise<DataEngine>;
380
- readonly file: FileController;
381
- readonly binary: BinaryController;
382
- readonly stream: StreamController;
383
- constructor(limits?: Partial<EngineLimits>);
384
- get limits(): Readonly<EngineLimits>;
385
- setLimits(limits: Partial<EngineLimits>): this;
386
- createOperationSignal(options?: OperationOptions): AbortSignal;
387
- /**
388
- * Set the optional, caller-owned failure sink (legacy DLQ terminology).
389
- * A failed fallback-transform chunk is written after retries are exhausted;
390
- * the operation still rejects. PipeX does not persist, replay, end, or own
391
- * the supplied Writable.
392
- *
393
- * @param stream The caller-provided Writable used as a failure sink.
394
- */
395
- setDlq(stream: Writable): this;
396
- /** The current caller-provided failure sink, if any. */
397
- get dlq(): Writable | undefined;
398
- /**
399
- * Set the engine's logger for structured observability.
400
- * Compatible with Pino, Winston, or any logger implementing the Logger interface.
401
- *
402
- * @param logger The logger instance.
403
- */
404
- setLogger(logger: Logger): this;
405
- /** The current logger instance. */
406
- get logger(): Logger | undefined;
407
- /**
408
- * Set the engine's tracer for OpenTelemetry-compatible tracing.
409
- *
410
- * @param tracer The tracer instance.
411
- */
412
- setTracer(tracer: Tracer): this;
413
- /** The current tracer instance. */
414
- get tracer(): Tracer | undefined;
415
- /**
416
- * Set the engine's audit logger for compliance and security auditing.
417
- *
418
- * @param logger The audit logger instance.
419
- */
420
- setAuditLogger(logger: AuditLogger): this;
421
- /**
422
- * Emits an audit record if an audit logger is configured.
423
- * This is called automatically by controllers.
424
- *
425
- * @param record The audit record metadata.
426
- */
427
- emitAudit(record: Omit<AuditRecord, 'pluginChain' | 'timestamp'>): Promise<void>;
428
- /**
429
- * Set a Schema Registry to fetch schemas dynamically.
430
- *
431
- * @param registry The schema registry provider.
432
- */
433
- setSchemaRegistry(registry: SchemaRegistry): this;
434
- /**
435
- * Fetch a schema from the registry and set it as the engine's active schema.
436
- *
437
- * @param subject The name of the schema to fetch.
438
- * @param version Optional version of the schema.
439
- */
440
- loadSchema(subject: string, version?: number): Promise<void>;
441
- /**
442
- * Set a global Zod schema for input/output validation.
443
- * When set, controllers will automatically validate data against this schema.
444
- */
445
- setSchema(schema: z.ZodType<any>): this;
446
- get schema(): z.ZodType<any> | undefined;
447
- /** Validates data against the registered schema (if any). Throws on failure. */
448
- validate(data: unknown): void;
449
- /** Register a plugin and return this for fluent chaining. */
450
- use(plugin: ProcessorPlugin): this;
451
- /**
452
- * Read-only view of the registered plugins.
453
- * Exposed so controllers can iterate without mutating the list.
454
- */
455
- get plugins(): readonly ProcessorPlugin[];
456
- /** Human-readable plugin identifiers in execution order. */
457
- get pipeline(): readonly string[];
458
- /** Runtime-validated capabilities in pipeline order. */
459
- get pluginCapabilities(): readonly Readonly<RegisteredPluginCapabilities>[];
460
- /** Generates a requestId, emits 'start', returns the id. */
461
- startRequest(metadata?: Record<string, unknown>): string;
462
- /** Keep capacity reserved for accepted non-cooperative work after caller cancellation. */
463
- trackWork(requestId: string, pending: Promise<unknown>): void;
464
- /** Idempotent cleanup, including error paths that fail before transformation starts. */
465
- releaseRequest(requestId: string): void;
466
- /** Emits 'end' with optional duration. */
467
- endRequest(requestId: string, durationMs?: number): void;
468
- /** Emits 'progress'. */
469
- emitProgress(bytes: number, requestId: string): void;
470
- /** Normalises unknown throws → Error and emits 'error'. */
471
- emitError(err: unknown, requestId: string): void;
472
- emit<K extends keyof PipeXEventMap>(event: K, ...args: PipeXEventMap[K]): boolean;
473
- on<K extends keyof PipeXEventMap>(event: K, listener: (...args: PipeXEventMap[K]) => void): this;
474
- once<K extends keyof PipeXEventMap>(event: K, listener: (...args: PipeXEventMap[K]) => void): this;
475
- }
476
- //#endregion
477
- //#region src/core/plugin.d.ts
478
- declare abstract class BasePlugin implements ProcessorPlugin {
479
- protected options: any;
480
- abstract readonly name: string;
481
- abstract readonly version: string;
482
- retryOptions?: RetryOptions;
483
- get reversible(): boolean;
484
- constructor(options?: any);
485
- abstract process(data: Buffer, context: ProcessorContext): Promise<Buffer> | Buffer;
486
- /** Unsupported by default. Subclasses must implement reverse explicitly. */
487
- reverse(_data: Buffer, _context: ProcessorContext): Promise<Buffer> | Buffer;
125
+ pipe<Next>(transform: TypedTransform<Output, Next>): TypedPipeline<Input, Awaited<Next>>;
126
+ /** Execute all transforms in order, honouring cancellation between awaits. */
127
+ run(input: Input, options?: TypedPipelineOptions): Promise<Output>;
488
128
  }
129
+ /** Create a typed pipeline with automatic end-to-end transform inference. */
130
+ declare function typedPipeline<Input, Output>(first: TypedTransform<Input, Output>): TypedPipeline<Input, Awaited<Output>>;
489
131
  //#endregion
490
132
  //#region src/core/errors.d.ts
491
- type PipeXErrorCode = 'UNSUPPORTED_REVERSE' | 'UNSUPPORTED_STREAMING' | 'INVALID_PLUGIN_CAPABILITY' | 'OPERATION_ABORTED' | 'OPERATION_TIMEOUT' | 'KMS_PROVIDER_FAILURE' | 'KMS_AUTHENTICATION_FAILED' | 'KMS_PROVIDER_AUTHENTICATION_FAILED' | 'KMS_PROVIDER_UNAVAILABLE' | 'UNSUPPORTED_KMS_OPERATION' | 'INVALID_KMS_PROVIDER_CAPABILITY' | 'WORKER_POOL_CLOSED' | 'WORKER_QUEUE_FULL' | 'WORKER_POOL_CLOSE_FAILURE' | 'WORKER_TASK_FAILURE';
133
+ type PipeXErrorCode = 'VALIDATION_FAILED' | 'COMPRESSION_FAILED' | 'HASHING_FAILED' | 'UNSUPPORTED_ALGORITHM' | 'UNSUPPORTED_REVERSE' | 'UNSUPPORTED_STREAMING' | 'INVALID_PLUGIN_CAPABILITY' | 'ENCRYPTION_ERROR' | 'INVALID_ENCRYPTION_KEY' | 'ENCRYPTION_AUTHENTICATION_FAILED' | 'OPERATION_ABORTED' | 'OPERATION_TIMEOUT' | 'KMS_PROVIDER_FAILURE' | 'KMS_AUTHENTICATION_FAILED' | 'KMS_PROVIDER_AUTHENTICATION_FAILED' | 'KMS_PROVIDER_UNAVAILABLE' | 'UNSUPPORTED_KMS_OPERATION' | 'INVALID_KMS_PROVIDER_CAPABILITY' | 'WORKER_POOL_CLOSED' | 'WORKER_QUEUE_FULL' | 'WORKER_POOL_CLOSE_FAILURE' | 'WORKER_TASK_FAILURE';
492
134
  declare class PipeXError extends Error {
493
135
  readonly code: PipeXErrorCode;
494
136
  readonly name: string;
495
- constructor(code: PipeXErrorCode, message: string, options?: ErrorOptions);
137
+ readonly transformName?: string;
138
+ readonly stage?: string;
139
+ constructor(code: PipeXErrorCode, message: string, options?: ErrorOptions & {
140
+ transformName?: string;
141
+ stage?: string;
142
+ });
143
+ }
144
+ /** Domain failures use fixed, non-sensitive messages. Never include input, keys or arbitrary provider errors. */
145
+ declare class ValidationError extends PipeXError {
146
+ readonly name = "ValidationError";
147
+ constructor(options?: ErrorOptions & {
148
+ transformName?: string;
149
+ stage?: string;
150
+ });
151
+ }
152
+ declare class CompressionError extends PipeXError {
153
+ readonly name = "CompressionError";
154
+ constructor(options?: ErrorOptions & {
155
+ transformName?: string;
156
+ stage?: string;
157
+ });
158
+ }
159
+ declare class HashingError extends PipeXError {
160
+ readonly name = "HashingError";
161
+ constructor(options?: ErrorOptions & {
162
+ transformName?: string;
163
+ stage?: string;
164
+ });
165
+ }
166
+ declare class UnsupportedAlgorithmError extends PipeXError {
167
+ readonly name = "UnsupportedAlgorithmError";
168
+ constructor(options?: ErrorOptions & {
169
+ transformName?: string;
170
+ stage?: string;
171
+ });
172
+ }
173
+ /** Alias hierarchy: existing OperationAbortedError retains its code and instanceof contract. */
174
+ declare class PipelineAbortedError extends PipeXError {
175
+ readonly name: string;
176
+ constructor(options?: ErrorOptions & {
177
+ transformName?: string;
178
+ stage?: string;
179
+ });
496
180
  }
497
181
  declare class UnsupportedReverseError extends PipeXError {
498
182
  readonly plugin: string;
@@ -512,7 +196,7 @@ declare class InvalidPluginCapabilityError extends PipeXError {
512
196
  readonly name: string;
513
197
  constructor(plugin: string, capability: 'reversible' | 'streaming', issue: InvalidPluginCapabilityIssue);
514
198
  }
515
- declare class OperationAbortedError extends PipeXError {
199
+ declare class OperationAbortedError extends PipelineAbortedError {
516
200
  readonly name: string;
517
201
  constructor(options?: ErrorOptions);
518
202
  }
@@ -569,6 +253,19 @@ declare class WorkerTaskError extends PipeXError {
569
253
  readonly name: string;
570
254
  constructor(taskName: string, options?: ErrorOptions);
571
255
  }
256
+ /** Public cryptographic failure categories; never include keys or ciphertext in messages. */
257
+ declare class EncryptionError extends PipeXError {
258
+ readonly name: string;
259
+ constructor(message?: string);
260
+ }
261
+ declare class InvalidKeyError extends PipeXError {
262
+ readonly name: string;
263
+ constructor();
264
+ }
265
+ declare class AuthenticationError extends PipeXError {
266
+ readonly name: string;
267
+ constructor();
268
+ }
572
269
  //#endregion
573
270
  //#region src/core/kmsCapabilities.d.ts
574
271
  /**
@@ -579,78 +276,6 @@ declare class WorkerTaskError extends PipeXError {
579
276
  declare function getKmsProviderCapabilities(provider: KmsProvider): Readonly<KmsProviderCapabilities>;
580
277
  declare function supportsKmsOperation(provider: KmsProvider, operation: KmsOperation): boolean;
581
278
  //#endregion
582
- //#region src/plugin/hashing.d.ts
583
- type HashAlgorithm = 'sha256' | 'sha512';
584
- interface HashingOptions {
585
- algorithm: HashAlgorithm;
586
- secret: string;
587
- }
588
- /**
589
- * HashingPlugin — Standard library plugin for HMAC integrity checks.
590
- * Appends a digest to the end of the buffer/stream.
591
- */
592
- declare class HashingPlugin extends BasePlugin {
593
- protected options: HashingOptions;
594
- readonly name = "hashing";
595
- readonly version = "3.0.0";
596
- constructor(options: HashingOptions);
597
- process(data: Buffer, context: ProcessorContext): Promise<Buffer>;
598
- reverse(data: Buffer, context: ProcessorContext): Promise<Buffer>;
599
- createStream(mode: 'compress' | 'decompress', context?: StreamPluginContext): Transform;
600
- }
601
- //#endregion
602
- //#region src/plugin/encryptionFormat.d.ts
603
- type EncryptionAlgorithm = 'aes-256-gcm' | 'chacha20-poly1305';
604
- interface EncryptionFormatOptions {
605
- readonly algorithm: EncryptionAlgorithm;
606
- readonly key: Buffer;
607
- readonly frameSizeBytes?: number;
608
- readonly allowLegacyDecrypt?: boolean;
609
- }
610
- //#endregion
611
- //#region src/plugin/encryption.d.ts
612
- interface EncryptionOptions extends EncryptionFormatOptions {
613
- /** Maximum plaintext bytes in each authenticated frame. Defaults to 64 KiB. */
614
- frameSizeBytes?: number;
615
- /** Temporarily accept the unversioned v3 format while migrating. Defaults to true. */
616
- allowLegacyDecrypt?: boolean;
617
- }
618
- /**
619
- * Authenticated, bounded-memory stream encryption.
620
- *
621
- * Version 4 writes the versioned PXAE framed format. The legacy unversioned
622
- * format remains readable by default for migration, but is never written.
623
- */
624
- declare class EncryptionPlugin extends BasePlugin {
625
- protected options: EncryptionOptions;
626
- readonly name = "encryption";
627
- readonly version = "4.0.0";
628
- constructor(options: EncryptionOptions);
629
- process(data: Buffer, context: ProcessorContext): Promise<Buffer>;
630
- reverse(data: Buffer, context: ProcessorContext): Promise<Buffer>;
631
- createStream(mode: 'compress' | 'decompress', context?: StreamPluginContext): Transform;
632
- }
633
- //#endregion
634
- //#region src/plugin/compression.d.ts
635
- type CompressionType = 'gzip' | 'brotli' | 'none';
636
- interface CompressionOptions {
637
- type: CompressionType;
638
- level?: number;
639
- }
640
- /**
641
- * CompressionPlugin — Standard library plugin for Gzip and Brotli.
642
- * Prepends a 1-byte header to identify the compression type.
643
- */
644
- declare class CompressionPlugin extends BasePlugin {
645
- protected options: CompressionOptions;
646
- readonly name = "compression";
647
- readonly version = "3.0.0";
648
- constructor(options: CompressionOptions);
649
- process(data: Buffer, ctx: ProcessorContext): Promise<Buffer>;
650
- reverse(data: Buffer, ctx: ProcessorContext): Promise<Buffer>;
651
- createStream(mode: 'compress' | 'decompress', context?: StreamPluginContext): Duplex;
652
- }
653
- //#endregion
654
279
  //#region src/plugin/performance.d.ts
655
280
  /**
656
281
  * BenchmarkPlugin — Standard library plugin for monitoring data throughput.
@@ -663,93 +288,6 @@ declare class BenchmarkPlugin extends BasePlugin {
663
288
  reverse(data: Buffer, ctx: ProcessorContext): Promise<Buffer>;
664
289
  }
665
290
  //#endregion
666
- //#region src/plugin/worker.d.ts
667
- interface WorkerPoolOptions {
668
- /** Absolute path or file URL to a caller-owned ESM/CJS worker module. */
669
- filename: string | URL;
670
- /** Export used for forward processing. Omit to use the worker's default export. */
671
- processName?: string;
672
- /** Export used for reverse processing. When omitted, reverse is unsupported. */
673
- reverseName?: string;
674
- maxThreads?: number;
675
- /** Maximum queued tasks. Defaults to 64. */
676
- maxQueue?: number;
677
- /** Per-task timeout in milliseconds. Zero disables the plugin-level timeout. */
678
- taskTimeoutMs?: number;
679
- /** Grace period used by Piscina when closing the pool. Defaults to 30 seconds. */
680
- closeTimeoutMs?: number;
681
- }
682
- /** Runs caller-owned CPU transforms in a bounded, persistent Piscina pool. */
683
- declare class WorkerPoolPlugin extends BasePlugin {
684
- #private;
685
- readonly name = "worker-pool";
686
- readonly version = "5.0.0";
687
- constructor(options: WorkerPoolOptions);
688
- get reversible(): boolean;
689
- process(data: Buffer, ctx: ProcessorContext): Promise<Buffer>;
690
- reverse(data: Buffer, ctx: ProcessorContext): Promise<Buffer>;
691
- createStream(mode: 'compress' | 'decompress', context?: StreamPluginContext): Transform;
692
- /** Rejects new tasks and waits for queued/running work unless force is true. */
693
- close(options?: {
694
- force?: boolean;
695
- }): Promise<void>;
696
- }
697
- //#endregion
698
- //#region src/core/validation.d.ts
699
- interface ValidationOptions {
700
- schema: z.ZodType<any>;
701
- /**
702
- * Whether to validate during the reverse (decompress) phase.
703
- * Useful if you want to ensure the restored data still matches the schema.
704
- */
705
- validateOnReverse?: boolean;
706
- }
707
- /**
708
- * ValidationPlugin — Core plugin for schema-based data validation.
709
- * Uses Zod to verify the structure of the data passing through the engine.
710
- *
711
- * Note: This plugin assumes the data is MsgPack-encoded (default PipeX behavior).
712
- */
713
- declare class ValidationPlugin extends BasePlugin {
714
- protected options: ValidationOptions;
715
- readonly name = "validation";
716
- readonly version = "1.0.0";
717
- constructor(options: ValidationOptions);
718
- process(data: Buffer, ctx: ProcessorContext): Promise<Buffer>;
719
- reverse(data: Buffer, ctx: ProcessorContext): Promise<Buffer>;
720
- private validate;
721
- createStream(mode?: 'compress' | 'decompress', context?: StreamPluginContext): Transform;
722
- }
723
- //#endregion
724
- //#region src/plugin/kms_encryption.d.ts
725
- interface KmsEncryptionOptions {
726
- kms: KmsProvider;
727
- keyId: string;
728
- /** Temporarily accept the unversioned v1 envelope while migrating. Defaults to true. */
729
- allowLegacyDecrypt?: boolean;
730
- }
731
- /**
732
- * KmsEncryptionPlugin — Enterprise-grade encryption using Envelope Encryption.
733
- *
734
- * 1. Generate a data key via KMS.
735
- * 2. Encrypt data locally using the plaintext data key.
736
- * 3. Prepend the encrypted data key (ciphertext) to the payload.
737
- *
738
- * Packet format: [PXKM][version][algorithm][flags][key_len][ciphertext_len]
739
- * [12B IV][Encrypted Data Key][Ciphertext][16B Tag]
740
- */
741
- declare class KmsEncryptionPlugin extends BasePlugin {
742
- protected options: KmsEncryptionOptions;
743
- readonly name = "kms-encryption";
744
- readonly version = "2.1.0";
745
- readonly streaming = false;
746
- get providerCapabilities(): Readonly<KmsProviderCapabilities>;
747
- get reversible(): boolean;
748
- constructor(options: KmsEncryptionOptions);
749
- process(data: Buffer, ctx: ProcessorContext): Promise<Buffer>;
750
- reverse(data: Buffer, ctx: ProcessorContext): Promise<Buffer>;
751
- }
752
- //#endregion
753
291
  //#region src/index.d.ts
754
292
  declare const Plugins: {
755
293
  readonly Hashing: typeof HashingPlugin;
@@ -761,5 +299,4 @@ declare const Plugins: {
761
299
  readonly KmsEncryption: typeof KmsEncryptionPlugin;
762
300
  };
763
301
  //#endregion
764
- export { type AuditLogger, type AuditRecord, BasePlugin, BenchmarkPlugin, type BinaryUndoOptions, type CompressionOptions, CompressionPlugin, type CompressionType, DEFAULT_HIGH_WATER, DEFAULT_LIMITS, DataEngine, type EncryptionAlgorithm, type EncryptionOptions, EncryptionPlugin, type EngineConfig, type EngineEvents, type EngineLimits, type EngineResult, GuardedUnpackrStream, type HashAlgorithm, type HashingOptions, HashingPlugin, InvalidKmsProviderCapabilityError, type InvalidKmsProviderCapabilityIssue, InvalidPluginCapabilityError, type InvalidPluginCapabilityIssue, KmsAuthenticationError, type KmsEncryptionOptions, KmsEncryptionPlugin, type KmsOperation, type KmsProvider, KmsProviderAuthenticationError, type KmsProviderCapabilities, KmsProviderError, KmsProviderUnavailableError, type KmsRequestOptions, type Logger, MAX_FRAME_BYTES, ORIGINAL_TYPES, OperationAbortedError, type OperationOptions, OperationTimeoutError, PACKR, PIPEX_MANIFEST_KEY, PipeXError, type PipeXErrorCode, type PipeXManifest, type PluginCapabilities, type PluginConstructor, type PluginOperation, Plugins, type ProcessorContext, type ProcessorPlugin, type RegisteredPluginCapabilities, type RetryOptions, type SchemaRegistry, type Span, type StreamPluginContext, type Tracer, UNPACKR, UnsupportedKmsOperationError, UnsupportedReverseError, UnsupportedStreamingError, type ValidationOptions, ValidationPlugin, WorkerPoolCloseError, WorkerPoolClosedError, type WorkerPoolOptions, WorkerPoolPlugin, WorkerQueueFullError, WorkerTaskError, assertExists, assertKnownValueByteLimit, assertMessagePackFrameLimits, assertOriginalType, assertReversiblePipeline, assertStreamingPipeline, buildByteLimitTransform, buildFallbackTransform, buildFrameLimitTransform, buildKnownValueByteLimitTransform, buildManifest, buildManifestExtractTransform, buildManifestHeaderTransform, buildNdjsonTransform, buildObjectLimitTransform, buildTransformChain, createPackrStream, createUnpackrStream, detectType, fromBuffer, getKmsProviderCapabilities, getPluginCapabilities, hasStreamSupport, isManifest, makeContext, resolveOutputPath, runPipeline, supportsKmsOperation, supportsOperation, supportsReverse, toBuffer, withRetry };
765
- //# sourceMappingURL=index.d.mts.map
302
+ export { type AuditLogger, type AuditRecord, AuthenticationError, BasePlugin, BenchmarkPlugin, type BinaryUndoOptions, CompressionError, type CompressionOptions, CompressionPlugin, type CompressionType, DEFAULT_HIGH_WATER, DEFAULT_LIMITS, DataEngine, type EncryptionAlgorithm, EncryptionError, type EncryptionOptions, EncryptionPlugin, type EngineConfig, type EngineEvents, type EngineLimits, type EngineResult, GuardedUnpackrStream, type HashAlgorithm, HashingError, type HashingOptions, HashingPlugin, InvalidKeyError, InvalidKmsProviderCapabilityError, type InvalidKmsProviderCapabilityIssue, InvalidPluginCapabilityError, type InvalidPluginCapabilityIssue, KmsAuthenticationError, type KmsEncryptionOptions, KmsEncryptionPlugin, type KmsOperation, type KmsProvider, KmsProviderAuthenticationError, type KmsProviderCapabilities, KmsProviderError, KmsProviderUnavailableError, type KmsRequestOptions, type Logger, MAX_FRAME_BYTES, ORIGINAL_TYPES, OperationAbortedError, type OperationOptions, OperationTimeoutError, PACKR, PIPEX_MANIFEST_KEY, PipeXError, type PipeXErrorCode, type PipeXManifest, PipelineAbortedError, type PluginCapabilities, type PluginConstructor, type PluginOperation, Plugins, type ProcessorContext, type ProcessorPlugin, type RegisteredPluginCapabilities, type RetryOptions, type SchemaRegistry, type Span, type StreamPluginContext, type Tracer, TypedPipeline, type TypedPipelineOptions, type TypedTransform, UNPACKR, UnsupportedAlgorithmError, UnsupportedKmsOperationError, UnsupportedReverseError, UnsupportedStreamingError, ValidationError, type ValidationOptions, ValidationPlugin, WorkerPoolCloseError, WorkerPoolClosedError, type WorkerPoolOptions, WorkerPoolPlugin, WorkerQueueFullError, WorkerTaskError, assertExists, assertKnownValueByteLimit, assertMessagePackFrameLimits, assertOriginalType, assertReversiblePipeline, assertStreamingPipeline, buildByteLimitTransform, buildFallbackTransform, buildFrameLimitTransform, buildKnownValueByteLimitTransform, buildManifest, buildManifestExtractTransform, buildManifestHeaderTransform, buildNdjsonTransform, buildObjectLimitTransform, buildTransformChain, createPackrStream, createUnpackrStream, detectType, fromBuffer, getKmsProviderCapabilities, getPluginCapabilities, hasStreamSupport, isManifest, makeContext, resolveOutputPath, runPipeline, supportsKmsOperation, supportsOperation, supportsReverse, toBuffer, typedPipeline, withRetry };