@decaf-ts/for-nano 0.9.0 → 0.11.0
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/lib/cjs/index.cjs +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/types/NanoDispatch.d.cts +1 -1
- package/lib/types/NanoDispatch.d.mts +1 -1
- package/lib/types/NanoRepository.d.cts +1 -1
- package/lib/types/NanoRepository.d.mts +1 -1
- package/lib/types/adapter.d.cts +3 -3
- package/lib/types/adapter.d.mts +3 -3
- package/lib/types/index.d.cts +5 -5
- package/lib/types/index.d.mts +5 -5
- package/package.json +1 -1
- package/lib/types/NanoDispatch.d.ts +0 -119
- package/lib/types/NanoRepository.d.ts +0 -17
- package/lib/types/adapter.d.ts +0 -449
- package/lib/types/constants.d.ts +0 -7
- package/lib/types/index.d.ts +0 -23
- package/lib/types/types.d.ts +0 -39
package/lib/cjs/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ __exportStar(require("./adapter.cjs"), exports);
|
|
|
35
35
|
* @const VERSION
|
|
36
36
|
* @memberOf module:for-nano
|
|
37
37
|
*/
|
|
38
|
-
exports.VERSION = "0.
|
|
38
|
+
exports.VERSION = "0.10.0";
|
|
39
39
|
/**
|
|
40
40
|
* @description Package version identifier
|
|
41
41
|
* @summary Stores the current package version string for the for-nano module
|
package/lib/esm/index.js
CHANGED
|
@@ -18,7 +18,7 @@ export * from "./adapter.js";
|
|
|
18
18
|
* @const VERSION
|
|
19
19
|
* @memberOf module:for-nano
|
|
20
20
|
*/
|
|
21
|
-
export const VERSION = "0.
|
|
21
|
+
export const VERSION = "0.10.0";
|
|
22
22
|
/**
|
|
23
23
|
* @description Package version identifier
|
|
24
24
|
* @summary Stores the current package version string for the for-nano module
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Adapter, Context, ContextualArgs, Dispatch } from "@decaf-ts/core";
|
|
2
2
|
import { DatabaseChangesResponse, DatabaseChangesResultItem, DocumentScope, RequestError } from "nano";
|
|
3
3
|
import { MangoQuery } from "@decaf-ts/for-couchdb";
|
|
4
|
-
import { NanoConfig, NanoFlags } from "./types.
|
|
4
|
+
import { NanoConfig, NanoFlags } from "./types.d.cts";
|
|
5
5
|
/**
|
|
6
6
|
* @description Dispatcher for Nano database change events
|
|
7
7
|
* @summary Handles the subscription to and processing of database change events from a Nano database,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Adapter, Context, ContextualArgs, Dispatch } from "@decaf-ts/core";
|
|
2
2
|
import { DatabaseChangesResponse, DatabaseChangesResultItem, DocumentScope, RequestError } from "nano";
|
|
3
3
|
import { MangoQuery } from "@decaf-ts/for-couchdb";
|
|
4
|
-
import { NanoConfig, NanoFlags } from "./types.
|
|
4
|
+
import { NanoConfig, NanoFlags } from "./types.d.mts";
|
|
5
5
|
/**
|
|
6
6
|
* @description Dispatcher for Nano database change events
|
|
7
7
|
* @summary Handles the subscription to and processing of database change events from a Nano database,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
2
|
import { CouchDBRepository } from "@decaf-ts/for-couchdb";
|
|
3
|
-
import { NanoAdapter } from "./adapter.
|
|
3
|
+
import { NanoAdapter } from "./adapter.d.cts";
|
|
4
4
|
import { Constructor } from "@decaf-ts/decoration";
|
|
5
5
|
import { ContextOf, FlagsOf } from "@decaf-ts/core";
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
2
|
import { CouchDBRepository } from "@decaf-ts/for-couchdb";
|
|
3
|
-
import { NanoAdapter } from "./adapter.
|
|
3
|
+
import { NanoAdapter } from "./adapter.d.mts";
|
|
4
4
|
import { Constructor } from "@decaf-ts/decoration";
|
|
5
5
|
import { ContextOf, FlagsOf } from "@decaf-ts/core";
|
|
6
6
|
/**
|
package/lib/types/adapter.d.cts
CHANGED
|
@@ -2,10 +2,10 @@ import { OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
|
2
2
|
import { CouchDBAdapter, MangoQuery, ViewResponse } from "@decaf-ts/for-couchdb";
|
|
3
3
|
import { DocumentScope, ServerScope } from "nano";
|
|
4
4
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
-
import { NanoConfig, NanoFlags } from "./types.
|
|
5
|
+
import { NanoConfig, NanoFlags } from "./types.d.cts";
|
|
6
6
|
import { Adapter, Context, ContextOf, ContextualArgs, MaybeContextualArg, RelationsMetadata, Repository } from "@decaf-ts/core";
|
|
7
|
-
import { NanoRepository } from "./NanoRepository.
|
|
8
|
-
import { NanoDispatch } from "./NanoDispatch.
|
|
7
|
+
import { NanoRepository } from "./NanoRepository.d.cts";
|
|
8
|
+
import { NanoDispatch } from "./NanoDispatch.d.cts";
|
|
9
9
|
import { Constructor } from "@decaf-ts/decoration";
|
|
10
10
|
/**
|
|
11
11
|
* @description Sets the creator or updater field in a model based on the user in the context
|
package/lib/types/adapter.d.mts
CHANGED
|
@@ -2,10 +2,10 @@ import { OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
|
2
2
|
import { CouchDBAdapter, MangoQuery, ViewResponse } from "@decaf-ts/for-couchdb";
|
|
3
3
|
import { DocumentScope, ServerScope } from "nano";
|
|
4
4
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
-
import { NanoConfig, NanoFlags } from "./types.
|
|
5
|
+
import { NanoConfig, NanoFlags } from "./types.d.mts";
|
|
6
6
|
import { Adapter, Context, ContextOf, ContextualArgs, MaybeContextualArg, RelationsMetadata, Repository } from "@decaf-ts/core";
|
|
7
|
-
import { NanoRepository } from "./NanoRepository.
|
|
8
|
-
import { NanoDispatch } from "./NanoDispatch.
|
|
7
|
+
import { NanoRepository } from "./NanoRepository.d.mts";
|
|
8
|
+
import { NanoDispatch } from "./NanoDispatch.d.mts";
|
|
9
9
|
import { Constructor } from "@decaf-ts/decoration";
|
|
10
10
|
/**
|
|
11
11
|
* @description Sets the creator or updater field in a model based on the user in the context
|
package/lib/types/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./constants.
|
|
2
|
-
export * from "./NanoRepository.
|
|
3
|
-
export * from "./types.
|
|
4
|
-
export * from "./adapter.
|
|
1
|
+
export * from "./constants.d.cts";
|
|
2
|
+
export * from "./NanoRepository.d.cts";
|
|
3
|
+
export * from "./types.d.cts";
|
|
4
|
+
export * from "./adapter.d.cts";
|
|
5
5
|
/**
|
|
6
6
|
* @description A TypeScript module for interacting with Nano databases
|
|
7
7
|
* @summary This module provides a set of utilities, classes, and types for working with Nano databases. It includes repository patterns, adapters, and type definitions to simplify database operations. Key exports include {@link NanoAdapter}, {@link NanoRepository}, {@link NanoFlags}, and {@link NanoFlavour}.
|
|
@@ -13,7 +13,7 @@ export * from "./adapter.cjs";
|
|
|
13
13
|
* @const VERSION
|
|
14
14
|
* @memberOf module:for-nano
|
|
15
15
|
*/
|
|
16
|
-
export declare const VERSION = "0.
|
|
16
|
+
export declare const VERSION = "0.10.0";
|
|
17
17
|
/**
|
|
18
18
|
* @description Package version identifier
|
|
19
19
|
* @summary Stores the current package version string for the for-nano module
|
package/lib/types/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./constants.
|
|
2
|
-
export * from "./NanoRepository.
|
|
3
|
-
export * from "./types.
|
|
4
|
-
export * from "./adapter.
|
|
1
|
+
export * from "./constants.d.mts";
|
|
2
|
+
export * from "./NanoRepository.d.mts";
|
|
3
|
+
export * from "./types.d.mts";
|
|
4
|
+
export * from "./adapter.d.mts";
|
|
5
5
|
/**
|
|
6
6
|
* @description A TypeScript module for interacting with Nano databases
|
|
7
7
|
* @summary This module provides a set of utilities, classes, and types for working with Nano databases. It includes repository patterns, adapters, and type definitions to simplify database operations. Key exports include {@link NanoAdapter}, {@link NanoRepository}, {@link NanoFlags}, and {@link NanoFlavour}.
|
|
@@ -13,7 +13,7 @@ export * from "./adapter.js";
|
|
|
13
13
|
* @const VERSION
|
|
14
14
|
* @memberOf module:for-nano
|
|
15
15
|
*/
|
|
16
|
-
export declare const VERSION = "0.
|
|
16
|
+
export declare const VERSION = "0.10.0";
|
|
17
17
|
/**
|
|
18
18
|
* @description Package version identifier
|
|
19
19
|
* @summary Stores the current package version string for the for-nano module
|
package/package.json
CHANGED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { Adapter, Context, ContextualArgs, Dispatch } from "@decaf-ts/core";
|
|
2
|
-
import { DatabaseChangesResponse, DatabaseChangesResultItem, DocumentScope, RequestError } from "nano";
|
|
3
|
-
import { MangoQuery } from "@decaf-ts/for-couchdb";
|
|
4
|
-
import { NanoConfig, NanoFlags } from "./types";
|
|
5
|
-
/**
|
|
6
|
-
* @description Dispatcher for Nano database change events
|
|
7
|
-
* @summary Handles the subscription to and processing of database change events from a Nano database,
|
|
8
|
-
* notifying observers when documents are created, updated, or deleted
|
|
9
|
-
* @template DocumentScope - The Nano document scope type
|
|
10
|
-
* @param {number} [timeout=5000] - Timeout in milliseconds for change feed requests
|
|
11
|
-
* @class NanoDispatch
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* // Create a dispatcher for a Nano database
|
|
15
|
-
* const db = server.db.use('my_database');
|
|
16
|
-
* const adapter = new NanoAdapter(db);
|
|
17
|
-
* const dispatch = new NanoDispatch();
|
|
18
|
-
*
|
|
19
|
-
* // The dispatcher will automatically subscribe to changes
|
|
20
|
-
* // and notify observers when documents change
|
|
21
|
-
* ```
|
|
22
|
-
* @mermaid
|
|
23
|
-
* classDiagram
|
|
24
|
-
* class Dispatch {
|
|
25
|
-
* +initialize()
|
|
26
|
-
* +updateObservers()
|
|
27
|
-
* }
|
|
28
|
-
* class NanoDispatch {
|
|
29
|
-
* -observerLastUpdate?: string
|
|
30
|
-
* -attemptCounter: number
|
|
31
|
-
* -timeout: number
|
|
32
|
-
* +constructor(timeout)
|
|
33
|
-
* #changeHandler()
|
|
34
|
-
* #initialize()
|
|
35
|
-
* }
|
|
36
|
-
* Dispatch <|-- NanoDispatch
|
|
37
|
-
*/
|
|
38
|
-
export declare class NanoDispatch extends Dispatch<Adapter<NanoConfig, DocumentScope<any>, MangoQuery, Context<NanoFlags>>> {
|
|
39
|
-
private timeout;
|
|
40
|
-
private observerLastUpdate?;
|
|
41
|
-
private attemptCounter;
|
|
42
|
-
private active;
|
|
43
|
-
private changeFeed?;
|
|
44
|
-
constructor(timeout?: number);
|
|
45
|
-
/**
|
|
46
|
-
* @description Closes the dispatcher
|
|
47
|
-
* @summary Stops the dispatcher and cleans up any active subscriptions or resources
|
|
48
|
-
* @return {Promise<void>} A promise that resolves when the dispatcher has been closed
|
|
49
|
-
*/
|
|
50
|
-
close(...args: ContextualArgs<Context<NanoFlags>>): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* @description Processes database change events
|
|
53
|
-
* @summary Handles the response from the Nano changes feed, processes the changes,
|
|
54
|
-
* and notifies observers about document changes
|
|
55
|
-
* @param {RequestError | null} error - Error object if the request failed
|
|
56
|
-
* @param response - The changes response from Nano
|
|
57
|
-
* @param {any} [headers] - Response headers (unused)
|
|
58
|
-
* @return {Promise<void>} A promise that resolves when all changes have been processed
|
|
59
|
-
* @mermaid
|
|
60
|
-
* sequenceDiagram
|
|
61
|
-
* participant D as NanoDispatch
|
|
62
|
-
* participant L as Logger
|
|
63
|
-
* participant O as Observers
|
|
64
|
-
* Note over D: Receive changes from Nano
|
|
65
|
-
* alt Error in response
|
|
66
|
-
* D->>L: Log error
|
|
67
|
-
* D-->>D: Return early
|
|
68
|
-
* end
|
|
69
|
-
* alt Response is string
|
|
70
|
-
* D->>D: Parse JSON from string
|
|
71
|
-
* end
|
|
72
|
-
* D->>D: Process changes
|
|
73
|
-
* D->>D: Group changes by table and operation
|
|
74
|
-
* loop For each table
|
|
75
|
-
* loop For each operation
|
|
76
|
-
* D->>O: updateObservers(table, operation, ids)
|
|
77
|
-
* D->>D: Update observerLastUpdate
|
|
78
|
-
* D->>L: Log successful dispatch
|
|
79
|
-
* end
|
|
80
|
-
* end
|
|
81
|
-
*/
|
|
82
|
-
protected changeHandler(error: RequestError | null, response: (DatabaseChangesResponse | DatabaseChangesResultItem)[] | string, headers?: any, ctxArg?: Context<NanoFlags>): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* @description Initializes the dispatcher and subscribes to database changes
|
|
85
|
-
* @summary Sets up the continuous changes feed subscription to the Nano database
|
|
86
|
-
* and handles reconnection attempts if the connection fails
|
|
87
|
-
* @return {Promise<void>} A promise that resolves when the subscription is established
|
|
88
|
-
* @mermaid
|
|
89
|
-
* sequenceDiagram
|
|
90
|
-
* participant D as NanoDispatch
|
|
91
|
-
* participant S as subscribeToCouch
|
|
92
|
-
* participant DB as Nano Database
|
|
93
|
-
* participant L as Logger
|
|
94
|
-
* D->>S: Call subscribeToCouch
|
|
95
|
-
* S->>S: Check adapter and native
|
|
96
|
-
* alt No adapter or native
|
|
97
|
-
* S-->>S: throw InternalError
|
|
98
|
-
* end
|
|
99
|
-
* S->>DB: changes(options, changeHandler)
|
|
100
|
-
* alt Success
|
|
101
|
-
* DB-->>S: Subscription established
|
|
102
|
-
* S-->>D: Promise resolves
|
|
103
|
-
* D->>L: Log successful subscription
|
|
104
|
-
* else Error
|
|
105
|
-
* DB-->>S: Error
|
|
106
|
-
* S->>S: Increment attemptCounter
|
|
107
|
-
* alt attemptCounter > 3
|
|
108
|
-
* S->>L: Log error
|
|
109
|
-
* S-->>D: Promise rejects
|
|
110
|
-
* else attemptCounter <= 3
|
|
111
|
-
* S->>L: Log retry
|
|
112
|
-
* S->>S: Wait timeout
|
|
113
|
-
* S->>S: Recursive call to subscribeToCouch
|
|
114
|
-
* end
|
|
115
|
-
* end
|
|
116
|
-
*/
|
|
117
|
-
protected initialize(): Promise<void>;
|
|
118
|
-
private disposeChangeFeed;
|
|
119
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
|
-
import { CouchDBRepository } from "@decaf-ts/for-couchdb";
|
|
3
|
-
import { NanoAdapter } from "./adapter";
|
|
4
|
-
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
-
import { ContextOf, FlagsOf } from "@decaf-ts/core";
|
|
6
|
-
/**
|
|
7
|
-
* @description Type for Nano database repositories
|
|
8
|
-
* @summary A specialized repository type for working with Nano databases, extending the base Repository
|
|
9
|
-
* with Nano-specific adapter, flags, and context types
|
|
10
|
-
* @template M - Type extending Model that this repository will manage
|
|
11
|
-
* @typedef {Repository<M, MangoQuery, NanoAdapter, NanoFlags, Context<NanoFlags>>} NanoRepository
|
|
12
|
-
* @memberOf module:for-nano
|
|
13
|
-
*/
|
|
14
|
-
export declare class NanoRepository<M extends Model> extends CouchDBRepository<M, NanoAdapter> {
|
|
15
|
-
constructor(adapter: NanoAdapter, model: Constructor<M>, force?: boolean);
|
|
16
|
-
override(flags: Partial<FlagsOf<ContextOf<NanoAdapter>>>): this;
|
|
17
|
-
}
|
package/lib/types/adapter.d.ts
DELETED
|
@@ -1,449 +0,0 @@
|
|
|
1
|
-
import { OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
2
|
-
import { CouchDBAdapter, MangoQuery, ViewResponse } from "@decaf-ts/for-couchdb";
|
|
3
|
-
import { DocumentScope, ServerScope } from "nano";
|
|
4
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
-
import { NanoConfig, NanoFlags } from "./types";
|
|
6
|
-
import { Adapter, Context, ContextOf, ContextualArgs, MaybeContextualArg, RelationsMetadata, Repository } from "@decaf-ts/core";
|
|
7
|
-
import { NanoRepository } from "./NanoRepository";
|
|
8
|
-
import { NanoDispatch } from "./NanoDispatch";
|
|
9
|
-
import { Constructor } from "@decaf-ts/decoration";
|
|
10
|
-
/**
|
|
11
|
-
* @description Sets the creator or updater field in a model based on the user in the context
|
|
12
|
-
* @summary Callback function used in decorators to automatically set the created_by or updated_by fields
|
|
13
|
-
* with the username from the context when a document is created or updated
|
|
14
|
-
* @template M - Type extending Model
|
|
15
|
-
* @template R - Type extending NanoRepository<M>
|
|
16
|
-
* @template V - Type extending RelationsMetadata
|
|
17
|
-
* @param {R} this - The repository instance
|
|
18
|
-
* @param {Context<NanoFlags>} context - The operation context containing user information
|
|
19
|
-
* @param {V} data - The relation metadata
|
|
20
|
-
* @param key - The property key to set with the username
|
|
21
|
-
* @param {M} model - The model instance being created or updated
|
|
22
|
-
* @return {Promise<void>} A promise that resolves when the operation is complete
|
|
23
|
-
* @function createdByOnNanoCreateUpdate
|
|
24
|
-
* @memberOf module:for-nano
|
|
25
|
-
* @mermaid
|
|
26
|
-
* sequenceDiagram
|
|
27
|
-
* participant F as createdByOnNanoCreateUpdate
|
|
28
|
-
* participant C as Context
|
|
29
|
-
* participant M as Model
|
|
30
|
-
* F->>C: get("user")
|
|
31
|
-
* C-->>F: user object
|
|
32
|
-
* F->>M: set key to user.name
|
|
33
|
-
* Note over F: If no user in context
|
|
34
|
-
* F-->>F: throw UnsupportedError
|
|
35
|
-
*/
|
|
36
|
-
export declare function createdByOnNanoCreateUpdate<M extends Model, R extends NanoRepository<M>, V extends RelationsMetadata>(this: R, context: ContextOf<R>, data: V, key: keyof M, model: M): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* @description Adapter for interacting with Nano databases
|
|
39
|
-
* @summary Provides a standardized interface for performing CRUD operations on Nano databases,
|
|
40
|
-
* extending the CouchDB adapter with Nano-specific functionality. This adapter handles document
|
|
41
|
-
* creation, reading, updating, and deletion, as well as bulk operations and index management.
|
|
42
|
-
* @template DocumentScope - The Nano document scope type
|
|
43
|
-
* @template NanoFlags - Configuration flags for Nano operations
|
|
44
|
-
* @template Context - Context type for operations
|
|
45
|
-
* @param {DocumentScope<any>} scope - The Nano document scope to use for database operations
|
|
46
|
-
* @param {string} [alias] - Optional alias for the adapter
|
|
47
|
-
* @class NanoAdapter
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* // Connect to a Nano database
|
|
51
|
-
* const server = NanoAdapter.connect('admin', 'password', 'localhost:5984');
|
|
52
|
-
* const db = server.db.use('my_database');
|
|
53
|
-
*
|
|
54
|
-
* // Create an adapter instance
|
|
55
|
-
* const adapter = new NanoAdapter(db);
|
|
56
|
-
*
|
|
57
|
-
* // Use the adapter for database operations
|
|
58
|
-
* const document = await adapter.read('users', '123');
|
|
59
|
-
* ```
|
|
60
|
-
* @mermaid
|
|
61
|
-
* classDiagram
|
|
62
|
-
* class CouchDBAdapter {
|
|
63
|
-
* +flags()
|
|
64
|
-
* +Dispatch()
|
|
65
|
-
* +index()
|
|
66
|
-
* +create()
|
|
67
|
-
* +read()
|
|
68
|
-
* +update()
|
|
69
|
-
* +delete()
|
|
70
|
-
* }
|
|
71
|
-
* class NanoAdapter {
|
|
72
|
-
* +flags()
|
|
73
|
-
* +Dispatch()
|
|
74
|
-
* +index()
|
|
75
|
-
* +create()
|
|
76
|
-
* +createAll()
|
|
77
|
-
* +read()
|
|
78
|
-
* +readAll()
|
|
79
|
-
* +update()
|
|
80
|
-
* +updateAll()
|
|
81
|
-
* +delete()
|
|
82
|
-
* +deleteAll()
|
|
83
|
-
* +raw()
|
|
84
|
-
* +static connect()
|
|
85
|
-
* +static createDatabase()
|
|
86
|
-
* +static deleteDatabase()
|
|
87
|
-
* +static createUser()
|
|
88
|
-
* +static deleteUser()
|
|
89
|
-
* +static decoration()
|
|
90
|
-
* }
|
|
91
|
-
* CouchDBAdapter <|-- NanoAdapter
|
|
92
|
-
*/
|
|
93
|
-
export declare class NanoAdapter extends CouchDBAdapter<NanoConfig, DocumentScope<any>, Context<NanoFlags>> {
|
|
94
|
-
constructor(scope: NanoConfig, alias?: string);
|
|
95
|
-
/**
|
|
96
|
-
* @description Shuts down the adapter instance
|
|
97
|
-
* @summary Cleans up internal resources and clears the cached Nano client instance
|
|
98
|
-
* @return {Promise<void>} A promise that resolves when shutdown completes
|
|
99
|
-
*/
|
|
100
|
-
shutdown(...args: MaybeContextualArg<Context<NanoFlags>>): Promise<void>;
|
|
101
|
-
/**
|
|
102
|
-
* @description Lazily creates and returns the Nano DocumentScope client
|
|
103
|
-
* @summary Uses the adapter configuration to establish a connection and wrap a database scope with credentials
|
|
104
|
-
* @return {DocumentScope<any>} The ready-to-use Nano DocumentScope for the configured database
|
|
105
|
-
*/
|
|
106
|
-
protected getClient(): any;
|
|
107
|
-
/**
|
|
108
|
-
* @description Generates flags for database operations
|
|
109
|
-
* @summary Creates a set of flags for a specific operation, including user information
|
|
110
|
-
* @template M - Type extending Model
|
|
111
|
-
* @param {OperationKeys} operation - The operation being performed (create, read, update, delete)
|
|
112
|
-
* @param {Constructor<M>} model - The model constructor
|
|
113
|
-
* @param {Partial<NanoFlags>} flags - Partial flags to be merged
|
|
114
|
-
* @return {Promise<NanoFlags>} Complete flags for the operation
|
|
115
|
-
*/
|
|
116
|
-
protected flags<M extends Model>(operation: OperationKeys, model: Constructor<M>, flags: Partial<NanoFlags>, ...args: any[]): Promise<NanoFlags>;
|
|
117
|
-
/**
|
|
118
|
-
* @description Creates a new NanoDispatch instance
|
|
119
|
-
* @summary Returns a dispatcher for handling Nano-specific operations
|
|
120
|
-
* @return {NanoDispatch} A new NanoDispatch instance
|
|
121
|
-
*/
|
|
122
|
-
protected Dispatch(): NanoDispatch;
|
|
123
|
-
repository<R extends Repository<any, Adapter<NanoConfig, DocumentScope<any>, MangoQuery, Context<NanoFlags>>>>(): Constructor<R>;
|
|
124
|
-
/**
|
|
125
|
-
* @description Creates database indexes for models
|
|
126
|
-
* @summary Generates and creates indexes in the Nano database based on the provided models
|
|
127
|
-
* @template M - Type extending Model
|
|
128
|
-
* @param models - Model constructors to create indexes for
|
|
129
|
-
* @return {Promise<void>} A promise that resolves when all indexes are created
|
|
130
|
-
* @mermaid
|
|
131
|
-
* sequenceDiagram
|
|
132
|
-
* participant A as NanoAdapter
|
|
133
|
-
* participant G as generateIndexes
|
|
134
|
-
* participant DB as Nano Database
|
|
135
|
-
* A->>G: generateIndexes(models)
|
|
136
|
-
* G-->>A: indexes
|
|
137
|
-
* loop For each index
|
|
138
|
-
* A->>DB: createIndex(index)
|
|
139
|
-
* DB-->>A: response
|
|
140
|
-
* Note over A: Check if index already exists
|
|
141
|
-
* alt Index exists
|
|
142
|
-
* A-->>A: throw ConflictError
|
|
143
|
-
* end
|
|
144
|
-
* end
|
|
145
|
-
*/
|
|
146
|
-
protected index<M extends Model>(...models: Constructor<M>[]): Promise<void>;
|
|
147
|
-
/**
|
|
148
|
-
* @description Creates a new document in the database
|
|
149
|
-
* @summary Inserts a new document into the Nano database with the provided data
|
|
150
|
-
* @param {string} tableName - The name of the table/collection
|
|
151
|
-
* @param {string | number} id - The document identifier
|
|
152
|
-
* @param {Record<string, any>} model - The document data to insert
|
|
153
|
-
* @return {Promise<Record<string, any>>} A promise that resolves to the created document with metadata
|
|
154
|
-
* @mermaid
|
|
155
|
-
* sequenceDiagram
|
|
156
|
-
* participant A as NanoAdapter
|
|
157
|
-
* participant DB as Nano Database
|
|
158
|
-
* A->>DB: insert(model)
|
|
159
|
-
* alt Success
|
|
160
|
-
* DB-->>A: response with ok=true
|
|
161
|
-
* A->>A: assignMetadata(model, response.rev)
|
|
162
|
-
* A-->>A: return document with metadata
|
|
163
|
-
* else Error
|
|
164
|
-
* DB-->>A: error
|
|
165
|
-
* A-->>A: throw parseError(e)
|
|
166
|
-
* else Not OK
|
|
167
|
-
* DB-->>A: response with ok=false
|
|
168
|
-
* A-->>A: throw InternalError
|
|
169
|
-
* end
|
|
170
|
-
*/
|
|
171
|
-
create<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<Context<NanoFlags>>): Promise<Record<string, any>>;
|
|
172
|
-
/**
|
|
173
|
-
* @description Creates multiple documents in the database
|
|
174
|
-
* @summary Inserts multiple documents into the Nano database in a single bulk operation
|
|
175
|
-
* @param {string} tableName - The name of the table/collection
|
|
176
|
-
* @param {string[] | number[]} ids - Array of document identifiers
|
|
177
|
-
* @param models - Array of document data to insert
|
|
178
|
-
* @return A promise that resolves to an array of created documents with metadata
|
|
179
|
-
* @mermaid
|
|
180
|
-
* sequenceDiagram
|
|
181
|
-
* participant A as NanoAdapter
|
|
182
|
-
* participant DB as Nano Database
|
|
183
|
-
* A->>DB: bulk({docs: models})
|
|
184
|
-
* alt Success
|
|
185
|
-
* DB-->>A: response array
|
|
186
|
-
* A->>A: Check if all responses have no errors
|
|
187
|
-
* alt All OK
|
|
188
|
-
* A->>A: assignMultipleMetadata(models, revs)
|
|
189
|
-
* A-->>A: return documents with metadata
|
|
190
|
-
* else Some errors
|
|
191
|
-
* A->>A: Collect error messages
|
|
192
|
-
* A-->>A: throw InternalError with collected messages
|
|
193
|
-
* end
|
|
194
|
-
* else Error
|
|
195
|
-
* DB-->>A: error
|
|
196
|
-
* A-->>A: throw parseError(e)
|
|
197
|
-
* end
|
|
198
|
-
*/
|
|
199
|
-
createAll<M extends Model>(tableName: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<Context<NanoFlags>>): Promise<Record<string, any>[]>;
|
|
200
|
-
/**
|
|
201
|
-
* @description Retrieves a document from the database
|
|
202
|
-
* @summary Fetches a single document from the Nano database by its ID
|
|
203
|
-
* @param {string} tableName - The name of the table/collection
|
|
204
|
-
* @param {string | number} id - The document identifier
|
|
205
|
-
* @return {Promise<Record<string, any>>} A promise that resolves to the retrieved document with metadata
|
|
206
|
-
* @mermaid
|
|
207
|
-
* sequenceDiagram
|
|
208
|
-
* participant A as NanoAdapter
|
|
209
|
-
* participant DB as Nano Database
|
|
210
|
-
* A->>A: generateId(tableName, id)
|
|
211
|
-
* A->>DB: get(_id)
|
|
212
|
-
* alt Success
|
|
213
|
-
* DB-->>A: record
|
|
214
|
-
* A->>A: assignMetadata(record, record._rev)
|
|
215
|
-
* A-->>A: return document with metadata
|
|
216
|
-
* else Error
|
|
217
|
-
* DB-->>A: error
|
|
218
|
-
* A-->>A: throw parseError(e)
|
|
219
|
-
* end
|
|
220
|
-
*/
|
|
221
|
-
read<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<Context<NanoFlags>>): Promise<Record<string, any>>;
|
|
222
|
-
/**
|
|
223
|
-
* @description Retrieves multiple documents from the database
|
|
224
|
-
* @summary Fetches multiple documents from the Nano database by their IDs in a single operation
|
|
225
|
-
* @param {string} tableName - The name of the table/collection
|
|
226
|
-
* @param {Array<string | number | bigint>} ids - Array of document identifiers
|
|
227
|
-
* @return A promise that resolves to an array of retrieved documents with metadata
|
|
228
|
-
* @mermaid
|
|
229
|
-
* sequenceDiagram
|
|
230
|
-
* participant A as NanoAdapter
|
|
231
|
-
* participant DB as Nano Database
|
|
232
|
-
* A->>A: Map ids to generateId(tableName, id)
|
|
233
|
-
* A->>DB: fetch({keys: mappedIds}, {})
|
|
234
|
-
* DB-->>A: results
|
|
235
|
-
* A->>A: Process each result row
|
|
236
|
-
* loop For each row
|
|
237
|
-
* alt Row has error
|
|
238
|
-
* A-->>A: throw InternalError
|
|
239
|
-
* else Row has document
|
|
240
|
-
* A->>A: assignMetadata(doc, doc._rev)
|
|
241
|
-
* else No document
|
|
242
|
-
* A-->>A: throw InternalError
|
|
243
|
-
* end
|
|
244
|
-
* end
|
|
245
|
-
* A-->>A: return documents with metadata
|
|
246
|
-
*/
|
|
247
|
-
readAll<M extends Model>(tableName: Constructor<M>, ids: (string | number | bigint)[], ...args: ContextualArgs<Context<NanoFlags>>): Promise<Record<string, any>[]>;
|
|
248
|
-
/**
|
|
249
|
-
* @description Updates a document in the database
|
|
250
|
-
* @summary Updates an existing document in the Nano database with the provided data
|
|
251
|
-
* @param {string} tableName - The name of the table/collection
|
|
252
|
-
* @param {string | number} id - The document identifier
|
|
253
|
-
* @param {Record<string, any>} model - The updated document data
|
|
254
|
-
* @return {Promise<Record<string, any>>} A promise that resolves to the updated document with metadata
|
|
255
|
-
* @mermaid
|
|
256
|
-
* sequenceDiagram
|
|
257
|
-
* participant A as NanoAdapter
|
|
258
|
-
* participant DB as Nano Database
|
|
259
|
-
* A->>DB: insert(model)
|
|
260
|
-
* alt Success
|
|
261
|
-
* DB-->>A: response with ok=true
|
|
262
|
-
* A->>A: assignMetadata(model, response.rev)
|
|
263
|
-
* A-->>A: return document with metadata
|
|
264
|
-
* else Error
|
|
265
|
-
* DB-->>A: error
|
|
266
|
-
* A-->>A: throw parseError(e)
|
|
267
|
-
* else Not OK
|
|
268
|
-
* DB-->>A: response with ok=false
|
|
269
|
-
* A-->>A: throw InternalError
|
|
270
|
-
* end
|
|
271
|
-
*/
|
|
272
|
-
update<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<Context<NanoFlags>>): Promise<Record<string, any>>;
|
|
273
|
-
/**
|
|
274
|
-
* @description Updates multiple documents in the database
|
|
275
|
-
* @summary Performs a bulk update operation on the Nano database for the provided documents
|
|
276
|
-
* @param {string} tableName - The name of the table/collection
|
|
277
|
-
* @param {Array<string|number>} ids - Array of document identifiers
|
|
278
|
-
* @param {Promise<Array<Record<string, any>>>} models - Array of updated document data
|
|
279
|
-
* @return {Promise<Promise<Array<Record<string, any>>>>} A promise that resolves to the updated documents with metadata
|
|
280
|
-
*/
|
|
281
|
-
updateAll<M extends Model>(tableName: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<Context<NanoFlags>>): Promise<Record<string, any>[]>;
|
|
282
|
-
/**
|
|
283
|
-
* @description Deletes a document from the database
|
|
284
|
-
* @summary Removes a single document from the Nano database by its ID and returns the deleted document metadata
|
|
285
|
-
* @param {string} tableName - The name of the table/collection
|
|
286
|
-
* @param {string|number} id - The document identifier
|
|
287
|
-
* @return {Promise<Record<string, any>>} A promise that resolves to the deleted document with metadata
|
|
288
|
-
*/
|
|
289
|
-
delete<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<Context<NanoFlags>>): Promise<Record<string, any>>;
|
|
290
|
-
/**
|
|
291
|
-
* @description Deletes multiple documents from the database
|
|
292
|
-
* @summary Performs a bulk delete operation for the provided IDs and returns the deleted documents metadata
|
|
293
|
-
* @param {string} tableName - The name of the table/collection
|
|
294
|
-
* @param {Array<string|number|bigint>} ids - Array of document identifiers to delete
|
|
295
|
-
* @return {Promise<Array<Record<string, any>>>} A promise resolving to the deleted documents with metadata
|
|
296
|
-
*/
|
|
297
|
-
deleteAll<M extends Model>(tableName: Constructor<M>, ids: PrimaryKeyType[], ...args: ContextualArgs<Context<NanoFlags>>): Promise<Record<string, any>[]>;
|
|
298
|
-
/**
|
|
299
|
-
* @description Executes a raw Mango query against the database
|
|
300
|
-
* @summary Runs a Mango query using Nano's find API and optionally returns only the documents array
|
|
301
|
-
* @template R - The expected response or document array type
|
|
302
|
-
* @param {MangoQuery} rawInput - The Mango query to execute
|
|
303
|
-
* @param {boolean} [docsOnly=true] - Whether to return only the docs array or the full response
|
|
304
|
-
* @return {Promise<R>} A promise that resolves to the query result, shaped according to docsOnly
|
|
305
|
-
*/
|
|
306
|
-
raw<R>(rawInput: MangoQuery, docsOnly?: boolean, ...args: ContextualArgs<Context<NanoFlags>>): Promise<R>;
|
|
307
|
-
view<R>(ddoc: string, viewName: string, options: Record<string, any>, ..._args: ContextualArgs<Context<NanoFlags>>): Promise<ViewResponse<R>>;
|
|
308
|
-
/**
|
|
309
|
-
* @description Establishes a connection to a Nano (CouchDB) server
|
|
310
|
-
* @summary Creates and returns a Nano ServerScope using the given credentials, host, and protocol
|
|
311
|
-
* @param {string} user - Username used for authentication
|
|
312
|
-
* @param {string} pass - Password used for authentication
|
|
313
|
-
* @param {string} [host="localhost:5984"] - Host and port of the CouchDB server
|
|
314
|
-
* @param {("http"|"https")} [protocol="http"] - Protocol to use for the connection
|
|
315
|
-
* @return {ServerScope} The Nano ServerScope connection
|
|
316
|
-
*/
|
|
317
|
-
static connect(user: string, pass: string, host?: string, protocol?: "http" | "https", agent?: any): ServerScope;
|
|
318
|
-
/**
|
|
319
|
-
* @description Creates a new database on the Nano server
|
|
320
|
-
* @summary Creates a new database with the specified name on the connected Nano server
|
|
321
|
-
* @param {ServerScope} con - The Nano server connection
|
|
322
|
-
* @param {string} name - The name of the database to create
|
|
323
|
-
* @return {Promise<void>} A promise that resolves when the database is created
|
|
324
|
-
* @mermaid
|
|
325
|
-
* sequenceDiagram
|
|
326
|
-
* participant A as NanoAdapter
|
|
327
|
-
* participant DB as Nano Server
|
|
328
|
-
* A->>DB: db.create(name)
|
|
329
|
-
* alt Success
|
|
330
|
-
* DB-->>A: result with ok=true
|
|
331
|
-
* else Error
|
|
332
|
-
* DB-->>A: error
|
|
333
|
-
* A-->>A: throw parseError(e)
|
|
334
|
-
* else Not OK
|
|
335
|
-
* DB-->>A: result with ok=false
|
|
336
|
-
* A-->>A: throw parseError(error, reason)
|
|
337
|
-
* end
|
|
338
|
-
*/
|
|
339
|
-
static createDatabase(con: ServerScope, name: string): Promise<void>;
|
|
340
|
-
/**
|
|
341
|
-
* @description Deletes a database from the Nano server
|
|
342
|
-
* @summary Removes an existing database with the specified name from the connected Nano server
|
|
343
|
-
* @param {ServerScope} con - The Nano server connection
|
|
344
|
-
* @param {string} name - The name of the database to delete
|
|
345
|
-
* @return {Promise<void>} A promise that resolves when the database is deleted
|
|
346
|
-
* @mermaid
|
|
347
|
-
* sequenceDiagram
|
|
348
|
-
* participant A as NanoAdapter
|
|
349
|
-
* participant DB as Nano Server
|
|
350
|
-
* A->>DB: db.destroy(name)
|
|
351
|
-
* alt Success
|
|
352
|
-
* DB-->>A: result with ok=true
|
|
353
|
-
* else Error
|
|
354
|
-
* DB-->>A: error
|
|
355
|
-
* A-->>A: throw parseError(e)
|
|
356
|
-
* else Not OK
|
|
357
|
-
* DB-->>A: result with ok=false
|
|
358
|
-
* A-->>A: throw InternalError
|
|
359
|
-
* end
|
|
360
|
-
*/
|
|
361
|
-
static deleteDatabase(con: ServerScope, name: string): Promise<void>;
|
|
362
|
-
/**
|
|
363
|
-
* @description Closes the keep-alive agent associated with a Nano connection
|
|
364
|
-
* @summary Destroys the custom HTTP/HTTPS agent that was created during connection setup
|
|
365
|
-
* @param {ServerScope} con - The Nano server connection whose agent should be destroyed
|
|
366
|
-
*/
|
|
367
|
-
static closeConnection(con?: ServerScope | null): void;
|
|
368
|
-
/**
|
|
369
|
-
* @description Creates a new user and grants access to a database
|
|
370
|
-
* @summary Creates a new user in the Nano server and configures security to grant the user access to a specific database
|
|
371
|
-
* @param {ServerScope} con - The Nano server connection
|
|
372
|
-
* @param {string} dbName - The name of the database to grant access to
|
|
373
|
-
* @param {string} user - The username to create
|
|
374
|
-
* @param {string} pass - The password for the new user
|
|
375
|
-
* @param {string[]} [roles=["reader", "writer"]] - The roles to assign to the user
|
|
376
|
-
* @return {Promise<void>} A promise that resolves when the user is created and granted access
|
|
377
|
-
* @mermaid
|
|
378
|
-
* sequenceDiagram
|
|
379
|
-
* participant A as NanoAdapter
|
|
380
|
-
* participant U as _users Database
|
|
381
|
-
* participant S as Security API
|
|
382
|
-
* A->>A: Create user object
|
|
383
|
-
* A->>U: insert(user)
|
|
384
|
-
* alt Success
|
|
385
|
-
* U-->>A: response with ok=true
|
|
386
|
-
* A->>S: PUT _security with user permissions
|
|
387
|
-
* alt Security Success
|
|
388
|
-
* S-->>A: security response with ok=true
|
|
389
|
-
* else Security Failure
|
|
390
|
-
* S-->>A: security response with ok=false
|
|
391
|
-
* A-->>A: throw InternalError
|
|
392
|
-
* end
|
|
393
|
-
* else Error
|
|
394
|
-
* U-->>A: error
|
|
395
|
-
* A-->>A: throw parseError(e)
|
|
396
|
-
* else Not OK
|
|
397
|
-
* U-->>A: response with ok=false
|
|
398
|
-
* A-->>A: throw InternalError
|
|
399
|
-
* end
|
|
400
|
-
*/
|
|
401
|
-
static createUser(con: ServerScope, dbName: string, user: string, pass: string, roles?: string[]): Promise<void>;
|
|
402
|
-
/**
|
|
403
|
-
* @description Deletes a user from the Nano server
|
|
404
|
-
* @summary Removes an existing user from the Nano server
|
|
405
|
-
* @param {ServerScope} con - The Nano server connection
|
|
406
|
-
* @param {string} dbName - The name of the database (used for logging purposes)
|
|
407
|
-
* @param {string} user - The username to delete
|
|
408
|
-
* @return {Promise<void>} A promise that resolves when the user is deleted
|
|
409
|
-
* @mermaid
|
|
410
|
-
* sequenceDiagram
|
|
411
|
-
* participant A as NanoAdapter
|
|
412
|
-
* participant U as _users Database
|
|
413
|
-
* A->>A: Generate user ID
|
|
414
|
-
* A->>U: get(id)
|
|
415
|
-
* U-->>A: user document
|
|
416
|
-
* A->>U: destroy(id, user._rev)
|
|
417
|
-
* alt Success
|
|
418
|
-
* U-->>A: success response
|
|
419
|
-
* else Error
|
|
420
|
-
* U-->>A: error
|
|
421
|
-
* A-->>A: throw parseError(e)
|
|
422
|
-
* end
|
|
423
|
-
*/
|
|
424
|
-
static deleteUser(con: ServerScope, dbName: string, user: string): Promise<void>;
|
|
425
|
-
/**
|
|
426
|
-
* @description Sets up decorations for Nano-specific model properties
|
|
427
|
-
* @summary Configures decorators for created_by and updated_by fields in models to be automatically
|
|
428
|
-
* populated with the user from the context when documents are created or updated
|
|
429
|
-
* @return {void}
|
|
430
|
-
* @mermaid
|
|
431
|
-
* sequenceDiagram
|
|
432
|
-
* participant A as NanoAdapter
|
|
433
|
-
* participant D as Decoration
|
|
434
|
-
* participant R as Repository
|
|
435
|
-
* A->>R: key(PersistenceKeys.CREATED_BY)
|
|
436
|
-
* R-->>A: createdByKey
|
|
437
|
-
* A->>D: flavouredAs("nano")
|
|
438
|
-
* A->>D: for(createdByKey)
|
|
439
|
-
* A->>D: define(onCreate(createdByOnNanoCreateUpdate), propMetadata)
|
|
440
|
-
* A->>D: apply()
|
|
441
|
-
* A->>R: key(PersistenceKeys.UPDATED_BY)
|
|
442
|
-
* R-->>A: updatedByKey
|
|
443
|
-
* A->>D: flavouredAs("nano")
|
|
444
|
-
* A->>D: for(updatedByKey)
|
|
445
|
-
* A->>D: define(onCreate(createdByOnNanoCreateUpdate), propMetadata)
|
|
446
|
-
* A->>D: apply()
|
|
447
|
-
*/
|
|
448
|
-
static decoration(): void;
|
|
449
|
-
}
|
package/lib/types/constants.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description Identifier for the Nano database flavor
|
|
3
|
-
* @summary Constant string that identifies the database type as "nano" for use in adapter selection and configuration
|
|
4
|
-
* @const NanoFlavour
|
|
5
|
-
* @memberOf module:for-nano
|
|
6
|
-
*/
|
|
7
|
-
export declare const NanoFlavour = "nano";
|
package/lib/types/index.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export * from "./constants";
|
|
2
|
-
export * from "./NanoRepository";
|
|
3
|
-
export * from "./types";
|
|
4
|
-
export * from "./adapter";
|
|
5
|
-
/**
|
|
6
|
-
* @description A TypeScript module for interacting with Nano databases
|
|
7
|
-
* @summary This module provides a set of utilities, classes, and types for working with Nano databases. It includes repository patterns, adapters, and type definitions to simplify database operations. Key exports include {@link NanoAdapter}, {@link NanoRepository}, {@link NanoFlags}, and {@link NanoFlavour}.
|
|
8
|
-
* @module for-nano
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @description Package version identifier
|
|
12
|
-
* @summary Stores the current package version string for the for-nano module
|
|
13
|
-
* @const VERSION
|
|
14
|
-
* @memberOf module:for-nano
|
|
15
|
-
*/
|
|
16
|
-
export declare const VERSION = "0.8.0";
|
|
17
|
-
/**
|
|
18
|
-
* @description Package version identifier
|
|
19
|
-
* @summary Stores the current package version string for the for-nano module
|
|
20
|
-
* @const PACKAGE_NAME
|
|
21
|
-
* @memberOf module:for-nano
|
|
22
|
-
*/
|
|
23
|
-
export declare const PACKAGE_NAME = "@decaf-ts/for-nano";
|
package/lib/types/types.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { AdapterFlags } from "@decaf-ts/core";
|
|
2
|
-
/**
|
|
3
|
-
* @description Configuration flags for Nano database operations
|
|
4
|
-
* @summary Extended repository flags that include user authentication information for Nano database connections
|
|
5
|
-
* @interface NanoFlags
|
|
6
|
-
* @memberOf module:for-nano
|
|
7
|
-
*/
|
|
8
|
-
export interface NanoFlags extends AdapterFlags {
|
|
9
|
-
/**
|
|
10
|
-
* @description User authentication information for Nano database connections
|
|
11
|
-
*/
|
|
12
|
-
user: {
|
|
13
|
-
/**
|
|
14
|
-
* @description Username for authentication with the Nano database
|
|
15
|
-
*/
|
|
16
|
-
name: string;
|
|
17
|
-
/**
|
|
18
|
-
* @description Optional array of roles assigned to the user
|
|
19
|
-
*/
|
|
20
|
-
roles?: string[];
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* @description Connection configuration for Nano
|
|
25
|
-
* @summary Defines the necessary parameters to establish a connection to a Nano (CouchDB) server and select a database
|
|
26
|
-
* @property {string} user - Username to authenticate against the server
|
|
27
|
-
* @property {string} password - Password to authenticate the user
|
|
28
|
-
* @property {string} host - Host and port of the server (e.g., "localhost:5984") or full URL host without protocol
|
|
29
|
-
* @property {string} dbName - The database name to use on the server
|
|
30
|
-
* @typeDef NanoConfig
|
|
31
|
-
* @memberOf module:for-nano
|
|
32
|
-
*/
|
|
33
|
-
export type NanoConfig = {
|
|
34
|
-
user: string;
|
|
35
|
-
password: string;
|
|
36
|
-
host: string;
|
|
37
|
-
dbName: string;
|
|
38
|
-
protocol: "http" | "https";
|
|
39
|
-
};
|