@routier/core 0.0.7 → 0.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/index.js","sources":["webpack://@routier/core/./src/pipeline/SyncronousQueue.ts","webpack://@routier/core/./src/pipeline/TrampolinePipeline.ts","webpack://@routier/core/./src/results/Result.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/pipeline/index.ts"],"sourcesContent":["export type SyncronousUnitOfWork = (done: () => void) => void\n\nexport class SyncronousQueue {\n\n private readonly _queue: SyncronousUnitOfWork[] = [];\n private _current: SyncronousUnitOfWork | null = null;\n\n enqueue(unitOfWork: SyncronousUnitOfWork) {\n this._queue.push(unitOfWork);\n this._next();\n }\n\n private _next() {\n if (this._current != null || this._queue.length === 0) {\n return;\n }\n\n // Take first item\n this._current = this._queue.shift() ?? null;\n\n if (this._current == null) {\n return;\n }\n\n this._current(() => {\n this._current = null;\n this._next();\n })\n }\n}","import { CallbackResult, Result, ResultType } from \"../results\";\n\n/**\n * Type definition for an asynchronous function that takes data and a callback.\n * TIn: The input data type.\n * TOut: The output data type (passed to the callback).\n */\nexport type Processor<TIn, TOut> = (data: TIn, callback: (result: TOut, error?: any) => void) => void;\n\n// Return type for a step execution: Either the next step function or null if waiting/done.\ntype StepResult<TData> = TrampolineStep<TData> | null;\ntype TrampolineStep<TData> = () => StepResult<TData>;\n\nexport class TrampolinePipeline<TInitial, TCurrent = TInitial> {\n private _list: Processor<any, any>[] = [];\n private _hasErrored: boolean = false; // Flag to prevent calling done on error\n\n filter<TFinal>(initialData: TInitial, done: (data: TFinal, error?: any) => void) {\n\n this._hasErrored = false; // Reset error flag on new execution\n\n if (this._list.length === 0) {\n queueMicrotask(() => done(initialData as any as TFinal));\n return;\n }\n\n let index = 0;\n let currentData: any = initialData;\n let isRunning = false; // Guard against overlapping trampoline calls\n\n try {\n // --- Revised Completion Logic --- (Moved up for clarity)\n const finalStepSentinel = (): StepResult<any> => { // A special step function for the very end\n // Only call done if no error has occurred\n if (!this._hasErrored) {\n queueMicrotask(() => done(currentData as TFinal));\n }\n return null; // Stop the trampoline\n };\n\n const createStepRevised = (idx: number): TrampolineStep<any> => {\n return () => {\n if (this._hasErrored) return null; // Stop if an error occurred elsewhere\n\n if (idx >= this._list.length) {\n return finalStepSentinel(); // Execute the dedicated final step\n }\n\n const processor = this._list[idx];\n // Initialize syncCallbackResult to null to satisfy StepResult type\n let syncCallbackResult: StepResult<any> = null;\n let calledSync = false;\n\n try {\n processor(currentData, (result, error) => {\n // --- Error Handling ---\n if (error) {\n console.error(`Error reported by processor at index ${idx}:`, error);\n this._hasErrored = true; // Set flag\n // Throw the error to be caught by outer try...catch blocks\n throw error;\n }\n // --- /Error Handling ---\n\n // If no error, proceed as before\n currentData = result;\n index = idx + 1; // Update index for the next step\n const nextStep = createStepRevised(index); // Use updated index\n\n if (isRunning) {\n // Callback was synchronous\n syncCallbackResult = nextStep; // Store next step function\n calledSync = true;\n } else {\n // Callback was asynchronous, restart trampoline\n trampoline(nextStep);\n }\n });\n } catch (error) {\n if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback\n console.error(`Error thrown by processor at index ${idx} or its callback:`, error);\n this._hasErrored = true;\n }\n // Rethrow to be caught by the trampoline's catch block\n throw error;\n }\n\n if (calledSync) {\n // Return the next step function for the sync loop\n return syncCallbackResult;\n } else {\n // Pause trampoline for async, loop will stop as step returns null\n return null;\n }\n };\n };\n\n // The trampoline loop\n const trampoline = (step: TrampolineStep<any> | null) => {\n\n if (isRunning) {\n return;\n }\n\n isRunning = true;\n let currentStep = step;\n\n while (typeof currentStep === 'function') {\n try {\n // Stop immediately if an error was flagged elsewhere\n if (this._hasErrored) {\n currentStep = null;\n break;\n }\n currentStep = currentStep(); // Execute step, get next step or null\n } catch (trampolineError) {\n // Catch errors propagated from step execution (processor or callback errors)\n if (!this._hasErrored) { // Avoid double logging\n console.error(\"Error during trampoline step execution:\", trampolineError);\n this._hasErrored = true;\n }\n currentStep = null; // Stop the loop\n // We don't call `done` here because an error occurred.\n // The application should handle the uncaught exception if desired.\n break; // Explicitly break loop on error\n }\n }\n // Loop ends when currentStep is null or loop is broken by error\n isRunning = false;\n\n // Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.\n };\n\n // --- Start the process ---\n index = 0; // Reset index\n currentData = initialData; // Reset data\n trampoline(createStepRevised(0)); // Start with the revised step creator\n } catch (error: any) {\n done(currentData, error);\n }\n }\n\n pipe<TNext>(processor: Processor<TCurrent, TNext>) {\n this._list.push(processor);\n return this as unknown as TrampolinePipeline<TInitial, TNext>;\n }\n\n pipeEach(items: TCurrent[], fn: (payload: ResultType<TCurrent>, done: CallbackResult<TCurrent>) => void, map: (previous: ResultType<TCurrent>, current: ResultType<TCurrent>) => ResultType<TCurrent>) {\n for (let i = 0, length = items.length; i < length; i++) {\n\n this.pipe<ResultType<TCurrent>>((previous, done) => {\n\n fn(map(previous as ResultType<TCurrent>, Result.success(items[i])), done);\n });\n }\n }\n}\n\nexport type AsyncUnitOfWork<TData, TResult> = (payload: TData, done: CallbackResult<TResult>) => void;\nexport class AsyncPipeline<TData, TResult> {\n private _list: [TData, AsyncUnitOfWork<TData, TResult>][] = [];\n private _hasErrored: boolean = false; // Flag to prevent calling done on error\n\n filter(done: CallbackResult<TResult[]>) {\n\n this._hasErrored = false; // Reset error flag on new execution\n let currentData: TResult[] = [];\n\n if (this._list.length === 0) {\n queueMicrotask(() => done(Result.success()));\n return;\n }\n\n let index = 0;\n let isRunning = false; // Guard against overlapping trampoline calls\n\n try {\n // --- Revised Completion Logic --- (Moved up for clarity)\n const finalStepSentinel = (): StepResult<any> => { // A special step function for the very end\n // Only call done if no error has occurred\n if (!this._hasErrored) {\n queueMicrotask(() => done(Result.success(currentData)));\n }\n return null; // Stop the trampoline\n };\n\n const createStepRevised = (idx: number): TrampolineStep<any> => {\n return () => {\n if (this._hasErrored) return null; // Stop if an error occurred elsewhere\n\n if (idx >= this._list.length) {\n return finalStepSentinel(); // Execute the dedicated final step\n }\n\n const [payload, processor] = this._list[idx];\n // Initialize syncCallbackResult to null to satisfy StepResult type\n let syncCallbackResult: StepResult<any> = null;\n let calledSync = false;\n\n try {\n processor(payload, (result) => {\n // --- Error Handling ---\n if (result.ok === Result.ERROR) {\n console.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);\n this._hasErrored = true; // Set flag\n // Throw the error to be caught by outer try...catch blocks\n throw result.error;\n }\n // --- /Error Handling ---\n\n // If no error, proceed as before\n currentData.push(result.data);\n index = idx + 1; // Update index for the next step\n const nextStep = createStepRevised(index); // Use updated index\n\n if (isRunning) {\n // Callback was synchronous\n syncCallbackResult = nextStep; // Store next step function\n calledSync = true;\n } else {\n // Callback was asynchronous, restart trampoline\n trampoline(nextStep);\n }\n });\n } catch (error) {\n if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback\n console.error(`Error thrown by processor at index ${idx} or its callback:`, error);\n this._hasErrored = true;\n }\n // Rethrow to be caught by the trampoline's catch block\n throw error;\n }\n\n if (calledSync) {\n // Return the next step function for the sync loop\n return syncCallbackResult;\n } else {\n // Pause trampoline for async, loop will stop as step returns null\n return null;\n }\n };\n };\n\n // The trampoline loop\n const trampoline = (step: TrampolineStep<any> | null) => {\n\n if (isRunning) {\n return;\n }\n\n isRunning = true;\n let currentStep = step;\n\n while (typeof currentStep === 'function') {\n try {\n // Stop immediately if an error was flagged elsewhere\n if (this._hasErrored) {\n currentStep = null;\n break;\n }\n currentStep = currentStep(); // Execute step, get next step or null\n } catch (trampolineError) {\n // Catch errors propagated from step execution (processor or callback errors)\n if (!this._hasErrored) { // Avoid double logging\n console.error(\"Error during trampoline step execution:\", trampolineError);\n this._hasErrored = true;\n }\n currentStep = null; // Stop the loop\n // We don't call `done` here because an error occurred.\n // The application should handle the uncaught exception if desired.\n break; // Explicitly break loop on error\n }\n }\n // Loop ends when currentStep is null or loop is broken by error\n isRunning = false;\n\n // Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.\n };\n\n // --- Start the process ---\n index = 0; // Reset index\n trampoline(createStepRevised(0)); // Start with the revised step creator\n } catch (error: any) {\n done(Result.error(error));\n }\n }\n\n pipe(data: TData, processor: AsyncUnitOfWork<TData, TResult>) {\n this._list.push([data, processor]);\n }\n\n pipeEach(items: TData[], processor: AsyncUnitOfWork<TData, TResult>) {\n for (let i = 0, length = items.length; i < length; i++) {\n this.pipe(items[i], processor);\n }\n }\n}\n\nexport type UnitOfWork = (done: CallbackResult<never>) => void;\n\n/**\n * Processes functions with callbacks asynchronously.\n * \n * This pipeline handles work items that contain callback functions,\n * executing them in an asynchronous manner while maintaining proper\n * flow control and error handling.\n */\nexport class WorkPipeline {\n private unitsOfWork: UnitOfWork[] = [];\n private _hasErrored: boolean = false; // Flag to prevent calling done on error\n\n filter(done: CallbackResult<never>) {\n\n this._hasErrored = false; // Reset error flag on new execution\n\n if (this.unitsOfWork.length === 0) {\n queueMicrotask(() => done(Result.success()));\n return;\n }\n\n let index = 0;\n let isRunning = false; // Guard against overlapping trampoline calls\n\n try {\n // --- Revised Completion Logic --- (Moved up for clarity)\n const finalStepSentinel = (): StepResult<never> => { // A special step function for the very end\n // Only call done if no error has occurred\n if (!this._hasErrored) {\n queueMicrotask(() => done(Result.success()));\n }\n return null; // Stop the trampoline\n };\n\n const createStepRevised = (idx: number): TrampolineStep<any> => {\n return () => {\n if (this._hasErrored) return null; // Stop if an error occurred elsewhere\n\n if (idx >= this.unitsOfWork.length) {\n return finalStepSentinel(); // Execute the dedicated final step\n }\n\n const processor = this.unitsOfWork[idx];\n // Initialize syncCallbackResult to null to satisfy StepResult type\n let syncCallbackResult: StepResult<any> = null;\n let calledSync = false;\n\n try {\n processor((result) => {\n // --- Error Handling ---\n if (result.ok === Result.ERROR) {\n console.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);\n this._hasErrored = true; // Set flag\n // Throw the error to be caught by outer try...catch blocks\n throw result.error;\n }\n // --- /Error Handling ---\n\n // If no error, proceed as before\n index = idx + 1; // Update index for the next step\n const nextStep = createStepRevised(index); // Use updated index\n\n if (isRunning) {\n // Callback was synchronous\n syncCallbackResult = nextStep; // Store next step function\n calledSync = true;\n } else {\n // Callback was asynchronous, restart trampoline\n trampoline(nextStep);\n }\n });\n } catch (error) {\n if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback\n console.error(`Error thrown by processor at index ${idx} or its callback:`, error);\n this._hasErrored = true;\n }\n // Rethrow to be caught by the trampoline's catch block\n throw error;\n }\n\n if (calledSync) {\n // Return the next step function for the sync loop\n return syncCallbackResult;\n } else {\n // Pause trampoline for async, loop will stop as step returns null\n return null;\n }\n };\n };\n\n // The trampoline loop\n const trampoline = (step: TrampolineStep<any> | null) => {\n\n if (isRunning) {\n return;\n }\n\n isRunning = true;\n let currentStep = step;\n\n while (typeof currentStep === 'function') {\n try {\n // Stop immediately if an error was flagged elsewhere\n if (this._hasErrored) {\n currentStep = null;\n break;\n }\n currentStep = currentStep(); // Execute step, get next step or null\n } catch (trampolineError) {\n // Catch errors propagated from step execution (processor or callback errors)\n if (!this._hasErrored) { // Avoid double logging\n console.error(\"Error during trampoline step execution:\", trampolineError);\n this._hasErrored = true;\n }\n currentStep = null; // Stop the loop\n // We don't call `done` here because an error occurred.\n // The application should handle the uncaught exception if desired.\n break; // Explicitly break loop on error\n }\n }\n // Loop ends when currentStep is null or loop is broken by error\n isRunning = false;\n\n // Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.\n };\n\n // --- Start the process ---\n index = 0; // Reset index\n trampoline(createStepRevised(0)); // Start with the revised step creator\n } catch (error: any) {\n done(Result.error(error));\n }\n }\n\n pipe(work: UnitOfWork) {\n this.unitsOfWork.push(work);\n }\n}","import { PartialResultType, PluginEventPartialResultType, PluginEventResultType, ResultType } from \"./types\";\n\nabstract class BaseResult {\n static ERROR = \"error\" as const;\n static SUCCESS = \"success\" as const;\n static PARTIAL = \"partial\" as const;\n\n static resolve<T>(result: ResultType<T> | PartialResultType<T>, resolve: (data: T) => void, reject: (error?: any) => void) {\n if (result.ok === BaseResult.SUCCESS) {\n resolve(result.data);\n return;\n }\n\n if (result.ok === BaseResult.PARTIAL) {\n reject({\n partial: result.data,\n error: result.error\n });\n return;\n }\n\n reject(result.error);\n }\n\n static assertSuccess<T>(result: any): asserts result is { ok: \"success\"; data: T } {\n if (result.ok !== BaseResult.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n\nexport class Result extends BaseResult {\n static success<T>(data: T): ResultType<T>;\n static success<T>(): ResultType<never>;\n static success<T>(data?: T): ResultType<T> {\n return {\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(error: any): ResultType<T> {\n return {\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(data: T, error: any): PartialResultType<T> {\n return {\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n}\n\nexport class PluginEventResult extends BaseResult {\n static success<T>(id: string, data: T): PluginEventResultType<T>;\n static success<T>(id: string): PluginEventResultType<never>;\n static success<T>(id: string, data?: T): PluginEventResultType<T> {\n return {\n id,\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(id: string, error: any): PluginEventResultType<T> {\n return {\n id,\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(id: string, data: T, error: any): PluginEventPartialResultType<T> {\n return {\n id,\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n\n static assertSuccess<T>(result: PluginEventResultType<T>): asserts result is { ok: \"success\"; data: T; id: string } {\n if (result.ok !== Result.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './SyncronousQueue';\nexport * from './TrampolinePipeline';"],"names":[],"mappings":";;;;;;;;;;AAEO,MAAM,eAAe;IAEP,MAAM,GAA2B,EAAE,CAAC;IAC7C,QAAQ,GAAgC,IAAI,CAAC;IAErD,OAAO,CAAC,UAAgC;QACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEO,KAAK;QACT,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpD,OAAO;QACX,CAAC;QAED,kBAAkB;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,IAAI,CAAC;QAE5C,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;YACf,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,IAAI,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC,CAAC;IACN,CAAC;CACJ;;;;;;;;;;;;;;;;AC7B+D;AAazD,MAAM,kBAAkB;IACnB,KAAK,GAA0B,EAAE,CAAC;IAClC,WAAW,GAAY,KAAK,CAAC,CAAC,wCAAwC;IAE9E,MAAM,CAAS,WAAqB,EAAE,IAAyC;QAE3E,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC,oCAAoC;QAE9D,IAAI,IAAI,CAAC,KAAK,CAAC,MA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AAC,KAAK,EAAE,CAAC,CAAC;QACtF,CAAC;IACL,CAAC;CACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC1FD;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA;;;;ACNA;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D;;;;;;;;;;;;;;;;;;;ACNkC;AACG"}
1
+ {"version":3,"file":"pipeline/index.js","sources":["webpack://@routier/core/./src/pipeline/SyncronousQueue.ts","webpack://@routier/core/./src/pipeline/TrampolinePipeline.ts","webpack://@routier/core/./src/results/Result.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/pipeline/index.ts"],"sourcesContent":["export type SyncronousUnitOfWork = (done: () => void) => void\n\nexport class SyncronousQueue {\n\n private readonly _queue: SyncronousUnitOfWork[] = [];\n private _current: SyncronousUnitOfWork | null = null;\n\n enqueue(unitOfWork: SyncronousUnitOfWork) {\n this._queue.push(unitOfWork);\n this._next();\n }\n\n private _next() {\n if (this._current != null || this._queue.length === 0) {\n return;\n }\n\n // Take first item\n this._current = this._queue.shift() ?? null;\n\n if (this._current == null) {\n return;\n }\n\n this._current(() => {\n this._current = null;\n this._next();\n })\n }\n}","import { CallbackResult, Result, ResultType } from \"../results\";\n\n/**\n * Type definition for an asynchronous function that takes data and a callback.\n * TIn: The input data type.\n * TOut: The output data type (passed to the callback).\n */\nexport type Processor<TIn, TOut> = (data: TIn, callback: (result: TOut, error?: any) => void) => void;\n\n// Return type for a step execution: Either the next step function or null if waiting/done.\ntype StepResult<TData> = TrampolineStep<TData> | null;\ntype TrampolineStep<TData> = () => StepResult<TData>;\n\nexport class TrampolinePipeline<TInitial, TCurrent = TInitial> {\n private _list: Processor<any, any>[] = [];\n private _hasErrored: boolean = false; // Flag to prevent calling done on error\n\n filter<TFinal>(initialData: TInitial, done: (data: TFinal, error?: any) => void) {\n\n this._hasErrored = false; // Reset error flag on new execution\n\n if (this._list.length === 0) {\n queueMicrotask(() => done(initialData as unknown as TFinal));\n return;\n }\n\n let index = 0;\n let currentData: any = initialData;\n let isRunning = false; // Guard against overlapping trampoline calls\n\n try {\n // --- Revised Completion Logic --- (Moved up for clarity)\n const finalStepSentinel = (): StepResult<any> => { // A special step function for the very end\n // Only call done if no error has occurred\n if (!this._hasErrored) {\n queueMicrotask(() => done(currentData as TFinal));\n }\n return null; // Stop the trampoline\n };\n\n const createStepRevised = (idx: number): TrampolineStep<any> => {\n return () => {\n if (this._hasErrored) return null; // Stop if an error occurred elsewhere\n\n if (idx >= this._list.length) {\n return finalStepSentinel(); // Execute the dedicated final step\n }\n\n const processor = this._list[idx];\n // Initialize syncCallbackResult to null to satisfy StepResult type\n let syncCallbackResult: StepResult<any> = null;\n let calledSync = false;\n\n try {\n processor(currentData, (result, error) => {\n // --- Error Handling ---\n if (error) {\n console.error(`Error reported by processor at index ${idx}:`, error);\n this._hasErrored = true; // Set flag\n // Throw the error to be caught by outer try...catch blocks\n throw error;\n }\n // --- /Error Handling ---\n\n // If no error, proceed as before\n currentData = result;\n index = idx + 1; // Update index for the next step\n const nextStep = createStepRevised(index); // Use updated index\n\n if (isRunning) {\n // Callback was synchronous\n syncCallbackResult = nextStep; // Store next step function\n calledSync = true;\n } else {\n // Callback was asynchronous, restart trampoline\n trampoline(nextStep);\n }\n });\n } catch (error) {\n if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback\n console.error(`Error thrown by processor at index ${idx} or its callback:`, error);\n this._hasErrored = true;\n }\n // Rethrow to be caught by the trampoline's catch block\n throw error;\n }\n\n if (calledSync) {\n // Return the next step function for the sync loop\n return syncCallbackResult;\n } else {\n // Pause trampoline for async, loop will stop as step returns null\n return null;\n }\n };\n };\n\n // The trampoline loop\n const trampoline = (step: TrampolineStep<any> | null) => {\n\n if (isRunning) {\n return;\n }\n\n isRunning = true;\n let currentStep = step;\n\n while (typeof currentStep === 'function') {\n try {\n // Stop immediately if an error was flagged elsewhere\n if (this._hasErrored) {\n currentStep = null;\n break;\n }\n currentStep = currentStep(); // Execute step, get next step or null\n } catch (trampolineError) {\n // Catch errors propagated from step execution (processor or callback errors)\n if (!this._hasErrored) { // Avoid double logging\n console.error(\"Error during trampoline step execution:\", trampolineError);\n this._hasErrored = true;\n }\n currentStep = null; // Stop the loop\n // We don't call `done` here because an error occurred.\n // The application should handle the uncaught exception if desired.\n break; // Explicitly break loop on error\n }\n }\n // Loop ends when currentStep is null or loop is broken by error\n isRunning = false;\n\n // Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.\n };\n\n // --- Start the process ---\n index = 0; // Reset index\n currentData = initialData; // Reset data\n trampoline(createStepRevised(0)); // Start with the revised step creator\n } catch (error: any) {\n done(currentData, error);\n }\n }\n\n pipe<TNext>(processor: Processor<TCurrent, TNext>) {\n this._list.push(processor);\n return this as unknown as TrampolinePipeline<TInitial, TNext>;\n }\n\n pipeEach(items: TCurrent[], fn: (payload: ResultType<TCurrent>, done: CallbackResult<TCurrent>) => void, map: (previous: ResultType<TCurrent>, current: ResultType<TCurrent>) => ResultType<TCurrent>) {\n for (let i = 0, length = items.length; i < length; i++) {\n\n this.pipe<ResultType<TCurrent>>((previous, done) => {\n\n fn(map(previous as ResultType<TCurrent>, Result.success(items[i])), done);\n });\n }\n }\n}\n\nexport type AsyncUnitOfWork<TData, TResult> = (payload: TData, done: CallbackResult<TResult>) => void;\nexport class AsyncPipeline<TData, TResult> {\n private _list: [TData, AsyncUnitOfWork<TData, TResult>][] = [];\n private _hasErrored: boolean = false; // Flag to prevent calling done on error\n\n filter(done: CallbackResult<TResult[]>) {\n\n this._hasErrored = false; // Reset error flag on new execution\n let currentData: TResult[] = [];\n\n if (this._list.length === 0) {\n queueMicrotask(() => done(Result.success()));\n return;\n }\n\n let index = 0;\n let isRunning = false; // Guard against overlapping trampoline calls\n\n try {\n // --- Revised Completion Logic --- (Moved up for clarity)\n const finalStepSentinel = (): StepResult<any> => { // A special step function for the very end\n // Only call done if no error has occurred\n if (!this._hasErrored) {\n queueMicrotask(() => done(Result.success(currentData)));\n }\n return null; // Stop the trampoline\n };\n\n const createStepRevised = (idx: number): TrampolineStep<any> => {\n return () => {\n if (this._hasErrored) return null; // Stop if an error occurred elsewhere\n\n if (idx >= this._list.length) {\n return finalStepSentinel(); // Execute the dedicated final step\n }\n\n const [payload, processor] = this._list[idx];\n // Initialize syncCallbackResult to null to satisfy StepResult type\n let syncCallbackResult: StepResult<any> = null;\n let calledSync = false;\n\n try {\n processor(payload, (result) => {\n // --- Error Handling ---\n if (result.ok === Result.ERROR) {\n console.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);\n this._hasErrored = true; // Set flag\n // Throw the error to be caught by outer try...catch blocks\n throw result.error;\n }\n // --- /Error Handling ---\n\n // If no error, proceed as before\n currentData.push(result.data);\n index = idx + 1; // Update index for the next step\n const nextStep = createStepRevised(index); // Use updated index\n\n if (isRunning) {\n // Callback was synchronous\n syncCallbackResult = nextStep; // Store next step function\n calledSync = true;\n } else {\n // Callback was asynchronous, restart trampoline\n trampoline(nextStep);\n }\n });\n } catch (error) {\n if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback\n console.error(`Error thrown by processor at index ${idx} or its callback:`, error);\n this._hasErrored = true;\n }\n // Rethrow to be caught by the trampoline's catch block\n throw error;\n }\n\n if (calledSync) {\n // Return the next step function for the sync loop\n return syncCallbackResult;\n } else {\n // Pause trampoline for async, loop will stop as step returns null\n return null;\n }\n };\n };\n\n // The trampoline loop\n const trampoline = (step: TrampolineStep<any> | null) => {\n\n if (isRunning) {\n return;\n }\n\n isRunning = true;\n let currentStep = step;\n\n while (typeof currentStep === 'function') {\n try {\n // Stop immediately if an error was flagged elsewhere\n if (this._hasErrored) {\n currentStep = null;\n break;\n }\n currentStep = currentStep(); // Execute step, get next step or null\n } catch (trampolineError) {\n // Catch errors propagated from step execution (processor or callback errors)\n if (!this._hasErrored) { // Avoid double logging\n console.error(\"Error during trampoline step execution:\", trampolineError);\n this._hasErrored = true;\n }\n currentStep = null; // Stop the loop\n // We don't call `done` here because an error occurred.\n // The application should handle the uncaught exception if desired.\n break; // Explicitly break loop on error\n }\n }\n // Loop ends when currentStep is null or loop is broken by error\n isRunning = false;\n\n // Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.\n };\n\n // --- Start the process ---\n index = 0; // Reset index\n trampoline(createStepRevised(0)); // Start with the revised step creator\n } catch (error: any) {\n done(Result.error(error));\n }\n }\n\n pipe(data: TData, processor: AsyncUnitOfWork<TData, TResult>) {\n this._list.push([data, processor]);\n }\n\n pipeEach(items: TData[], processor: AsyncUnitOfWork<TData, TResult>) {\n for (let i = 0, length = items.length; i < length; i++) {\n this.pipe(items[i], processor);\n }\n }\n}\n\nexport type UnitOfWork = (done: CallbackResult<never>) => void;\n\n/**\n * Processes functions with callbacks asynchronously.\n * \n * This pipeline handles work items that contain callback functions,\n * executing them in an asynchronous manner while maintaining proper\n * flow control and error handling.\n */\nexport class WorkPipeline {\n private unitsOfWork: UnitOfWork[] = [];\n private _hasErrored: boolean = false; // Flag to prevent calling done on error\n\n filter(done: CallbackResult<never>) {\n\n this._hasErrored = false; // Reset error flag on new execution\n\n if (this.unitsOfWork.length === 0) {\n queueMicrotask(() => done(Result.success()));\n return;\n }\n\n let index = 0;\n let isRunning = false; // Guard against overlapping trampoline calls\n\n try {\n // --- Revised Completion Logic --- (Moved up for clarity)\n const finalStepSentinel = (): StepResult<never> => { // A special step function for the very end\n // Only call done if no error has occurred\n if (!this._hasErrored) {\n queueMicrotask(() => done(Result.success()));\n }\n return null; // Stop the trampoline\n };\n\n const createStepRevised = (idx: number): TrampolineStep<any> => {\n return () => {\n if (this._hasErrored) return null; // Stop if an error occurred elsewhere\n\n if (idx >= this.unitsOfWork.length) {\n return finalStepSentinel(); // Execute the dedicated final step\n }\n\n const processor = this.unitsOfWork[idx];\n // Initialize syncCallbackResult to null to satisfy StepResult type\n let syncCallbackResult: StepResult<any> = null;\n let calledSync = false;\n\n try {\n processor((result) => {\n // --- Error Handling ---\n if (result.ok === Result.ERROR) {\n console.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);\n this._hasErrored = true; // Set flag\n // Throw the error to be caught by outer try...catch blocks\n throw result.error;\n }\n // --- /Error Handling ---\n\n // If no error, proceed as before\n index = idx + 1; // Update index for the next step\n const nextStep = createStepRevised(index); // Use updated index\n\n if (isRunning) {\n // Callback was synchronous\n syncCallbackResult = nextStep; // Store next step function\n calledSync = true;\n } else {\n // Callback was asynchronous, restart trampoline\n trampoline(nextStep);\n }\n });\n } catch (error) {\n if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback\n console.error(`Error thrown by processor at index ${idx} or its callback:`, error);\n this._hasErrored = true;\n }\n // Rethrow to be caught by the trampoline's catch block\n throw error;\n }\n\n if (calledSync) {\n // Return the next step function for the sync loop\n return syncCallbackResult;\n } else {\n // Pause trampoline for async, loop will stop as step returns null\n return null;\n }\n };\n };\n\n // The trampoline loop\n const trampoline = (step: TrampolineStep<any> | null) => {\n\n if (isRunning) {\n return;\n }\n\n isRunning = true;\n let currentStep = step;\n\n while (typeof currentStep === 'function') {\n try {\n // Stop immediately if an error was flagged elsewhere\n if (this._hasErrored) {\n currentStep = null;\n break;\n }\n currentStep = currentStep(); // Execute step, get next step or null\n } catch (trampolineError) {\n // Catch errors propagated from step execution (processor or callback errors)\n if (!this._hasErrored) { // Avoid double logging\n console.error(\"Error during trampoline step execution:\", trampolineError);\n this._hasErrored = true;\n }\n currentStep = null; // Stop the loop\n // We don't call `done` here because an error occurred.\n // The application should handle the uncaught exception if desired.\n break; // Explicitly break loop on error\n }\n }\n // Loop ends when currentStep is null or loop is broken by error\n isRunning = false;\n\n // Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.\n };\n\n // --- Start the process ---\n index = 0; // Reset index\n trampoline(createStepRevised(0)); // Start with the revised step creator\n } catch (error: any) {\n done(Result.error(error));\n }\n }\n\n pipe(work: UnitOfWork) {\n this.unitsOfWork.push(work);\n }\n}","import { PartialResultType, PluginEventPartialResultType, PluginEventResultType, ResultType } from \"./types\";\n\nabstract class BaseResult {\n static ERROR = \"error\" as const;\n static SUCCESS = \"success\" as const;\n static PARTIAL = \"partial\" as const;\n\n static resolve<T>(result: ResultType<T> | PartialResultType<T>, resolve: (data: T) => void, reject: (error?: any) => void) {\n if (result.ok === BaseResult.SUCCESS) {\n resolve(result.data);\n return;\n }\n\n if (result.ok === BaseResult.PARTIAL) {\n reject({\n partial: result.data,\n error: result.error\n });\n return;\n }\n\n reject(result.error);\n }\n\n static assertSuccess<T>(result: any): asserts result is { ok: \"success\"; data: T } {\n if (result.ok !== BaseResult.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n\nexport class Result extends BaseResult {\n static success<T>(data: T): ResultType<T>;\n static success<T>(): ResultType<never>;\n static success<T>(data?: T): ResultType<T> {\n return {\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(error: any): ResultType<T> {\n return {\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(data: T, error: any): PartialResultType<T> {\n return {\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n}\n\nexport class PluginEventResult extends BaseResult {\n static success<T>(id: string, data: T): PluginEventResultType<T>;\n static success<T>(id: string): PluginEventResultType<never>;\n static success<T>(id: string, data?: T): PluginEventResultType<T> {\n return {\n id,\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(id: string, error: any): PluginEventResultType<T> {\n return {\n id,\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(id: string, data: T, error: any): PluginEventPartialResultType<T> {\n return {\n id,\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n\n static assertSuccess<T>(result: PluginEventResultType<T>): asserts result is { ok: \"success\"; data: T; id: string } {\n if (result.ok !== Result.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './SyncronousQueue';\nexport * from './TrampolinePipeline';"],"names":[],"mappings":";;;;;;;;;;AAEO,MAAM,eAAe;IAEP,MAAM,GAA2B,EAAE,CAAC;IAC7C,QAAQ,GAAgC,IAAI,CAAC;IAErD,OAAO,CAAC,UAAgC;QACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEO,KAAK;QACT,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpD,OAAO;QACX,CAAC;QAED,kBAAkB;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,IAAI,CAAC;QAE5C,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;YACf,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,IAAI,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC,CAAC;IACN,CAAC;CACJ;;;;;;;;;;;;;;;;AC7B+D;AAazD,MAAM,kBAAkB;IACnB,KAAK,GAA0B,EAAE,CAAC;IAClC,WAAW,GAAY,KAAK,CAAC,CAAC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AI,MAAgC;QACpD,IAAI,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,oCAAoC,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACtF,CAAC;IACL,CAAC;CACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC1FD;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA;;;;ACNA;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D;;;;;;;;;;;;;;;;;;;ACNkC;AACG"}
@@ -250,7 +250,7 @@ class TagCollection {
250
250
  return this.data.keys();
251
251
  }
252
252
  [Symbol.dispose]() {
253
- this.data = null;
253
+ this.data.clear();
254
254
  }
255
255
  [Symbol.iterator]() {
256
256
  return this.data[Symbol.iterator]();
@@ -320,6 +320,39 @@ function forEach(expression, callback) {
320
320
  }
321
321
 
322
322
 
323
+ }),
324
+ "./src/performance/index.ts":
325
+ /*!**********************************!*\
326
+ !*** ./src/performance/index.ts ***!
327
+ \**********************************/
328
+ (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
329
+ __webpack_require__.r(__webpack_exports__);
330
+ __webpack_require__.d(__webpack_exports__, {
331
+ measure: () => (measure),
332
+ now: () => (now)
333
+ });
334
+ const measurements = {};
335
+ const now = () => {
336
+ if (typeof performance !== 'undefined' && performance.now) {
337
+ // Browser or modern Node.js
338
+ return performance.now();
339
+ }
340
+ // Fallback for older environments
341
+ return Date.now();
342
+ };
343
+ const measure = {
344
+ start: (name) => {
345
+ measurements[name] = now();
346
+ },
347
+ end: (name) => {
348
+ const start = measurements[name];
349
+ delete measurements[name];
350
+ const delta = now() - start;
351
+ console.log(`[ROUTIER] - Performance: ${name} took ${delta}`);
352
+ }
353
+ };
354
+
355
+
323
356
  }),
324
357
  "./src/pipeline/TrampolinePipeline.ts":
325
358
  /*!********************************************!*\
@@ -1073,23 +1106,27 @@ __webpack_require__.d(__webpack_exports__, {
1073
1106
  OptimisticReplicationDbPlugin: () => (OptimisticReplicationDbPlugin)
1074
1107
  });
1075
1108
  /* ESM import */var _results__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../results */ "./src/results/Result.ts");
1076
- /* ESM import */var _pipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../pipeline */ "./src/pipeline/TrampolinePipeline.ts");
1109
+ /* ESM import */var _pipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../pipeline */ "./src/pipeline/TrampolinePipeline.ts");
1077
1110
  /* ESM import */var _query__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../query */ "./src/plugins/query/Query.ts");
1078
1111
  /* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utilities */ "./src/utilities/uuid.ts");
1079
- /* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../utilities */ "./src/utilities/replication.ts");
1112
+ /* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../utilities */ "./src/utilities/replication.ts");
1080
1113
  /* ESM import */var _collections__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../collections */ "./src/collections/Changes.ts");
1114
+ /* ESM import */var _performance__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../performance */ "./src/performance/index.ts");
1081
1115
 
1082
1116
 
1083
1117
  7;
1084
1118
 
1085
1119
 
1086
1120
 
1121
+
1087
1122
  const getMemoryPluginCollectionSize = (plugin, schema) => {
1088
1123
  if ("getCollectionSize" in plugin && typeof plugin.getCollectionSize === "function") {
1089
1124
  return plugin.getCollectionSize(schema.collectionName);
1090
1125
  }
1091
1126
  throw new Error("Cannot get size of collection for MemoryPlugin, not an instance of MemoryPlugin");
1092
1127
  };
1128
+ const MAX_HYDRATION_WAIT_MS = 60_000; // 60 seconds max wait
1129
+ const HYDRATION_POLL_INTERVAL_MS = 10; // Check ever 10 ms
1093
1130
  let hydrationStatus = "hydration-not-started";
1094
1131
  class OptimisticReplicationDbPlugin {
1095
1132
  plugins;
@@ -1117,7 +1154,6 @@ class OptimisticReplicationDbPlugin {
1117
1154
  if (collectionSize === 0 && hydrationStatus === "hydration-not-started") {
1118
1155
  // Notify the cache that the db was hydrated right away
1119
1156
  hydrationStatus = "hydration-pending";
1120
- console.log('[ROUTIER] - Optimistic Query', hydrationStatus);
1121
1157
  // nothing is hydrated, let's try and hydrate before querying
1122
1158
  // Memory plugin might not be hydrated, lets hydrate it for the targeted schema only,
1123
1159
  // Other queries will do the same and hydrate if needed
@@ -1132,28 +1168,20 @@ class OptimisticReplicationDbPlugin {
1132
1168
  if (sourceResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
1133
1169
  // Notify that hydration failed
1134
1170
  hydrationStatus = "hydration-error";
1135
- console.log("[ROUTIER] - Hydration Error - Source Query", sourceResult);
1136
- done(sourceResult);
1137
- return;
1138
- }
1139
- if (sourceResult == null || (Array.isArray(sourceResult.data) && sourceResult.data.length === 0)) {
1140
- // Notify that hydration had no data
1141
- hydrationStatus = "hydration-error";
1142
- console.log("[ROUTIER] - Hydration Error - No Data", sourceResult);
1143
1171
  done(sourceResult);
1144
1172
  return;
1145
1173
  }
1146
- if (Array.isArray(sourceResult.data) === false) {
1174
+ // Source plugin can have no data, still should succeed
1175
+ if (Array.isArray(sourceResult.data.value) === false) {
1147
1176
  // Notify that hydration failed
1148
1177
  hydrationStatus = "hydration-error";
1149
- console.log("[ROUTIER] - Hydration Error - Bad Result", sourceResult);
1150
1178
  done(_results__WEBPACK_IMPORTED_MODULE_2__.PluginEventResult.error(event.id, "Query result is not an array"));
1151
1179
  return;
1152
1180
  }
1153
1181
  const changesCollection = new _collections__WEBPACK_IMPORTED_MODULE_3__.BulkPersistChanges();
1154
1182
  const schemaChanges = changesCollection.resolve(event.operation.schema.id);
1155
1183
  // Add the existing items into the persist payload as adds
1156
- schemaChanges.adds = sourceResult.data;
1184
+ schemaChanges.adds = sourceResult.data.value;
1157
1185
  readPlugin.bulkPersist({
1158
1186
  id: (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)(8),
1159
1187
  schemas: event.schemas,
@@ -1163,7 +1191,6 @@ class OptimisticReplicationDbPlugin {
1163
1191
  if (readPersistResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
1164
1192
  // Notify that hydration failed
1165
1193
  hydrationStatus = "hydration-error";
1166
- console.log("[ROUTIER] - Hydration Error - Could Not Save", readPersistResult);
1167
1194
  done(readPersistResult);
1168
1195
  return;
1169
1196
  }
@@ -1174,6 +1201,41 @@ class OptimisticReplicationDbPlugin {
1174
1201
  });
1175
1202
  return;
1176
1203
  }
1204
+ if (hydrationStatus === "hydration-error") {
1205
+ done(_results__WEBPACK_IMPORTED_MODULE_2__.PluginEventResult.error(event.id, "Hydration failed, unable to query read plugin"));
1206
+ return;
1207
+ }
1208
+ // If hydration is pending, do not query empty collection, wait for hydration
1209
+ if (hydrationStatus === "hydration-pending") {
1210
+ const start = (0,_performance__WEBPACK_IMPORTED_MODULE_4__.now)();
1211
+ const pollHydrationStatus = () => {
1212
+ const delta = (0,_performance__WEBPACK_IMPORTED_MODULE_4__.now)() - start;
1213
+ if (delta > MAX_HYDRATION_WAIT_MS) {
1214
+ hydrationStatus = "hydration-error";
1215
+ done(_results__WEBPACK_IMPORTED_MODULE_2__.PluginEventResult.error(event.id, `Hydration timeout: exceeded maximum wait time of ${MAX_HYDRATION_WAIT_MS}ms`));
1216
+ return;
1217
+ }
1218
+ if (hydrationStatus === "hydration-error") {
1219
+ done(_results__WEBPACK_IMPORTED_MODULE_2__.PluginEventResult.error(event.id, "Hydration failed, unable to query read plugin"));
1220
+ return;
1221
+ }
1222
+ if (hydrationStatus === "hydration-success") {
1223
+ // Hydration completed successfully, proceed with query
1224
+ readPlugin.query(event, (readResult) => {
1225
+ if (readResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
1226
+ done(readResult);
1227
+ return;
1228
+ }
1229
+ done(readResult);
1230
+ });
1231
+ return;
1232
+ }
1233
+ // Still pending, check again after interval
1234
+ setTimeout(pollHydrationStatus, HYDRATION_POLL_INTERVAL_MS);
1235
+ };
1236
+ pollHydrationStatus();
1237
+ return;
1238
+ }
1177
1239
  // Collection is hydrated for the targeted collection and should be in sync
1178
1240
  readPlugin.query(event, (readResult) => {
1179
1241
  if (readResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
@@ -1190,7 +1252,7 @@ class OptimisticReplicationDbPlugin {
1190
1252
  }
1191
1253
  destroy(event, done) {
1192
1254
  try {
1193
- const workPipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_4__.WorkPipeline();
1255
+ const workPipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_5__.WorkPipeline();
1194
1256
  const plugins = [this.plugins.source, ...this.plugins.replicas];
1195
1257
  for (let i = 0, length = plugins.length; i < length; i++) {
1196
1258
  workPipeline.pipe((done) => plugins[i].destroy(event, done));
@@ -1209,7 +1271,7 @@ class OptimisticReplicationDbPlugin {
1209
1271
  }
1210
1272
  bulkPersist(event, done) {
1211
1273
  try {
1212
- const workPipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_4__.WorkPipeline();
1274
+ const workPipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_5__.WorkPipeline();
1213
1275
  const deferredPlugins = [this.plugins.source, ...this.plugins.replicas];
1214
1276
  // Since we are doing optimistic, we insert into the read plugin first and assume later plugins will succeed
1215
1277
  // This means the read plugin will generate ids for the source plugin
@@ -1229,7 +1291,7 @@ class OptimisticReplicationDbPlugin {
1229
1291
  const optimisticBulkPersistChanges = new _collections__WEBPACK_IMPORTED_MODULE_3__.BulkPersistChanges();
1230
1292
  // make sure we swap the adds here, that way we can make sure other persist events
1231
1293
  // don't take their additions and try to change subsequent calls
1232
- (0,_utilities__WEBPACK_IMPORTED_MODULE_5__.resolveBulkPersistChanges)(event, r.data, optimisticBulkPersistChanges);
1294
+ (0,_utilities__WEBPACK_IMPORTED_MODULE_6__.resolveBulkPersistChanges)(event, r.data, optimisticBulkPersistChanges);
1233
1295
  for (let i = 0, length = deferredPlugins.length; i < length; i++) {
1234
1296
  workPipeline.pipe((d) => {
1235
1297
  const plugin = deferredPlugins[i];