@snyxex/pipex 1.0.2 → 1.0.4
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/CHANGELOG.md +6 -0
- package/LICENSE +1 -1
- package/README.md +238 -139
- package/dist/compression-B0xKUa-N.d.mts +35 -0
- package/dist/compression-C1nLQVur.d.cts +35 -0
- package/dist/compression-ChJlMVwP.mjs +1 -0
- package/dist/compression-ZHOsKTJC.cjs +1 -0
- package/dist/compression.cjs +1 -0
- package/dist/compression.d.cts +2 -0
- package/dist/compression.d.mts +2 -0
- package/dist/compression.mjs +1 -0
- package/dist/core-DNchiRD5.mjs +2 -0
- package/dist/core-DSIwvTqu.cjs +2 -0
- package/dist/dataEngine-6R3J-WtS.cjs +1 -0
- package/dist/dataEngine-C-xYat2f.d.cts +223 -0
- package/dist/dataEngine-Zap1RwAJ.d.mts +223 -0
- package/dist/dataEngine-raQdutX5.mjs +1 -0
- package/dist/encryption-CCPoyX4q.d.cts +39 -0
- package/dist/encryption-CHvy--rb.mjs +1 -0
- package/dist/encryption-D4eC9ubl.d.mts +39 -0
- package/dist/encryption-DwdO7Y4J.cjs +1 -0
- package/dist/encryption.cjs +1 -0
- package/dist/encryption.d.cts +2 -0
- package/dist/encryption.d.mts +2 -0
- package/dist/encryption.mjs +1 -0
- package/dist/hashing-C6TkcsUE.d.cts +30 -0
- package/dist/hashing-CEwtXh2V.d.mts +30 -0
- package/dist/hashing-DF_guuZf.cjs +1 -0
- package/dist/hashing-DU3rmGMP.mjs +1 -0
- package/dist/hashing.cjs +1 -0
- package/dist/hashing.d.cts +2 -0
- package/dist/hashing.d.mts +2 -0
- package/dist/hashing.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +285 -0
- package/dist/index.d.mts +143 -623
- package/dist/index.mjs +1 -3
- package/dist/kms.cjs +1 -0
- package/dist/kms.d.cts +3 -0
- package/dist/kms.d.mts +3 -0
- package/dist/kms.mjs +1 -0
- package/dist/kms_encryption-1G54Lcuo.mjs +1 -0
- package/dist/kms_encryption-B07lunjB.cjs +1 -0
- package/dist/kms_encryption-BBIHGi_O.d.cts +30 -0
- package/dist/kms_encryption-BbtS7rXa.d.mts +30 -0
- package/dist/native.cjs +1 -0
- package/dist/native.d.cts +2 -0
- package/dist/native.d.mts +2 -0
- package/dist/native.mjs +1 -0
- package/dist/parallel.cjs +1 -0
- package/dist/parallel.d.cts +2 -0
- package/dist/parallel.d.mts +2 -0
- package/dist/parallel.mjs +1 -0
- package/dist/plugin-D85NMNiy.d.mts +13 -0
- package/dist/plugin-c_iSNY86.d.cts +13 -0
- package/dist/resourceLimits-CpDWwraK.mjs +1 -0
- package/dist/resourceLimits-lJrEhDE5.cjs +1 -0
- package/dist/types-B50Urzn2.d.cts +152 -0
- package/dist/types-B50Urzn2.d.mts +152 -0
- package/dist/validation-BgdV4KdW.cjs +1 -0
- package/dist/validation-BkJxOs7q.mjs +1 -0
- package/dist/validation-hcvcixaS.d.cts +29 -0
- package/dist/validation-xIBvnsSH.d.mts +29 -0
- package/dist/validation.cjs +1 -0
- package/dist/validation.d.cts +2 -0
- package/dist/validation.d.mts +2 -0
- package/dist/validation.mjs +1 -0
- package/dist/worker-1Q2hRcRB.cjs +1 -0
- package/dist/worker-DT7RYWwo.d.cts +34 -0
- package/dist/worker-iSO3KhfN.d.mts +34 -0
- package/dist/worker-ul8lQ0SH.mjs +1 -0
- package/package.json +128 -31
- package/SECURITY.md +0 -41
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/docs/architecture.md +0 -124
- package/docs/encryption-v4-migration.md +0 -45
- package/docs/enterprise.md +0 -280
package/dist/index.d.mts
CHANGED
|
@@ -1,757 +1,279 @@
|
|
|
1
1
|
import { Duplex, Readable, Transform, TransformCallback, Writable } from "node:stream";
|
|
2
2
|
import { Packr, PackrStream, Unpackr, UnpackrStream } from "msgpackr";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
//#region src/core/frameLimits.d.ts
|
|
158
|
-
declare function assertMessagePackFrameLimits(input: Buffer | Uint8Array, maxFrameBytes: number, maxFrames?: number): number;
|
|
159
|
-
declare function buildFrameLimitTransform(maxFrameBytes: number, maxFrames: number): Transform;
|
|
160
|
-
//#endregion
|
|
161
|
-
//#region src/core/resourceLimits.d.ts
|
|
162
|
-
declare const DEFAULT_LIMITS: Readonly<EngineLimits>;
|
|
163
|
-
//#endregion
|
|
164
|
-
//#region src/core/core.d.ts
|
|
3
|
+
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-B50Urzn2.mjs";
|
|
4
|
+
import { n as PluginConstructor, t as DataEngine } from "./dataEngine-Zap1RwAJ.mjs";
|
|
5
|
+
import { t as BasePlugin } from "./plugin-D85NMNiy.mjs";
|
|
6
|
+
import { n as HashingOptions, r as HashingPlugin, t as HashAlgorithm } from "./hashing-CEwtXh2V.mjs";
|
|
7
|
+
import { a as EncryptionPlugin, i as EncryptionOptions, o as EncryptionAlgorithm } from "./encryption-D4eC9ubl.mjs";
|
|
8
|
+
import { i as CompressionType, n as CompressionOptions, r as CompressionPlugin } from "./compression-B0xKUa-N.mjs";
|
|
9
|
+
import { n as WorkerPoolPlugin, t as WorkerPoolOptions } from "./worker-iSO3KhfN.mjs";
|
|
10
|
+
import { n as ValidationPlugin, t as ValidationOptions } from "./validation-xIBvnsSH.mjs";
|
|
11
|
+
import { n as KmsEncryptionPlugin, t as KmsEncryptionOptions } from "./kms_encryption-BbtS7rXa.mjs";
|
|
12
|
+
export declare function assertMessagePackFrameLimits(input: Buffer | Uint8Array, maxFrameBytes: number, maxFrames?: number): number;
|
|
13
|
+
export declare function buildFrameLimitTransform(maxFrameBytes: number, maxFrames: number): Transform;
|
|
14
|
+
export declare const DEFAULT_LIMITS: Readonly<EngineLimits>;
|
|
165
15
|
/**
|
|
166
16
|
* Executes a function with automatic retries and backoff.
|
|
167
17
|
*/
|
|
168
|
-
declare function withRetry<T>(fn: () => Promise<T> | T, options?: RetryOptions, logger?: Logger, control?: {
|
|
18
|
+
export declare function withRetry<T>(fn: () => Promise<T> | T, options?: RetryOptions, logger?: Logger, control?: {
|
|
169
19
|
signal?: AbortSignal;
|
|
170
20
|
limits?: Pick<EngineLimits, 'maxRetryAttempts' | 'maxRetryDelayMs'>;
|
|
171
21
|
track?: (pending: Promise<unknown>) => void;
|
|
172
22
|
}): Promise<T>;
|
|
173
|
-
declare const PIPEX_MANIFEST_KEY:
|
|
174
|
-
declare const PACKR: Packr;
|
|
175
|
-
declare const UNPACKR: Unpackr;
|
|
23
|
+
export declare const PIPEX_MANIFEST_KEY: '__pipex_v';
|
|
24
|
+
export declare const PACKR: Packr;
|
|
25
|
+
export declare const UNPACKR: Unpackr;
|
|
176
26
|
/** @deprecated Use `DEFAULT_LIMITS.maxFrameBytes` or an engine-specific limit. */
|
|
177
|
-
declare const MAX_FRAME_BYTES: number;
|
|
178
|
-
declare const DEFAULT_HIGH_WATER: number;
|
|
27
|
+
export declare const MAX_FRAME_BYTES: number;
|
|
28
|
+
export declare const DEFAULT_HIGH_WATER: number;
|
|
179
29
|
type PluginWithStream = ProcessorPlugin & {
|
|
180
30
|
createStream(mode: 'compress' | 'decompress', context?: StreamPluginContext): Duplex;
|
|
181
31
|
};
|
|
182
|
-
declare function hasStreamSupport(p: ProcessorPlugin): p is PluginWithStream;
|
|
32
|
+
export declare function hasStreamSupport(p: ProcessorPlugin): p is PluginWithStream;
|
|
183
33
|
/**
|
|
184
34
|
* Returns the effective capabilities of a plugin after validating declarations.
|
|
185
35
|
* Explicit `false` declarations are authoritative, which supports plugins whose
|
|
186
36
|
* implementation is present but disabled by configuration (for example workers).
|
|
187
37
|
*/
|
|
188
|
-
declare function getPluginCapabilities(plugin: ProcessorPlugin): Readonly<PluginCapabilities>;
|
|
38
|
+
export declare function getPluginCapabilities(plugin: ProcessorPlugin): Readonly<PluginCapabilities>;
|
|
189
39
|
/** Query an operation without attempting to execute it. Invalid declarations fail closed. */
|
|
190
|
-
declare function supportsOperation(plugin: ProcessorPlugin, operation: PluginOperation): boolean;
|
|
191
|
-
declare function supportsReverse(plugin: ProcessorPlugin): plugin is ProcessorPlugin & Required<Pick<ProcessorPlugin, 'reverse'>>;
|
|
192
|
-
declare function assertReversiblePipeline(plugins: readonly ProcessorPlugin[]): void;
|
|
193
|
-
declare function assertStreamingPipeline(plugins: readonly ProcessorPlugin[]): void;
|
|
194
|
-
declare function detectType(input: unknown): string;
|
|
195
|
-
declare function toBuffer(input: unknown): Buffer;
|
|
196
|
-
declare const ORIGINAL_TYPES: readonly ["buffer", "object", "array", "string", "number", "boolean", "null", "undefined", "bigint", "json"];
|
|
197
|
-
declare function assertOriginalType(value: unknown): asserts value is string;
|
|
198
|
-
declare function fromBuffer(buffer: Buffer, targetType: string, maxFrameBytes?: number): unknown;
|
|
199
|
-
declare function makeContext(requestId: string, extra?: Record<string, unknown>, logger?: Logger, span?: Span, signal?: AbortSignal, limits?: Readonly<EngineLimits>): ProcessorContext;
|
|
200
|
-
declare function buildManifest(plugins: readonly ProcessorPlugin[]): PipeXManifest;
|
|
40
|
+
export declare function supportsOperation(plugin: ProcessorPlugin, operation: PluginOperation): boolean;
|
|
41
|
+
export declare function supportsReverse(plugin: ProcessorPlugin): plugin is ProcessorPlugin & Required<Pick<ProcessorPlugin, 'reverse'>>;
|
|
42
|
+
export declare function assertReversiblePipeline(plugins: readonly ProcessorPlugin[]): void;
|
|
43
|
+
export declare function assertStreamingPipeline(plugins: readonly ProcessorPlugin[]): void;
|
|
44
|
+
export declare function detectType(input: unknown): string;
|
|
45
|
+
export declare function toBuffer(input: unknown): Buffer;
|
|
46
|
+
export declare const ORIGINAL_TYPES: readonly ["buffer", "object", "array", "string", "number", "boolean", "null", "undefined", "bigint", "json"];
|
|
47
|
+
export declare function assertOriginalType(value: unknown): asserts value is string;
|
|
48
|
+
export declare function fromBuffer(buffer: Buffer, targetType: string, maxFrameBytes?: number): unknown;
|
|
49
|
+
export declare function makeContext(requestId: string, extra?: Record<string, unknown>, logger?: Logger, span?: Span, signal?: AbortSignal, limits?: Readonly<EngineLimits>): ProcessorContext;
|
|
50
|
+
export declare function buildManifest(plugins: readonly ProcessorPlugin[]): PipeXManifest;
|
|
201
51
|
/**
|
|
202
52
|
* A passthrough Transform that prepends a single msgpack-encoded manifest frame
|
|
203
53
|
* to the byte stream before forwarding any data chunks.
|
|
204
54
|
* Inserted between PackrStream output and the file destination.
|
|
205
55
|
*/
|
|
206
|
-
declare function buildManifestHeaderTransform(manifest: PipeXManifest): Transform;
|
|
56
|
+
export declare function buildManifestHeaderTransform(manifest: PipeXManifest): Transform;
|
|
207
57
|
/**
|
|
208
58
|
* Object-mode Transform that sits after UnpackrStream.
|
|
209
59
|
* Intercepts the first decoded frame: if it is a PipeXManifest, captures it
|
|
210
60
|
* via onManifest() and drops it from the output; all other frames pass through.
|
|
211
61
|
*/
|
|
212
|
-
declare function buildManifestExtractTransform(onManifest: (m: PipeXManifest) => void): Transform;
|
|
62
|
+
export declare function buildManifestExtractTransform(onManifest: (m: PipeXManifest) => void): Transform;
|
|
213
63
|
/** DoS-safe UnpackrStream subclass — rejects oversized raw chunks before decode. */
|
|
214
|
-
declare class GuardedUnpackrStream extends UnpackrStream {
|
|
64
|
+
export declare class GuardedUnpackrStream extends UnpackrStream {
|
|
215
65
|
#private;
|
|
216
66
|
constructor(options?: Record<string, unknown>, maxInputBytes?: number);
|
|
217
67
|
_transform(chunk: Buffer, enc: BufferEncoding, cb: TransformCallback): void;
|
|
218
68
|
}
|
|
219
69
|
/** PackrStream with useRecords disabled (safe default). */
|
|
220
|
-
declare function createPackrStream(): PackrStream;
|
|
70
|
+
export declare function createPackrStream(): PackrStream;
|
|
221
71
|
/** GuardedUnpackrStream with useRecords disabled. */
|
|
222
|
-
declare function createUnpackrStream(maxInputBytes?: number): GuardedUnpackrStream;
|
|
223
|
-
declare function buildByteLimitTransform(maxBytes: number, label: string): Transform;
|
|
224
|
-
declare function buildObjectLimitTransform(maxFrames: number): Transform;
|
|
72
|
+
export declare function createUnpackrStream(maxInputBytes?: number): GuardedUnpackrStream;
|
|
73
|
+
export declare function buildByteLimitTransform(maxBytes: number, label: string): Transform;
|
|
74
|
+
export declare function buildObjectLimitTransform(maxFrames: number): Transform;
|
|
225
75
|
/** Rejects known byte-backed values before MessagePack copies their payload. */
|
|
226
|
-
declare function assertKnownValueByteLimit(value: unknown, maxBytes: number, label: string): void;
|
|
227
|
-
declare function buildKnownValueByteLimitTransform(maxBytes: number, label: string): Transform;
|
|
76
|
+
export declare function assertKnownValueByteLimit(value: unknown, maxBytes: number, label: string): void;
|
|
77
|
+
export declare function buildKnownValueByteLimitTransform(maxBytes: number, label: string): Transform;
|
|
228
78
|
/**
|
|
229
79
|
* Wraps a plugin's process/reverse call in a Transform.
|
|
230
80
|
* requestId is fixed per stream instance — not per chunk — to avoid
|
|
231
81
|
* 60× randomUUID() overhead on high-throughput paths.
|
|
232
82
|
*/
|
|
233
|
-
declare function buildFallbackTransform(plugin: ProcessorPlugin, reverse: boolean, emitProgress?: (bytes: number) => void, logger?: Logger, tracer?: Tracer, dlq?: Writable, streamContext?: StreamPluginContext): Transform;
|
|
83
|
+
export declare function buildFallbackTransform(plugin: ProcessorPlugin, reverse: boolean, emitProgress?: (bytes: number) => void, logger?: Logger, tracer?: Tracer, dlq?: Writable, streamContext?: StreamPluginContext): Transform;
|
|
234
84
|
/** Serialises JS objects to NDJSON lines. */
|
|
235
|
-
declare function buildNdjsonTransform(): Transform;
|
|
85
|
+
export declare function buildNdjsonTransform(): Transform;
|
|
236
86
|
/**
|
|
237
87
|
* Builds the ordered Transform chain from a plugin list.
|
|
238
88
|
* Uses native createStream() when available; falls back to buildFallbackTransform.
|
|
239
89
|
*/
|
|
240
|
-
declare function buildTransformChain(plugins: readonly ProcessorPlugin[], mode: 'compress' | 'decompress', reverse?: boolean, onProgress?: (bytes: number) => void, logger?: Logger, tracer?: Tracer, dlq?: Writable, streamContext?: StreamPluginContext): (Duplex | Transform | PackrStream | GuardedUnpackrStream)[];
|
|
90
|
+
export declare function buildTransformChain(plugins: readonly ProcessorPlugin[], mode: 'compress' | 'decompress', reverse?: boolean, onProgress?: (bytes: number) => void, logger?: Logger, tracer?: Tracer, dlq?: Writable, streamContext?: StreamPluginContext): (Duplex | Transform | PackrStream | GuardedUnpackrStream)[];
|
|
241
91
|
/**
|
|
242
92
|
* Runs an arbitrary pipeline: Source → [...Transforms] → Destination.
|
|
243
93
|
* The `any` cast is scoped to this single call site — nowhere else.
|
|
244
94
|
*/
|
|
245
|
-
declare function runPipeline(source: Readable, transforms: (Duplex | Transform | PackrStream | GuardedUnpackrStream)[], destination: Writable, options?: {
|
|
95
|
+
export declare function runPipeline(source: Readable, transforms: (Duplex | Transform | PackrStream | GuardedUnpackrStream)[], destination: Writable, options?: {
|
|
246
96
|
signal?: AbortSignal;
|
|
247
97
|
}): Promise<void>;
|
|
248
|
-
declare function assertExists(inputPath: string, allowedRoot?: string): string;
|
|
249
|
-
declare function resolveOutputPath(outputPath: string, allowedRoot?: string): string;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
process(inputPath: string, outputPath: string, allowedRoot?: string, options?: OperationOptions): Promise<void>;
|
|
259
|
-
/**
|
|
260
|
-
* Source file → Plugin pipeline (decompress, reversed) → Destination file.
|
|
261
|
-
*/
|
|
262
|
-
reverse(inputPath: string, outputPath: string, allowedRoot?: string, options?: OperationOptions): Promise<void>;
|
|
263
|
-
/**
|
|
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.
|
|
268
|
-
*/
|
|
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>;
|
|
98
|
+
export declare function assertExists(inputPath: string, allowedRoot?: string): string;
|
|
99
|
+
export declare function resolveOutputPath(outputPath: string, allowedRoot?: string): string;
|
|
100
|
+
/** A synchronous or asynchronous transformation from Input to Output. */
|
|
101
|
+
type TypedTransform<Input, Output> = (input: Input, options: Readonly<OperationOptions>) => Output | Promise<Output>;
|
|
102
|
+
/** Cancellation options for typed application pipelines. */
|
|
103
|
+
type TypedPipelineOptions = Readonly<OperationOptions>;
|
|
104
|
+
/** An immutable pipeline whose input and output types are preserved across steps. */
|
|
105
|
+
export declare class TypedPipeline<Input, Output> {
|
|
106
|
+
private readonly transforms;
|
|
107
|
+
private constructor();
|
|
441
108
|
/**
|
|
442
|
-
*
|
|
443
|
-
*
|
|
109
|
+
* Start a pipeline from an initial typed transform.
|
|
110
|
+
* @param transform First transformation; its input type becomes the pipeline input.
|
|
444
111
|
*/
|
|
445
|
-
|
|
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;
|
|
112
|
+
static from<Input, Output>(transform: TypedTransform<Input, Output>): TypedPipeline<Input, Awaited<Output>>;
|
|
451
113
|
/**
|
|
452
|
-
*
|
|
453
|
-
*
|
|
114
|
+
* Append a transform. Its input must accept this pipeline's current output.
|
|
115
|
+
* The returned pipeline infers the appended asynchronous or synchronous output.
|
|
454
116
|
*/
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
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;
|
|
488
|
-
}
|
|
489
|
-
//#endregion
|
|
490
|
-
//#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';
|
|
492
|
-
declare class PipeXError extends Error {
|
|
117
|
+
pipe<Next>(transform: TypedTransform<Output, Next>): TypedPipeline<Input, Awaited<Next>>;
|
|
118
|
+
/** Execute all transforms in order, honouring cancellation between awaits. */
|
|
119
|
+
run(input: Input, options?: TypedPipelineOptions): Promise<Output>;
|
|
120
|
+
}
|
|
121
|
+
/** Create a typed pipeline with automatic end-to-end transform inference. */
|
|
122
|
+
export declare function typedPipeline<Input, Output>(first: TypedTransform<Input, Output>): TypedPipeline<Input, Awaited<Output>>;
|
|
123
|
+
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';
|
|
124
|
+
export declare class PipeXError extends Error {
|
|
493
125
|
readonly code: PipeXErrorCode;
|
|
494
126
|
readonly name: string;
|
|
495
|
-
|
|
127
|
+
readonly transformName?: string;
|
|
128
|
+
readonly stage?: string;
|
|
129
|
+
constructor(code: PipeXErrorCode, message: string, options?: ErrorOptions & {
|
|
130
|
+
transformName?: string;
|
|
131
|
+
stage?: string;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/** Domain failures use fixed, non-sensitive messages. Never include input, keys or arbitrary provider errors. */
|
|
135
|
+
export declare class ValidationError extends PipeXError {
|
|
136
|
+
readonly name = "ValidationError";
|
|
137
|
+
constructor(options?: ErrorOptions & {
|
|
138
|
+
transformName?: string;
|
|
139
|
+
stage?: string;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
export declare class CompressionError extends PipeXError {
|
|
143
|
+
readonly name = "CompressionError";
|
|
144
|
+
constructor(options?: ErrorOptions & {
|
|
145
|
+
transformName?: string;
|
|
146
|
+
stage?: string;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
export declare class HashingError extends PipeXError {
|
|
150
|
+
readonly name = "HashingError";
|
|
151
|
+
constructor(options?: ErrorOptions & {
|
|
152
|
+
transformName?: string;
|
|
153
|
+
stage?: string;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
export declare class UnsupportedAlgorithmError extends PipeXError {
|
|
157
|
+
readonly name = "UnsupportedAlgorithmError";
|
|
158
|
+
constructor(options?: ErrorOptions & {
|
|
159
|
+
transformName?: string;
|
|
160
|
+
stage?: string;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/** Alias hierarchy: existing OperationAbortedError retains its code and instanceof contract. */
|
|
164
|
+
export declare class PipelineAbortedError extends PipeXError {
|
|
165
|
+
readonly name: string;
|
|
166
|
+
constructor(options?: ErrorOptions & {
|
|
167
|
+
transformName?: string;
|
|
168
|
+
stage?: string;
|
|
169
|
+
});
|
|
496
170
|
}
|
|
497
|
-
declare class UnsupportedReverseError extends PipeXError {
|
|
171
|
+
export declare class UnsupportedReverseError extends PipeXError {
|
|
498
172
|
readonly plugin: string;
|
|
499
173
|
readonly name: string;
|
|
500
174
|
constructor(plugin: string);
|
|
501
175
|
}
|
|
502
|
-
declare class UnsupportedStreamingError extends PipeXError {
|
|
176
|
+
export declare class UnsupportedStreamingError extends PipeXError {
|
|
503
177
|
readonly plugin: string;
|
|
504
178
|
readonly name: string;
|
|
505
179
|
constructor(plugin: string);
|
|
506
180
|
}
|
|
507
181
|
type InvalidPluginCapabilityIssue = 'MUST_BE_BOOLEAN' | 'MISSING_IMPLEMENTATION' | 'CONFLICTING_IMPLEMENTATION';
|
|
508
|
-
declare class InvalidPluginCapabilityError extends PipeXError {
|
|
182
|
+
export declare class InvalidPluginCapabilityError extends PipeXError {
|
|
509
183
|
readonly plugin: string;
|
|
510
184
|
readonly capability: 'reversible' | 'streaming';
|
|
511
185
|
readonly issue: InvalidPluginCapabilityIssue;
|
|
512
186
|
readonly name: string;
|
|
513
187
|
constructor(plugin: string, capability: 'reversible' | 'streaming', issue: InvalidPluginCapabilityIssue);
|
|
514
188
|
}
|
|
515
|
-
declare class OperationAbortedError extends
|
|
189
|
+
export declare class OperationAbortedError extends PipelineAbortedError {
|
|
516
190
|
readonly name: string;
|
|
517
191
|
constructor(options?: ErrorOptions);
|
|
518
192
|
}
|
|
519
|
-
declare class OperationTimeoutError extends PipeXError {
|
|
193
|
+
export declare class OperationTimeoutError extends PipeXError {
|
|
520
194
|
readonly name: string;
|
|
521
195
|
constructor(options?: ErrorOptions);
|
|
522
196
|
}
|
|
523
|
-
declare class KmsProviderError extends PipeXError {
|
|
197
|
+
export declare class KmsProviderError extends PipeXError {
|
|
524
198
|
readonly operation: 'generateDataKey' | 'decrypt' | 'encrypt';
|
|
525
199
|
readonly name: string;
|
|
526
200
|
constructor(operation: 'generateDataKey' | 'decrypt' | 'encrypt', options?: ErrorOptions);
|
|
527
201
|
}
|
|
528
|
-
declare class KmsAuthenticationError extends PipeXError {
|
|
202
|
+
export declare class KmsAuthenticationError extends PipeXError {
|
|
529
203
|
readonly name: string;
|
|
530
204
|
constructor();
|
|
531
205
|
}
|
|
532
|
-
declare class KmsProviderAuthenticationError extends PipeXError {
|
|
206
|
+
export declare class KmsProviderAuthenticationError extends PipeXError {
|
|
533
207
|
readonly operation: 'generateDataKey' | 'decrypt' | 'encrypt';
|
|
534
208
|
readonly name: string;
|
|
535
209
|
constructor(operation: 'generateDataKey' | 'decrypt' | 'encrypt');
|
|
536
210
|
}
|
|
537
|
-
declare class KmsProviderUnavailableError extends PipeXError {
|
|
211
|
+
export declare class KmsProviderUnavailableError extends PipeXError {
|
|
538
212
|
readonly operation: 'generateDataKey' | 'decrypt' | 'encrypt';
|
|
539
213
|
readonly name: string;
|
|
540
214
|
constructor(operation: 'generateDataKey' | 'decrypt' | 'encrypt');
|
|
541
215
|
}
|
|
542
|
-
declare class UnsupportedKmsOperationError extends PipeXError {
|
|
216
|
+
export declare class UnsupportedKmsOperationError extends PipeXError {
|
|
543
217
|
readonly operation: 'generateDataKey' | 'decrypt' | 'encrypt';
|
|
544
218
|
readonly name: string;
|
|
545
219
|
constructor(operation: 'generateDataKey' | 'decrypt' | 'encrypt');
|
|
546
220
|
}
|
|
547
221
|
type InvalidKmsProviderCapabilityIssue = 'MUST_BE_BOOLEAN' | 'MISSING_IMPLEMENTATION';
|
|
548
|
-
declare class InvalidKmsProviderCapabilityError extends PipeXError {
|
|
222
|
+
export declare class InvalidKmsProviderCapabilityError extends PipeXError {
|
|
549
223
|
readonly operation: 'generateDataKey' | 'decrypt' | 'encrypt';
|
|
550
224
|
readonly issue: InvalidKmsProviderCapabilityIssue;
|
|
551
225
|
readonly name: string;
|
|
552
226
|
constructor(operation: 'generateDataKey' | 'decrypt' | 'encrypt', issue: InvalidKmsProviderCapabilityIssue);
|
|
553
227
|
}
|
|
554
|
-
declare class WorkerPoolClosedError extends PipeXError {
|
|
228
|
+
export declare class WorkerPoolClosedError extends PipeXError {
|
|
555
229
|
readonly name: string;
|
|
556
230
|
constructor();
|
|
557
231
|
}
|
|
558
|
-
declare class WorkerQueueFullError extends PipeXError {
|
|
232
|
+
export declare class WorkerQueueFullError extends PipeXError {
|
|
559
233
|
readonly maxQueue: number;
|
|
560
234
|
readonly name: string;
|
|
561
235
|
constructor(maxQueue: number);
|
|
562
236
|
}
|
|
563
|
-
declare class WorkerPoolCloseError extends PipeXError {
|
|
237
|
+
export declare class WorkerPoolCloseError extends PipeXError {
|
|
564
238
|
readonly name: string;
|
|
565
239
|
constructor(options?: ErrorOptions);
|
|
566
240
|
}
|
|
567
|
-
declare class WorkerTaskError extends PipeXError {
|
|
241
|
+
export declare class WorkerTaskError extends PipeXError {
|
|
568
242
|
readonly taskName: string;
|
|
569
243
|
readonly name: string;
|
|
570
244
|
constructor(taskName: string, options?: ErrorOptions);
|
|
571
245
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
* Explicit false declarations support legacy provider stubs that exist only
|
|
577
|
-
* to throw; such methods are never invoked through PipeX.
|
|
578
|
-
*/
|
|
579
|
-
declare function getKmsProviderCapabilities(provider: KmsProvider): Readonly<KmsProviderCapabilities>;
|
|
580
|
-
declare function supportsKmsOperation(provider: KmsProvider, operation: KmsOperation): boolean;
|
|
581
|
-
//#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;
|
|
246
|
+
/** Public cryptographic failure categories; never include keys or ciphertext in messages. */
|
|
247
|
+
export declare class EncryptionError extends PipeXError {
|
|
248
|
+
readonly name: string;
|
|
249
|
+
constructor(message?: string);
|
|
617
250
|
}
|
|
618
|
-
|
|
619
|
-
|
|
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;
|
|
251
|
+
export declare class InvalidKeyError extends PipeXError {
|
|
252
|
+
readonly name: string;
|
|
253
|
+
constructor();
|
|
632
254
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
interface CompressionOptions {
|
|
637
|
-
type: CompressionType;
|
|
638
|
-
level?: number;
|
|
255
|
+
export declare class AuthenticationError extends PipeXError {
|
|
256
|
+
readonly name: string;
|
|
257
|
+
constructor();
|
|
639
258
|
}
|
|
640
259
|
/**
|
|
641
|
-
*
|
|
642
|
-
*
|
|
260
|
+
* Returns an immutable, runtime-validated view of a generic KMS provider.
|
|
261
|
+
* Explicit false declarations support legacy provider stubs that exist only
|
|
262
|
+
* to throw; such methods are never invoked through PipeX.
|
|
643
263
|
*/
|
|
644
|
-
declare
|
|
645
|
-
|
|
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
|
-
//#region src/plugin/performance.d.ts
|
|
264
|
+
export declare function getKmsProviderCapabilities(provider: KmsProvider): Readonly<KmsProviderCapabilities>;
|
|
265
|
+
export declare function supportsKmsOperation(provider: KmsProvider, operation: KmsOperation): boolean;
|
|
655
266
|
/**
|
|
656
267
|
* BenchmarkPlugin — Standard library plugin for monitoring data throughput.
|
|
657
268
|
* Records input/output byte counts in context metadata.
|
|
658
269
|
*/
|
|
659
|
-
declare class BenchmarkPlugin extends BasePlugin {
|
|
270
|
+
export declare class BenchmarkPlugin extends BasePlugin {
|
|
660
271
|
readonly name = "benchmark";
|
|
661
272
|
readonly version = "2.0.0";
|
|
662
273
|
process(data: Buffer, ctx: ProcessorContext): Promise<Buffer>;
|
|
663
274
|
reverse(data: Buffer, ctx: ProcessorContext): Promise<Buffer>;
|
|
664
275
|
}
|
|
665
|
-
|
|
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
|
-
//#region src/index.d.ts
|
|
754
|
-
declare const Plugins: {
|
|
276
|
+
export declare const Plugins: {
|
|
755
277
|
readonly Hashing: typeof HashingPlugin;
|
|
756
278
|
readonly Encryption: typeof EncryptionPlugin;
|
|
757
279
|
readonly Compression: typeof CompressionPlugin;
|
|
@@ -760,6 +282,4 @@ declare const Plugins: {
|
|
|
760
282
|
readonly Validation: typeof ValidationPlugin;
|
|
761
283
|
readonly KmsEncryption: typeof KmsEncryptionPlugin;
|
|
762
284
|
};
|
|
763
|
-
|
|
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
|
|
285
|
+
export { type AuditLogger, type AuditRecord, BasePlugin, type BinaryUndoOptions, type CompressionOptions, CompressionPlugin, type CompressionType, DataEngine, type EncryptionAlgorithm, type EncryptionOptions, EncryptionPlugin, type EngineConfig, type EngineEvents, type EngineLimits, type EngineResult, type HashAlgorithm, type HashingOptions, HashingPlugin, type InvalidKmsProviderCapabilityIssue, type InvalidPluginCapabilityIssue, type KmsEncryptionOptions, KmsEncryptionPlugin, type KmsOperation, type KmsProvider, type KmsProviderCapabilities, type KmsRequestOptions, type Logger, type OperationOptions, type PipeXErrorCode, type PipeXManifest, type PluginCapabilities, type PluginConstructor, type PluginOperation, type ProcessorContext, type ProcessorPlugin, type RegisteredPluginCapabilities, type RetryOptions, type SchemaRegistry, type Span, type StreamPluginContext, type Tracer, type TypedPipelineOptions, type TypedTransform, type ValidationOptions, ValidationPlugin, type WorkerPoolOptions, WorkerPoolPlugin, isManifest };
|