couchdb-web-node-plugin 1.0.747 → 1.0.749

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "couchdb-web-node-plugin",
3
- "version": "1.0.747",
3
+ "version": "1.0.749",
4
4
  "description": "A couchdb server, model instance conflict handler, rest api, authentication, session management, schema validator and model relation guarantee for webNode.",
5
5
  "keywords": [
6
6
  "api",
package/type.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ChildProcess } from 'child_process';
2
2
  import { AnyFunction, Mapping, PlainObject, Primitive, ProcessCloseReason, UTILITY_SCOPE } from 'clientnode';
3
- import { Configuration as BaseConfiguration, PluginHandler as BasePluginHandler, ServicePromises as BaseServicePromises, Services as BaseServices, ServicePromisesState as BaseServicePromisesState, ServicesState as BaseServicesState } from 'web-node/type';
4
- import { Server as HTTPServer } from 'http';
5
3
  import { Express } from 'express-serve-static-core';
4
+ import { IncomingMessage as IncomingHTTPMessage, Server as HTTPServer, ServerResponse as HTTP1ServerResponse } from 'http';
5
+ import { Configuration as BaseConfiguration, PluginHandler as BasePluginHandler, ServicePromises as BaseServicePromises, Services as BaseServices, ServicePromisesState as BaseServicePromisesState, ServicesState as BaseServicesState } from 'web-node/type';
6
6
  export type Attachment = PouchDB.Core.Attachment & {
7
7
  content_type?: PouchDB.Core.Attachment['content_type'];
8
8
  contentType?: PouchDB.Core.Attachment['content_type'];
@@ -33,6 +33,7 @@ export type DocumentGetMeta = PouchDB.Core.GetMeta;
33
33
  export type DocumentIDMeta = PouchDB.Core.IdMeta;
34
34
  export type DocumentRevisionIDMeta = PouchDB.Core.RevisionIdMeta;
35
35
  export type FindRequest<Type extends object> = PouchDB.Find.FindRequest<Type>;
36
+ export type FindResponse<Type extends object> = PouchDB.Find.FindResponse<Type>;
36
37
  export type DeleteIndexOptions = PouchDB.Find.DeleteIndexOptions;
37
38
  export type GetOptions = PouchDB.Core.GetOptions;
38
39
  export type PutOptions = PouchDB.Core.Options;
@@ -318,13 +319,13 @@ export interface CouchDB<Type extends object = Mapping<unknown>> {
318
319
  connection: Connection<Type>;
319
320
  connector: Connector;
320
321
  server: {
321
- express?: Express;
322
- expressPouchDB?: Express;
322
+ expressInstance?: Express;
323
+ expressPouchDBInstance?: Express;
323
324
  process?: ChildProcess | HTTPServer;
324
325
  reject: (value: Error | ProcessCloseReason) => void;
325
326
  resolve: (reason?: ProcessCloseReason) => void;
326
327
  restart: (state: State) => Promise<void>;
327
- start: (services: Services, configuration: Configuration) => Promise<void>;
328
+ start: (state: State) => Promise<void>;
328
329
  stop: (services: Services, configuration: Configuration) => Promise<void>;
329
330
  runner: BinaryRunner | InPlaceRunner;
330
331
  };
@@ -361,6 +362,29 @@ export interface PluginHandler extends BasePluginHandler {
361
362
  * @returns Promise resolving to nothing.
362
363
  */
363
364
  restartCouchdb?(state: State): Promise<void>;
365
+ /**
366
+ * Hook before registering pouchdb routes into the express server
367
+ * instance.
368
+ * @param state - Application state.
369
+ * @returns Promise resolving to find result.
370
+ */
371
+ onPouchDBFind?(state: State<{
372
+ request: IncomingHTTPMessage & {
373
+ body: FindRequest<PlainObject>;
374
+ };
375
+ response: HTTP1ServerResponse;
376
+ result: FindResponse<object>;
377
+ }>): Promise<FindResponse<object> | undefined>;
378
+ /**
379
+ * Hook before registering pouchdb routes into the express server
380
+ * instance.
381
+ * @param state - Application state.
382
+ * @returns Promise resolving to nothing.
383
+ */
384
+ initializeExpressPouchDB?(state: State<{
385
+ expressInstance: Express;
386
+ expressPouchDBInstance: Express;
387
+ }>): Promise<void>;
364
388
  }
365
389
  export interface EmptyEvaluationErrorData {
366
390
  empty: string;