@decaf-ts/for-pouch 0.5.0 → 0.7.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/PouchRepository.cjs +1 -0
- package/lib/cjs/PouchRepository.cjs.map +1 -0
- package/lib/cjs/adapter.cjs +9 -8
- package/lib/cjs/adapter.cjs.map +1 -0
- package/lib/cjs/constants.cjs +1 -0
- package/lib/cjs/constants.cjs.map +1 -0
- package/lib/cjs/index.cjs +4 -3
- package/lib/cjs/index.cjs.map +1 -0
- package/lib/cjs/types.cjs +1 -0
- package/lib/cjs/types.cjs.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/types/PouchRepository.d.cts +15 -0
- package/lib/types/PouchRepository.d.mts +15 -0
- package/lib/types/adapter.d.cts +427 -0
- package/lib/types/adapter.d.mts +427 -0
- package/lib/types/constants.d.cts +15 -0
- package/lib/types/constants.d.mts +15 -0
- package/lib/types/index.d.cts +23 -0
- package/lib/types/index.d.mts +23 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/types.d.cts +41 -0
- package/lib/types/types.d.mts +41 -0
- package/package.json +4 -4
- package/lib/cjs/PouchRepository.js.map +0 -1
- package/lib/cjs/adapter.js.map +0 -1
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/types.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PouchRepository.js","sourceRoot":"","sources":["PouchRepository.js"],"names":[],"mappings":";;;AAAA,uDAA0D;AAC1D;;;;;GAKG;AACH,MAAa,eAAgB,SAAQ,+BAAiB;IAClD,YAAY,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK;QACrC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,QAAQ,CAAC,KAAK;QACV,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;CACJ;AAPD,0CAOC;AACD,2CAA2C"}
|
package/lib/cjs/adapter.cjs
CHANGED
|
@@ -45,8 +45,8 @@ const for_couchdb_2 = require("@decaf-ts/for-couchdb");
|
|
|
45
45
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
46
46
|
const core_1 = require("@decaf-ts/core");
|
|
47
47
|
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
48
|
-
const
|
|
49
|
-
const
|
|
48
|
+
const constants_js_1 = require("./constants.cjs");
|
|
49
|
+
const PouchRepository_js_1 = require("./PouchRepository.cjs");
|
|
50
50
|
const pouchdb_core_1 = __importDefault(require("pouchdb-core"));
|
|
51
51
|
const PouchMapReduce = __importStar(require("pouchdb-mapreduce"));
|
|
52
52
|
const PouchReplication = __importStar(require("pouchdb-replication"));
|
|
@@ -137,7 +137,7 @@ async function createdByOnPouchCreateUpdate(context, data, key, model) {
|
|
|
137
137
|
*/
|
|
138
138
|
class PouchAdapter extends for_couchdb_1.CouchDBAdapter {
|
|
139
139
|
constructor(config, alias) {
|
|
140
|
-
super(config,
|
|
140
|
+
super(config, constants_js_1.PouchFlavour, alias);
|
|
141
141
|
this._pluginsRegistered = false;
|
|
142
142
|
}
|
|
143
143
|
registerPlugins() {
|
|
@@ -171,7 +171,7 @@ class PouchAdapter extends for_couchdb_1.CouchDBAdapter {
|
|
|
171
171
|
const credentials = user ? `${authUser}${authPassword}@` : "";
|
|
172
172
|
return new pouchdb_core_1.default(`${protocol}://${credentials}${host}/${dbName}`);
|
|
173
173
|
}
|
|
174
|
-
return new pouchdb_core_1.default(`${storagePath ||
|
|
174
|
+
return new pouchdb_core_1.default(`${storagePath || constants_js_1.DefaultLocalStoragePath}/${dbName}`);
|
|
175
175
|
}
|
|
176
176
|
catch (e) {
|
|
177
177
|
throw new db_decorators_1.InternalError(`Failed to create PouchDB client: ${e}`);
|
|
@@ -234,7 +234,7 @@ class PouchAdapter extends for_couchdb_1.CouchDBAdapter {
|
|
|
234
234
|
}, flags), ...args);
|
|
235
235
|
}
|
|
236
236
|
repository() {
|
|
237
|
-
return
|
|
237
|
+
return PouchRepository_js_1.PouchRepository;
|
|
238
238
|
}
|
|
239
239
|
/**
|
|
240
240
|
* @description Creates database indexes for the given models
|
|
@@ -815,16 +815,17 @@ class PouchAdapter extends for_couchdb_1.CouchDBAdapter {
|
|
|
815
815
|
*/
|
|
816
816
|
static decoration() {
|
|
817
817
|
super.decoration();
|
|
818
|
-
decoration_1.Decoration.flavouredAs(
|
|
818
|
+
decoration_1.Decoration.flavouredAs(constants_js_1.PouchFlavour)
|
|
819
819
|
.for(core_1.PersistenceKeys.CREATED_BY)
|
|
820
820
|
.define((0, db_decorators_1.onCreate)(createdByOnPouchCreateUpdate), (0, decoration_1.propMetadata)(core_1.PersistenceKeys.CREATED_BY, {}))
|
|
821
821
|
.apply();
|
|
822
|
-
decoration_1.Decoration.flavouredAs(
|
|
822
|
+
decoration_1.Decoration.flavouredAs(constants_js_1.PouchFlavour)
|
|
823
823
|
.for(core_1.PersistenceKeys.UPDATED_BY)
|
|
824
824
|
.define((0, db_decorators_1.onCreateUpdate)(createdByOnPouchCreateUpdate), (0, decoration_1.propMetadata)(core_1.PersistenceKeys.UPDATED_BY, {}))
|
|
825
825
|
.apply();
|
|
826
826
|
}
|
|
827
827
|
}
|
|
828
828
|
exports.PouchAdapter = PouchAdapter;
|
|
829
|
-
core_1.Adapter.setCurrent(
|
|
829
|
+
core_1.Adapter.setCurrent(constants_js_1.PouchFlavour);
|
|
830
|
+
//# sourceMappingURL=adapter.js.map
|
|
830
831
|
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["adapter.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,oEASC;AAvCD,4BAA0B;AAC1B,mCAAoC;AACpC,uDAAqG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mappings":";;;AAAA;;;;;;GAMG;AACU,QAAA,YAAY,GAAG,OAAO,CAAC;AACpC;;;;;GAKG;AACU,QAAA,uBAAuB,GAAG,WAAW,CAAC;AACnD,qCAAqC"}
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -15,9 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.PACKAGE_NAME = exports.VERSION = void 0;
|
|
18
|
-
const
|
|
18
|
+
const adapter_js_1 = require("./adapter.cjs");
|
|
19
19
|
const decoration_1 = require("@decaf-ts/decoration");
|
|
20
|
-
|
|
20
|
+
adapter_js_1.PouchAdapter.decoration();
|
|
21
21
|
__exportStar(require("./constants.cjs"), exports);
|
|
22
22
|
__exportStar(require("./PouchRepository.cjs"), exports);
|
|
23
23
|
__exportStar(require("./types.cjs"), exports);
|
|
@@ -34,7 +34,7 @@ __exportStar(require("./adapter.cjs"), exports);
|
|
|
34
34
|
* @const VERSION
|
|
35
35
|
* @memberOf module:for-pouch
|
|
36
36
|
*/
|
|
37
|
-
exports.VERSION = "0.
|
|
37
|
+
exports.VERSION = "0.6.0";
|
|
38
38
|
/**
|
|
39
39
|
* @description Package version identifier
|
|
40
40
|
* @summary Stores the current version of the for-pouch package
|
|
@@ -43,4 +43,5 @@ exports.VERSION = "0.4.5";
|
|
|
43
43
|
*/
|
|
44
44
|
exports.PACKAGE_NAME = "@decaf-ts/for-pouch";
|
|
45
45
|
decoration_1.Metadata.registerLibrary(exports.PACKAGE_NAME, exports.VERSION);
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
46
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6CAA4C;AAC5C,qDAAgD;AAChD,yBAAY,CAAC,UAAU,EAAE,CAAC;AAC1B,iDAA+B;AAC/B,uDAAqC;AACrC,6CAA2B;AAC3B,6BAA6B;AAC7B,+CAA6B;AAC7B;;;;GAIG;AACH;;;;;GAKG;AACU,QAAA,OAAO,GAAG,aAAa,CAAC;AACrC;;;;;GAKG;AACU,QAAA,YAAY,GAAG,aAAa,CAAC;AAC1C,qBAAQ,CAAC,eAAe,CAAC,oBAAY,EAAE,eAAO,CAAC,CAAC;AAChD,iCAAiC"}
|
package/lib/cjs/types.cjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.js"],"names":[],"mappings":";;AACA,iCAAiC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -17,7 +17,7 @@ export * from "./adapter.js";
|
|
|
17
17
|
* @const VERSION
|
|
18
18
|
* @memberOf module:for-pouch
|
|
19
19
|
*/
|
|
20
|
-
export const VERSION = "0.
|
|
20
|
+
export const VERSION = "0.6.0";
|
|
21
21
|
/**
|
|
22
22
|
* @description Package version identifier
|
|
23
23
|
* @summary Stores the current version of the for-pouch package
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
|
+
import { CouchDBRepository } from "@decaf-ts/for-couchdb";
|
|
3
|
+
import { ContextOf, FlagsOf } from "@decaf-ts/core";
|
|
4
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
+
import { PouchAdapter } from "./adapter.cjs";
|
|
6
|
+
/**
|
|
7
|
+
* @description Repository implementation for PouchDB-backed models
|
|
8
|
+
* @summary Extends the CouchDBRepository with PouchAdapter-specific overrides so the repository can be proxied with the correct flags.
|
|
9
|
+
* @template M - Model type managed by this repository
|
|
10
|
+
* @memberOf module:for-pouch
|
|
11
|
+
*/
|
|
12
|
+
export declare class PouchRepository<M extends Model> extends CouchDBRepository<M, PouchAdapter> {
|
|
13
|
+
constructor(adapter: PouchAdapter, model: Constructor<M>, force?: boolean);
|
|
14
|
+
override(flags: Partial<FlagsOf<ContextOf<PouchAdapter>>>): this;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
|
+
import { CouchDBRepository } from "@decaf-ts/for-couchdb";
|
|
3
|
+
import { ContextOf, FlagsOf } from "@decaf-ts/core";
|
|
4
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
+
import { PouchAdapter } from "./adapter.js";
|
|
6
|
+
/**
|
|
7
|
+
* @description Repository implementation for PouchDB-backed models
|
|
8
|
+
* @summary Extends the CouchDBRepository with PouchAdapter-specific overrides so the repository can be proxied with the correct flags.
|
|
9
|
+
* @template M - Model type managed by this repository
|
|
10
|
+
* @memberOf module:for-pouch
|
|
11
|
+
*/
|
|
12
|
+
export declare class PouchRepository<M extends Model> extends CouchDBRepository<M, PouchAdapter> {
|
|
13
|
+
constructor(adapter: PouchAdapter, model: Constructor<M>, force?: boolean);
|
|
14
|
+
override(flags: Partial<FlagsOf<ContextOf<PouchAdapter>>>): this;
|
|
15
|
+
}
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { CouchDBAdapter, MangoQuery, ViewResponse } from "@decaf-ts/for-couchdb";
|
|
3
|
+
import { BaseError, OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
4
|
+
import { Adapter, Context, ContextOf, ContextualArgs, RelationsMetadata, Repository } from "@decaf-ts/core";
|
|
5
|
+
import Database = PouchDB.Database;
|
|
6
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
7
|
+
import { PouchConfig, PouchFlags } from "./types.cjs";
|
|
8
|
+
import { PouchRepository } from "./PouchRepository.cjs";
|
|
9
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
10
|
+
/**
|
|
11
|
+
* @description Sets the creator ID on a model during creation or update operations
|
|
12
|
+
* @summary This function is used as a decorator handler to automatically set the creator ID field on a model
|
|
13
|
+
* when it's being created or updated. It extracts the UUID from the context and assigns it to the specified key.
|
|
14
|
+
* @template M - The model type that extends Model
|
|
15
|
+
* @template R - The repository type that extends PouchRepository<M>
|
|
16
|
+
* @template V - The relations metadata type that extends RelationsMetadata
|
|
17
|
+
* @param {R} this - The repository instance
|
|
18
|
+
* @param {Context<PouchFlags>} context - The operation context containing flags
|
|
19
|
+
* @param {V} data - The relations metadata
|
|
20
|
+
* @param key - The property key to set on the model
|
|
21
|
+
* @param {M} model - The model instance to modify
|
|
22
|
+
* @return {Promise<void>} A promise that resolves when the operation is complete
|
|
23
|
+
* @function createdByOnPouchCreateUpdate
|
|
24
|
+
* @memberOf module:for-pouch
|
|
25
|
+
*/
|
|
26
|
+
export declare function createdByOnPouchCreateUpdate<M extends Model, R extends PouchRepository<M>, V extends RelationsMetadata>(this: R, context: ContextOf<R>, data: V, key: keyof M, model: M): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* @description PouchDB implementation of the CouchDBAdapter
|
|
29
|
+
* @summary Concrete adapter that bridges the generic CouchDBAdapter to a PouchDB backend. It supports CRUD (single and bulk), indexing and Mango queries, and wires flavour-specific decorations.
|
|
30
|
+
* @template PouchFlags - The flags specific to PouchDB operations
|
|
31
|
+
* @template Context<PouchFlags> - The context type with PouchDB flags
|
|
32
|
+
* @param {PouchConfig} config - Adapter configuration (remote credentials or local storage path, db name, plugins)
|
|
33
|
+
* @param {string} [alias] - Optional alias for the database
|
|
34
|
+
* @class PouchAdapter
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { PouchAdapter } from '@decaf-ts/for-pouch';
|
|
38
|
+
*
|
|
39
|
+
* // Create a PouchAdapter with config
|
|
40
|
+
* const adapter = new PouchAdapter({
|
|
41
|
+
* protocol: 'http',
|
|
42
|
+
* host: 'localhost:5984',
|
|
43
|
+
* user: 'admin',
|
|
44
|
+
* password: 'secret',
|
|
45
|
+
* dbName: 'my-database',
|
|
46
|
+
* plugins: []
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // Or use local storage
|
|
50
|
+
* const localAdapter = new PouchAdapter({
|
|
51
|
+
* protocol: 'http', // ignored for local
|
|
52
|
+
* dbName: 'local-db',
|
|
53
|
+
* storagePath: 'local_dbs',
|
|
54
|
+
* plugins: []
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* // Use the adapter for database operations
|
|
58
|
+
* const result = await adapter.read('users', 'user-123');
|
|
59
|
+
* ```
|
|
60
|
+
* @mermaid
|
|
61
|
+
* sequenceDiagram
|
|
62
|
+
* participant Client
|
|
63
|
+
* participant PouchAdapter
|
|
64
|
+
* participant PouchDB
|
|
65
|
+
* participant CouchDB
|
|
66
|
+
*
|
|
67
|
+
* Client->>PouchAdapter: new PouchAdapter(config, alias?)
|
|
68
|
+
* PouchAdapter->>CouchDBAdapter: super(config, PouchFlavour, alias)
|
|
69
|
+
*
|
|
70
|
+
* Client->>PouchAdapter: create(table, id, model)
|
|
71
|
+
* PouchAdapter->>PouchDB: put(model)
|
|
72
|
+
* PouchDB->>CouchDB: HTTP PUT
|
|
73
|
+
* CouchDB-->>PouchDB: Response
|
|
74
|
+
* PouchDB-->>PouchAdapter: Response
|
|
75
|
+
* PouchAdapter-->>Client: Updated model
|
|
76
|
+
*
|
|
77
|
+
* Client->>PouchAdapter: read(table, id)
|
|
78
|
+
* PouchAdapter->>PouchDB: get(id)
|
|
79
|
+
* PouchDB->>CouchDB: HTTP GET
|
|
80
|
+
* CouchDB-->>PouchDB: Document
|
|
81
|
+
* PouchDB-->>PouchAdapter: Document
|
|
82
|
+
* PouchAdapter-->>Client: Model
|
|
83
|
+
*/
|
|
84
|
+
export declare class PouchAdapter extends CouchDBAdapter<PouchConfig, Database, Context<PouchFlags>> {
|
|
85
|
+
constructor(config: PouchConfig, alias?: string);
|
|
86
|
+
private _adminClient?;
|
|
87
|
+
private _pluginsRegistered;
|
|
88
|
+
private registerPlugins;
|
|
89
|
+
private buildClient;
|
|
90
|
+
protected getAdminClient(): Database;
|
|
91
|
+
/**
|
|
92
|
+
* @description Lazily initializes and returns the underlying PouchDB client
|
|
93
|
+
* @summary Loads required PouchDB plugins once, builds the connection URL or local storage path from config, and caches the Database instance for reuse. Throws InternalError if client creation fails.
|
|
94
|
+
* @return {Database} A PouchDB Database instance ready to perform operations
|
|
95
|
+
* @mermaid
|
|
96
|
+
* sequenceDiagram
|
|
97
|
+
* participant Caller
|
|
98
|
+
* participant PouchAdapter
|
|
99
|
+
* participant PouchDB
|
|
100
|
+
* Caller->>PouchAdapter: getClient()
|
|
101
|
+
* alt client not initialized
|
|
102
|
+
* PouchAdapter->>PouchAdapter: register plugins
|
|
103
|
+
* PouchAdapter->>PouchDB: new PouchDB(url or path)
|
|
104
|
+
* alt creation fails
|
|
105
|
+
* PouchDB-->>PouchAdapter: Error
|
|
106
|
+
* PouchAdapter-->>Caller: throws InternalError
|
|
107
|
+
* else success
|
|
108
|
+
* PouchDB-->>PouchAdapter: Database
|
|
109
|
+
* PouchAdapter-->>Caller: cached client
|
|
110
|
+
* end
|
|
111
|
+
* else client initialized
|
|
112
|
+
* PouchAdapter-->>Caller: cached client
|
|
113
|
+
* end
|
|
114
|
+
*/
|
|
115
|
+
getClient(): Database;
|
|
116
|
+
/**
|
|
117
|
+
* @description Generates operation flags for PouchDB operations
|
|
118
|
+
* @summary Creates a set of flags for a specific operation, including a UUID for identification.
|
|
119
|
+
* This method extracts the user ID from the database URL or generates a random UUID if not available.
|
|
120
|
+
* @template M - The model type that extends Model
|
|
121
|
+
* @param {OperationKeys} operation - The operation key (create, read, update, delete)
|
|
122
|
+
* @param {Constructor<M>} model - The model constructor
|
|
123
|
+
* @param {Partial<PouchFlags>} flags - Partial flags to be merged
|
|
124
|
+
* @return {Promise<PouchFlags>} The complete set of flags for the operation
|
|
125
|
+
*/
|
|
126
|
+
protected flags<M extends Model>(operation: OperationKeys, model: Constructor<M>, flags: Partial<PouchFlags>, ...args: any[]): Promise<PouchFlags>;
|
|
127
|
+
repository<R extends Repository<any, Adapter<PouchConfig, Database, MangoQuery, Context<PouchFlags>>>>(): Constructor<R>;
|
|
128
|
+
/**
|
|
129
|
+
* @description Creates database indexes for the given models
|
|
130
|
+
* @summary Generates and creates indexes in the PouchDB database based on the provided model constructors.
|
|
131
|
+
* This method uses the generateIndexes utility to create index definitions and then creates them in the database.
|
|
132
|
+
* @template M - The model type that extends Model
|
|
133
|
+
* @param models - The model constructors to create indexes for
|
|
134
|
+
* @return {Promise<void>} A promise that resolves when all indexes are created
|
|
135
|
+
*/
|
|
136
|
+
protected index<M extends Model>(...models: Constructor<M>[]): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* @description Creates a new document in the database
|
|
139
|
+
* @summary Inserts a new document into the PouchDB database using the put operation.
|
|
140
|
+
* This method handles error parsing and ensures the operation was successful.
|
|
141
|
+
* @param {string} tableName - The name of the table/collection
|
|
142
|
+
* @param {string|number} id - The document ID
|
|
143
|
+
* @param {Record<string, any>} model - The document data to insert
|
|
144
|
+
* @return {Promise<Record<string, any>>} A promise that resolves to the created document with metadata
|
|
145
|
+
* @mermaid
|
|
146
|
+
* sequenceDiagram
|
|
147
|
+
* participant Client
|
|
148
|
+
* participant PouchAdapter
|
|
149
|
+
* participant PouchDB
|
|
150
|
+
*
|
|
151
|
+
* Client->>PouchAdapter: create(tableName, id, model)
|
|
152
|
+
* PouchAdapter->>PouchDB: put(model)
|
|
153
|
+
* alt Success
|
|
154
|
+
* PouchDB-->>PouchAdapter: Response with ok=true
|
|
155
|
+
* PouchAdapter->>PouchAdapter: assignMetadata(model, response.rev)
|
|
156
|
+
* PouchAdapter-->>Client: Updated model with metadata
|
|
157
|
+
* else Error
|
|
158
|
+
* PouchDB-->>PouchAdapter: Error
|
|
159
|
+
* PouchAdapter->>PouchAdapter: parseError(e)
|
|
160
|
+
* PouchAdapter-->>Client: Throws error
|
|
161
|
+
* end
|
|
162
|
+
*/
|
|
163
|
+
create<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<Context<PouchFlags>>): Promise<Record<string, any>>;
|
|
164
|
+
/**
|
|
165
|
+
* @description Creates multiple documents in the database in a single operation
|
|
166
|
+
* @summary Inserts multiple documents into the PouchDB database using the bulkDocs operation.
|
|
167
|
+
* This method handles error parsing and ensures all operations were successful.
|
|
168
|
+
* @param {string} tableName - The name of the table/collection
|
|
169
|
+
* @param {string[]|number[]} ids - The document IDs
|
|
170
|
+
* @param models - The document data to insert
|
|
171
|
+
* @return A promise that resolves to the created documents with metadata
|
|
172
|
+
* @mermaid
|
|
173
|
+
* sequenceDiagram
|
|
174
|
+
* participant Client
|
|
175
|
+
* participant PouchAdapter
|
|
176
|
+
* participant PouchDB
|
|
177
|
+
*
|
|
178
|
+
* Client->>PouchAdapter: createAll(tableName, ids, models)
|
|
179
|
+
* PouchAdapter->>PouchDB: bulkDocs(models)
|
|
180
|
+
* alt Success
|
|
181
|
+
* PouchDB-->>PouchAdapter: Array of responses with ok=true
|
|
182
|
+
* PouchAdapter->>PouchAdapter: assignMultipleMetadata(models, revs)
|
|
183
|
+
* PouchAdapter-->>Client: Updated models with metadata
|
|
184
|
+
* else Error
|
|
185
|
+
* PouchDB-->>PouchAdapter: Array with errors
|
|
186
|
+
* PouchAdapter->>PouchAdapter: Check for errors
|
|
187
|
+
* PouchAdapter-->>Client: Throws InternalError
|
|
188
|
+
* end
|
|
189
|
+
*/
|
|
190
|
+
createAll<M extends Model>(tableName: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<Context<PouchFlags>>): Promise<Record<string, any>[]>;
|
|
191
|
+
/**
|
|
192
|
+
* @description Retrieves a document from the database by ID
|
|
193
|
+
* @summary Fetches a document from the PouchDB database using the get operation.
|
|
194
|
+
* This method generates the document ID based on the table name and ID, then retrieves the document.
|
|
195
|
+
* @param {string} tableName - The name of the table/collection
|
|
196
|
+
* @param {string|number} id - The document ID
|
|
197
|
+
* @return {Promise<Record<string, any>>} A promise that resolves to the retrieved document with metadata
|
|
198
|
+
* @mermaid
|
|
199
|
+
* sequenceDiagram
|
|
200
|
+
* participant Client
|
|
201
|
+
* participant PouchAdapter
|
|
202
|
+
* participant PouchDB
|
|
203
|
+
*
|
|
204
|
+
* Client->>PouchAdapter: read(tableName, id)
|
|
205
|
+
* PouchAdapter->>PouchAdapter: generateId(tableName, id)
|
|
206
|
+
* PouchAdapter->>PouchDB: get(_id)
|
|
207
|
+
* alt Success
|
|
208
|
+
* PouchDB-->>PouchAdapter: Document
|
|
209
|
+
* PouchAdapter->>PouchAdapter: assignMetadata(record, record._rev)
|
|
210
|
+
* PouchAdapter-->>Client: Document with metadata
|
|
211
|
+
* else Error
|
|
212
|
+
* PouchDB-->>PouchAdapter: Error
|
|
213
|
+
* PouchAdapter->>PouchAdapter: parseError(e)
|
|
214
|
+
* PouchAdapter-->>Client: Throws error
|
|
215
|
+
* end
|
|
216
|
+
*/
|
|
217
|
+
read<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<Context<PouchFlags>>): Promise<Record<string, any>>;
|
|
218
|
+
/**
|
|
219
|
+
* @description Retrieves multiple documents from the database by their IDs
|
|
220
|
+
* @summary Fetches multiple documents from the PouchDB database using the bulkGet operation.
|
|
221
|
+
* This method generates document IDs based on the table name and IDs, then retrieves the documents.
|
|
222
|
+
* @param {string} tableName - The name of the table/collection
|
|
223
|
+
* @param {Array<string|number|bigint>} ids - The document IDs
|
|
224
|
+
* @return A promise that resolves to the retrieved documents with metadata
|
|
225
|
+
* @mermaid
|
|
226
|
+
* sequenceDiagram
|
|
227
|
+
* participant Client
|
|
228
|
+
* participant PouchAdapter
|
|
229
|
+
* participant PouchDB
|
|
230
|
+
*
|
|
231
|
+
* Client->>PouchAdapter: readAll(tableName, ids)
|
|
232
|
+
* PouchAdapter->>PouchAdapter: Map ids to generateId(tableName, id)
|
|
233
|
+
* PouchAdapter->>PouchDB: bulkGet({docs})
|
|
234
|
+
* alt Success
|
|
235
|
+
* PouchDB-->>PouchAdapter: BulkGetResponse
|
|
236
|
+
* PouchAdapter->>PouchAdapter: Process results
|
|
237
|
+
* PouchAdapter->>PouchAdapter: assignMetadata for each doc
|
|
238
|
+
* PouchAdapter-->>Client: Documents with metadata
|
|
239
|
+
* else Error
|
|
240
|
+
* PouchAdapter->>PouchAdapter: parseError(error)
|
|
241
|
+
* PouchAdapter-->>Client: Throws error
|
|
242
|
+
* end
|
|
243
|
+
*/
|
|
244
|
+
readAll<M extends Model>(tableName: Constructor<M>, ids: (string | number | bigint)[], ...args: ContextualArgs<Context<PouchFlags>>): Promise<Record<string, any>[]>;
|
|
245
|
+
/**
|
|
246
|
+
* @description Updates an existing document in the database
|
|
247
|
+
* @summary Updates a document in the PouchDB database using the put operation.
|
|
248
|
+
* This method handles error parsing and ensures the operation was successful.
|
|
249
|
+
* @param {string} tableName - The name of the table/collection
|
|
250
|
+
* @param {string|number} id - The document ID
|
|
251
|
+
* @param {Record<string, any>} model - The updated document data
|
|
252
|
+
* @return {Promise<Record<string, any>>} A promise that resolves to the updated document with metadata
|
|
253
|
+
* @mermaid
|
|
254
|
+
* sequenceDiagram
|
|
255
|
+
* participant Client
|
|
256
|
+
* participant PouchAdapter
|
|
257
|
+
* participant PouchDB
|
|
258
|
+
*
|
|
259
|
+
* Client->>PouchAdapter: update(tableName, id, model)
|
|
260
|
+
* PouchAdapter->>PouchDB: put(model)
|
|
261
|
+
* alt Success
|
|
262
|
+
* PouchDB-->>PouchAdapter: Response with ok=true
|
|
263
|
+
* PouchAdapter->>PouchAdapter: assignMetadata(model, response.rev)
|
|
264
|
+
* PouchAdapter-->>Client: Updated model with metadata
|
|
265
|
+
* else Error
|
|
266
|
+
* PouchDB-->>PouchAdapter: Error
|
|
267
|
+
* PouchAdapter->>PouchAdapter: parseError(e)
|
|
268
|
+
* PouchAdapter-->>Client: Throws error
|
|
269
|
+
* end
|
|
270
|
+
*/
|
|
271
|
+
update<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<Context<PouchFlags>>): Promise<Record<string, any>>;
|
|
272
|
+
/**
|
|
273
|
+
* @description Updates multiple documents in the database in a single operation
|
|
274
|
+
* @summary Updates multiple documents in the PouchDB database using the bulkDocs operation.
|
|
275
|
+
* This method handles error parsing and ensures all operations were successful.
|
|
276
|
+
* @param {string} tableName - The name of the table/collection
|
|
277
|
+
* @param {string[]|number[]} ids - The document IDs
|
|
278
|
+
* @param models - The updated document data
|
|
279
|
+
* @return A promise that resolves to the updated documents with metadata
|
|
280
|
+
* @mermaid
|
|
281
|
+
* sequenceDiagram
|
|
282
|
+
* participant Client
|
|
283
|
+
* participant PouchAdapter
|
|
284
|
+
* participant PouchDB
|
|
285
|
+
*
|
|
286
|
+
* Client->>PouchAdapter: updateAll(tableName, ids, models)
|
|
287
|
+
* PouchAdapter->>PouchDB: bulkDocs(models)
|
|
288
|
+
* alt Success
|
|
289
|
+
* PouchDB-->>PouchAdapter: Array of responses with ok=true
|
|
290
|
+
* PouchAdapter->>PouchAdapter: assignMultipleMetadata(models, revs)
|
|
291
|
+
* PouchAdapter-->>Client: Updated models with metadata
|
|
292
|
+
* else Error
|
|
293
|
+
* PouchDB-->>PouchAdapter: Array with errors
|
|
294
|
+
* PouchAdapter->>PouchAdapter: Check for errors
|
|
295
|
+
* PouchAdapter-->>Client: Throws InternalError
|
|
296
|
+
* end
|
|
297
|
+
*/
|
|
298
|
+
updateAll<M extends Model>(tableName: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<Context<PouchFlags>>): Promise<Record<string, any>[]>;
|
|
299
|
+
/**
|
|
300
|
+
* @description Deletes a document from the database by ID
|
|
301
|
+
* @summary Removes a document from the PouchDB database using the remove operation.
|
|
302
|
+
* This method first retrieves the document to get its revision, then deletes it.
|
|
303
|
+
* @param {string} tableName - The name of the table/collection
|
|
304
|
+
* @param {string|number} id - The document ID
|
|
305
|
+
* @return {Promise<Record<string, any>>} A promise that resolves to the deleted document with metadata
|
|
306
|
+
* @mermaid
|
|
307
|
+
* sequenceDiagram
|
|
308
|
+
* participant Client
|
|
309
|
+
* participant PouchAdapter
|
|
310
|
+
* participant PouchDB
|
|
311
|
+
*
|
|
312
|
+
* Client->>PouchAdapter: delete(tableName, id)
|
|
313
|
+
* PouchAdapter->>PouchAdapter: generateId(tableName, id)
|
|
314
|
+
* PouchAdapter->>PouchDB: get(_id)
|
|
315
|
+
* PouchDB-->>PouchAdapter: Document with _rev
|
|
316
|
+
* PouchAdapter->>PouchDB: remove(_id, record._rev)
|
|
317
|
+
* alt Success
|
|
318
|
+
* PouchDB-->>PouchAdapter: Success response
|
|
319
|
+
* PouchAdapter->>PouchAdapter: assignMetadata(record, record._rev)
|
|
320
|
+
* PouchAdapter-->>Client: Deleted document with metadata
|
|
321
|
+
* else Error
|
|
322
|
+
* PouchDB-->>PouchAdapter: Error
|
|
323
|
+
* PouchAdapter->>PouchAdapter: parseError(e)
|
|
324
|
+
* PouchAdapter-->>Client: Throws error
|
|
325
|
+
* end
|
|
326
|
+
*/
|
|
327
|
+
delete<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<Context<PouchFlags>>): Promise<Record<string, any>>;
|
|
328
|
+
/**
|
|
329
|
+
* @description Deletes multiple documents from the database by their IDs
|
|
330
|
+
* @summary Removes multiple documents from the PouchDB database in a single operation.
|
|
331
|
+
* This method first retrieves all documents to get their revisions, then marks them as deleted.
|
|
332
|
+
* @param {string} tableName - The name of the table/collection
|
|
333
|
+
* @param {Array<string|number|bigint>} ids - The document IDs
|
|
334
|
+
* @return A promise that resolves to the deleted documents with metadata
|
|
335
|
+
* @mermaid
|
|
336
|
+
* sequenceDiagram
|
|
337
|
+
* participant Client
|
|
338
|
+
* participant PouchAdapter
|
|
339
|
+
* participant PouchDB
|
|
340
|
+
*
|
|
341
|
+
* Client->>PouchAdapter: deleteAll(tableName, ids)
|
|
342
|
+
* PouchAdapter->>PouchAdapter: Map ids to generateId(tableName, id)
|
|
343
|
+
* PouchAdapter->>PouchDB: bulkGet({docs})
|
|
344
|
+
* PouchDB-->>PouchAdapter: BulkGetResponse with documents
|
|
345
|
+
* PouchAdapter->>PouchAdapter: Mark documents as deleted
|
|
346
|
+
* PouchAdapter->>PouchDB: bulkDocs(marked documents)
|
|
347
|
+
* alt Success
|
|
348
|
+
* PouchDB-->>PouchAdapter: Success responses
|
|
349
|
+
* PouchAdapter->>PouchAdapter: Process results
|
|
350
|
+
* PouchAdapter->>PouchAdapter: assignMetadata for each doc
|
|
351
|
+
* PouchAdapter-->>Client: Deleted documents with metadata
|
|
352
|
+
* else Error
|
|
353
|
+
* PouchAdapter->>PouchAdapter: Check for errors
|
|
354
|
+
* PouchAdapter-->>Client: Throws InternalError
|
|
355
|
+
* end
|
|
356
|
+
*/
|
|
357
|
+
deleteAll<M extends Model>(tableName: Constructor<M>, ids: (string | number | bigint)[], ...args: ContextualArgs<Context<PouchFlags>>): Promise<Record<string, any>[]>;
|
|
358
|
+
/**
|
|
359
|
+
* @description Executes a raw Mango query against the database
|
|
360
|
+
* @summary Runs a Mango query and optionally returns only the documents array or the entire response
|
|
361
|
+
* @template V - The return value type
|
|
362
|
+
* @param {MangoQuery} rawInput - The Mango query to execute
|
|
363
|
+
* @param {boolean} [docsOnly=true] - Whether to return only the documents array
|
|
364
|
+
* @return {Promise<V>} A promise resolving the query result
|
|
365
|
+
*/
|
|
366
|
+
raw<V>(rawInput: MangoQuery, docsOnly?: boolean, ...args: ContextualArgs<Context<PouchFlags>>): Promise<V>;
|
|
367
|
+
view<R>(ddoc: string, viewName: string, options: Record<string, any>, ..._args: ContextualArgs<Context<PouchFlags>>): Promise<ViewResponse<R>>;
|
|
368
|
+
/**
|
|
369
|
+
* @description Parses and converts errors from PouchDB to application-specific errors
|
|
370
|
+
* @summary Converts PouchDB errors to the application's error hierarchy.
|
|
371
|
+
* This instance method delegates to the static parseError method.
|
|
372
|
+
* @param {Error|string} err - The error object or message to parse
|
|
373
|
+
* @param {string} [reason] - Optional reason for the error
|
|
374
|
+
* @return {BaseError} The converted error object
|
|
375
|
+
*/
|
|
376
|
+
parseError<E extends BaseError>(err: Error | string, reason?: string): E;
|
|
377
|
+
/**
|
|
378
|
+
* @description Static method to parse and convert errors from PouchDB to application-specific errors
|
|
379
|
+
* @summary Converts PouchDB errors to the application's error hierarchy based on error codes and messages.
|
|
380
|
+
* This method analyzes the error type, status code, or message to determine the appropriate error class.
|
|
381
|
+
* @param {Error|string} err - The error object or message to parse
|
|
382
|
+
* @param {string} [reason] - Optional reason for the error
|
|
383
|
+
* @return {BaseError} The converted error object
|
|
384
|
+
* @mermaid
|
|
385
|
+
* sequenceDiagram
|
|
386
|
+
* participant Caller
|
|
387
|
+
* participant PouchAdapter
|
|
388
|
+
*
|
|
389
|
+
* Caller->>PouchAdapter: parseError(err, reason)
|
|
390
|
+
* alt err is BaseError
|
|
391
|
+
* PouchAdapter-->>Caller: Return err as is
|
|
392
|
+
* else err is string
|
|
393
|
+
* alt contains "already exist" or "update conflict"
|
|
394
|
+
* PouchAdapter-->>Caller: ConflictError
|
|
395
|
+
* else contains "missing" or "deleted"
|
|
396
|
+
* PouchAdapter-->>Caller: NotFoundError
|
|
397
|
+
* end
|
|
398
|
+
* else err has status/statusCode/code
|
|
399
|
+
* Note over PouchAdapter: Extract code and reason
|
|
400
|
+
* else
|
|
401
|
+
* Note over PouchAdapter: Use err.message as code
|
|
402
|
+
* end
|
|
403
|
+
*
|
|
404
|
+
* Note over PouchAdapter: Switch on code
|
|
405
|
+
* alt code is 401, 412, or 409
|
|
406
|
+
* PouchAdapter->>ErrorTypes: ConflictError
|
|
407
|
+
* else code is 404
|
|
408
|
+
* PouchAdapter->>ErrorTypes: NotFoundError
|
|
409
|
+
* else code is 400
|
|
410
|
+
* alt code contains "No index exists"
|
|
411
|
+
* PouchAdapter->>ErrorTypes: IndexError
|
|
412
|
+
* else
|
|
413
|
+
* PouchAdapter->>ErrorTypes: InternalError
|
|
414
|
+
* else code contains "ECONNREFUSED"
|
|
415
|
+
* PouchAdapter->>ErrorTypes: ConnectionError
|
|
416
|
+
* else
|
|
417
|
+
* PouchAdapter->>ErrorTypes: InternalError
|
|
418
|
+
* end
|
|
419
|
+
*/
|
|
420
|
+
static parseError<E extends BaseError>(err: Error | string, reason?: string): E;
|
|
421
|
+
/**
|
|
422
|
+
* @description Sets up decorations for PouchDB-specific model properties
|
|
423
|
+
* @summary Configures decorators for createdBy and updatedBy fields in models.
|
|
424
|
+
* This method defines how these fields should be automatically populated during create and update operations.
|
|
425
|
+
*/
|
|
426
|
+
static decoration(): void;
|
|
427
|
+
}
|