diff --git a/packages/core-storage/src/pouch-db/services/pouch-envelope.service.ts b/packages/core-storage/src/pouch-db/services/pouch-envelope.service.ts index 8ed0a59..8bb441f 100644 --- a/packages/core-storage/src/pouch-db/services/pouch-envelope.service.ts +++ b/packages/core-storage/src/pouch-db/services/pouch-envelope.service.ts @@ -52,16 +52,6 @@ export class PouchEnvelopeService extends Po // ─── Private Helpers ──────────────────────────────────────── - /** - * Build a case-insensitive regex pattern for keyword search - * without relying on `$options` (which PouchDB doesn't support). - */ - private toContainsRegex(keyword: string): string { - return keyword - .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') // escape special regex chars - .replace(/[a-zA-Z]/g, (c) => `[${c.toLowerCase()}${c.toUpperCase()}]`); // case-insensitive - } - private buildEnvelope(id: string, payload: Record): Omit { return { _id: `${this.entity}:${id}`, @@ -311,19 +301,4 @@ export class PouchEnvelopeService extends Po index: { fields, ...(name ? { name } : {}) }, }); } - - /** - * List currently defined indexes. Useful for debugging with `explain()`. - */ - async listIndexes(): Promise> { - return this.raw.getIndexes(); - } - - /** - * Explain how a given selector will be executed — shows which index (if any) is used. - * Returns `index.name === '_all_docs'` when the query falls back to a full scan. - */ - async explain(options: PouchDB.Find.FindRequest): Promise { - return (this.raw as any).explain(options as PouchDB.Find.FindRequest); - } } diff --git a/packages/core-storage/src/pouch-db/services/pouch.service.ts b/packages/core-storage/src/pouch-db/services/pouch.service.ts index 2e02175..befae20 100644 --- a/packages/core-storage/src/pouch-db/services/pouch.service.ts +++ b/packages/core-storage/src/pouch-db/services/pouch.service.ts @@ -88,6 +88,16 @@ export class PouchService { return this._status; } + /** + * Build a case-insensitive regex pattern for keyword search + * without relying on `$options` (which PouchDB doesn't support). + */ + toContainsRegex(keyword: string): string { + return keyword + .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') // escape special regex chars + .replace(/[a-zA-Z]/g, (c) => `[${c.toLowerCase()}${c.toUpperCase()}]`); // case-insensitive + } + /** Turn sync ON for this DB. No-op if already connected or no remoteUrl configured. */ connect(): void { this.startLiveSync(); @@ -294,4 +304,21 @@ export class PouchService { this.listeners.delete(callback); }; } + + // ─── New Methods (no base equivalent) ─────────────────────── + + /** + * List currently defined indexes. Useful for debugging with `explain()`. + */ + async listIndexes(): Promise> { + return this.raw.getIndexes(); + } + + /** + * Explain how a given selector will be executed — shows which index (if any) is used. + * Returns `index.name === '_all_docs'` when the query falls back to a full scan. + */ + async explain(options: PouchDB.Find.FindRequest): Promise { + return (this.raw as any).explain(options as PouchDB.Find.FindRequest); + } }