@samet-it/be-couchbase-common 1.1.7 → 1.1.9
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/dist/config/couchbase-common.config.js +28 -8
- package/dist/config/index.types.d.ts +4 -0
- package/dist/connection/cb-direct.connection.js +1 -1
- package/dist/connection/cb.connection.d.ts +45 -17
- package/dist/connection/cb.connection.js +103 -151
- package/dist/connection/index.types.d.ts +14 -34
- package/dist/filter/cb-filter-util.impl.js +9 -9
- package/dist/filter/index.types.d.ts +3 -2
- package/dist/repo/cb-direct.repo.js +3 -23
- package/dist/repo/cb.repo.d.ts +51 -6
- package/dist/repo/cb.repo.js +339 -127
- package/dist/repo/index.types.d.ts +73 -39
- package/dist/repo/index.types.js +1 -0
- package/package.json +7 -6
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { Bucket, BucketSettings, Cluster, Collection, CollectionSpec, RemoveOptions, Scope, ScopeSpec, UpsertOptions } from "couchbase";
|
|
2
|
-
import type { CbConnectionLike
|
|
3
|
-
import type { DbRepoLike, DbRepoOpt,
|
|
1
|
+
import type { Bucket, BucketSettings, Cluster, Collection, CollectionSpec, ExistsOptions, GetOptions, InsertOptions, QueryOptions, QueryResult, QueryMetaData, RemoveOptions, ReplaceOptions, Scope, ScopeSpec, UpsertOptions } from "couchbase";
|
|
2
|
+
import type { CbConnectionLike } from "../connection";
|
|
3
|
+
import type { DbExecOpt, DbRepoDirectOpt, DbRepoLike, DbRepoOpt, DbRepoProps } from "@samet-it/be-db-common";
|
|
4
4
|
import type { DefDims, Entity, Pair, Portion, UrnDef, UrnDocLike, View } from "@samet-it/be-base-common";
|
|
5
|
-
import type {
|
|
6
|
-
import type { DbRepoProps } from "@samet-it/be-db-common";
|
|
7
|
-
import type { KeyValue, StrKey } from "@leyyo/common";
|
|
5
|
+
import type { IgnoreFieldsByType, KeyValue, ReplaceType, StrKey } from "@leyyo/common";
|
|
8
6
|
/**
|
|
9
7
|
* Couchbase repository (collection) interface
|
|
10
8
|
*
|
|
@@ -18,9 +16,47 @@ import type { KeyValue, StrKey } from "@leyyo/common";
|
|
|
18
16
|
* - 6-`KEYS`: keys to autocomplete, def: keys of {@link Entity}
|
|
19
17
|
* - 7-`DIMS`: dimensions for presentation layer {@link DefDims}
|
|
20
18
|
* */
|
|
21
|
-
export interface CbRepoLike<ENT extends Entity<ID>, ID extends KeyValue = KeyValue, URN extends UrnDocLike = UrnDef<ID>, VIEW extends View<ID> = ENT, PAIR extends Pair<ID> = Pair<ID>, PORTION extends Portion<ID> = Portion<ID>, KEYS extends string = StrKey<ENT>, DIMS extends DefDims = DefDims> extends DbRepoLike<CbConnectionLike, CbExecOpt, ENT, ID, URN, VIEW, PAIR, PORTION, KEYS, DIMS> {
|
|
19
|
+
export interface CbRepoLike<ENT extends Entity<ID>, ID extends KeyValue = KeyValue, URN extends UrnDocLike = UrnDef<ID>, VIEW extends View<ID> = ENT, PAIR extends Pair<ID> = Pair<ID>, PORTION extends Portion<ID> = Portion<ID>, KEYS extends string = StrKey<ENT>, DIMS extends DefDims = DefDims> extends DbRepoLike<CbConnectionLike, CbExecOpt, QueryMetaData, ENT, ID, URN, VIEW, PAIR, PORTION, KEYS, DIMS> {
|
|
22
20
|
/** @inheritDoc */
|
|
23
21
|
get props(): Readonly<CbRepoProps<ENT, ID>>;
|
|
22
|
+
/**
|
|
23
|
+
* Shortcut to {@link CbConnectionLike}
|
|
24
|
+
* */
|
|
25
|
+
get conn(): CbConnectionLike;
|
|
26
|
+
/**
|
|
27
|
+
* Shortcut to {@link CbConnProps#cluster}
|
|
28
|
+
* */
|
|
29
|
+
get cluster(): Cluster;
|
|
30
|
+
/**
|
|
31
|
+
* Bucket instance
|
|
32
|
+
*
|
|
33
|
+
* @type {Bucket}
|
|
34
|
+
* */
|
|
35
|
+
get bucket(): Bucket & CbRepoPropsPart<BucketSettings>;
|
|
36
|
+
/**
|
|
37
|
+
* Scope instance
|
|
38
|
+
*
|
|
39
|
+
* @type {Scope}
|
|
40
|
+
* */
|
|
41
|
+
get scope(): Scope & CbRepoPropsPart<ScopeSpec>;
|
|
42
|
+
/**
|
|
43
|
+
* Collection instance
|
|
44
|
+
*
|
|
45
|
+
* @type {Collection}
|
|
46
|
+
* */
|
|
47
|
+
get collection(): Collection & CbRepoPropsPart<CollectionSpec>;
|
|
48
|
+
/**
|
|
49
|
+
* Flatten query result to rows
|
|
50
|
+
* */
|
|
51
|
+
flatten<T>(result: QueryResult<T>): Array<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Cast dates
|
|
54
|
+
* */
|
|
55
|
+
castDates<T>(given: ReplaceType<T, Date, string> | T, ...fields: Array<IgnoreFieldsByType<T, Date>>): void;
|
|
56
|
+
/**
|
|
57
|
+
* Cast dates for an array
|
|
58
|
+
* */
|
|
59
|
+
castDatesForList<T>(given: Array<ReplaceType<T, Date, string> | T>, ...fields: Array<IgnoreFieldsByType<T, Date>>): void;
|
|
24
60
|
/** @inheritDoc */
|
|
25
61
|
insert(doc: ENT, opt?: CbInsertOpt | string, ignoreCheck?: boolean): Promise<string>;
|
|
26
62
|
/** @inheritDoc */
|
|
@@ -72,6 +108,24 @@ export interface CbRepoOpt<ENT extends Entity<ID>, ID extends KeyValue = KeyValu
|
|
|
72
108
|
* @type {string}
|
|
73
109
|
* */
|
|
74
110
|
collectionName?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Bucket instance
|
|
113
|
+
*
|
|
114
|
+
* @type {Bucket}
|
|
115
|
+
* */
|
|
116
|
+
bucket: Bucket & CbRepoPropsPart<BucketSettings>;
|
|
117
|
+
/**
|
|
118
|
+
* Scope instance
|
|
119
|
+
*
|
|
120
|
+
* @type {Scope}
|
|
121
|
+
* */
|
|
122
|
+
scope: Scope & CbRepoPropsPart<ScopeSpec>;
|
|
123
|
+
/**
|
|
124
|
+
* Collection instance
|
|
125
|
+
*
|
|
126
|
+
* @type {Collection}
|
|
127
|
+
* */
|
|
128
|
+
collection: Collection & CbRepoPropsPart<CollectionSpec>;
|
|
75
129
|
/**
|
|
76
130
|
* Create indices when it's started
|
|
77
131
|
*
|
|
@@ -87,18 +141,6 @@ export interface CbRepoOpt<ENT extends Entity<ID>, ID extends KeyValue = KeyValu
|
|
|
87
141
|
* - 1-`ID`: id type {@link KeyValue}
|
|
88
142
|
* */
|
|
89
143
|
export interface CbRepoProps<ENT extends Entity<ID>, ID extends KeyValue = KeyValue> extends CbRepoOpt<ENT, ID>, DbRepoProps<CbConnectionLike, ENT, ID> {
|
|
90
|
-
/**
|
|
91
|
-
* Cluster
|
|
92
|
-
*
|
|
93
|
-
* @type {Cluster}
|
|
94
|
-
* */
|
|
95
|
-
cluster: Cluster;
|
|
96
|
-
/**
|
|
97
|
-
* Full collection address
|
|
98
|
-
*
|
|
99
|
-
* @type {string}
|
|
100
|
-
* */
|
|
101
|
-
full: string;
|
|
102
144
|
/**
|
|
103
145
|
* Bucket instance
|
|
104
146
|
*
|
|
@@ -140,20 +182,21 @@ export interface CbRepoPropsPart<SPEC> {
|
|
|
140
182
|
* - 3-`DIMS`: dimensions for presentation layer {@link DefDims}
|
|
141
183
|
* - 4-`R`: ??
|
|
142
184
|
* */
|
|
143
|
-
export interface CbRepoDirectOpt<ENT extends Entity<ID>, ID extends KeyValue = KeyValue, URN extends UrnDocLike = UrnDef<ID>, DIMS extends DefDims = DefDims, R = unknown> extends CbRepoOpt<ENT, ID> {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
* Overridable method to easy use
|
|
150
|
-
* */
|
|
151
|
-
toUrnTuple?: DbRepoToUrnTuple<URN>;
|
|
185
|
+
export interface CbRepoDirectOpt<ENT extends Entity<ID>, ID extends KeyValue = KeyValue, URN extends UrnDocLike = UrnDef<ID>, DIMS extends DefDims = DefDims, R = unknown> extends CbRepoOpt<ENT, ID>, DbRepoDirectOpt<ENT, ID, URN, DIMS, R> {
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* General result for mutable queries to return key
|
|
189
|
+
* */
|
|
190
|
+
export interface CbResultX {
|
|
152
191
|
/**
|
|
153
|
-
*
|
|
192
|
+
* It should be `meta().id`
|
|
154
193
|
* */
|
|
155
|
-
|
|
194
|
+
x: string;
|
|
156
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Couchbase query option
|
|
198
|
+
* */
|
|
199
|
+
export type CbExecOpt = DbExecOpt & QueryOptions;
|
|
157
200
|
/**
|
|
158
201
|
* Couchbase insert query option
|
|
159
202
|
* */
|
|
@@ -178,12 +221,3 @@ export type CbGetOpt = CbExecOpt & GetOptions;
|
|
|
178
221
|
* Couchbase upsert query option
|
|
179
222
|
* */
|
|
180
223
|
export type CbUpsertOpt = CbExecOpt & UpsertOptions;
|
|
181
|
-
/**
|
|
182
|
-
* General result for mutable queries to return key
|
|
183
|
-
* */
|
|
184
|
-
export interface CbResultX {
|
|
185
|
-
/**
|
|
186
|
-
* It should be `meta().id`
|
|
187
|
-
* */
|
|
188
|
-
x: string;
|
|
189
|
-
}
|
package/dist/repo/index.types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samet-it/be-couchbase-common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "Couchbase common component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Couchbase"
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@babel/preset-env": "^7.28.0",
|
|
41
41
|
"@babel/preset-typescript": "^7.27.1",
|
|
42
42
|
"@eslint/js": "^9.33.0",
|
|
43
|
+
"@types/express": "^5.0.6",
|
|
43
44
|
"@types/jest": "^30.0.0",
|
|
44
45
|
"@types/node": "^24.2.1",
|
|
45
46
|
"@typescript-eslint/eslint-plugin": "^8.39.1",
|
|
@@ -66,13 +67,13 @@
|
|
|
66
67
|
}
|
|
67
68
|
},
|
|
68
69
|
"dependencies": {
|
|
69
|
-
"@leyyo/common": "^1.2.
|
|
70
|
-
"@leyyo/env": "^1.2.
|
|
70
|
+
"@leyyo/common": "^1.2.4",
|
|
71
|
+
"@leyyo/env": "^1.2.5",
|
|
71
72
|
"@leyyo/query": "^1.2.1",
|
|
72
73
|
"@leyyo/type": "^1.1.1",
|
|
73
|
-
"@samet-it/be-base-common": "^1.1.
|
|
74
|
-
"@samet-it/be-cache-common": "^1.1.
|
|
75
|
-
"@samet-it/be-db-common": "^1.1.
|
|
74
|
+
"@samet-it/be-base-common": "^1.1.5",
|
|
75
|
+
"@samet-it/be-cache-common": "^1.1.10",
|
|
76
|
+
"@samet-it/be-db-common": "^1.1.9",
|
|
76
77
|
"couchbase": "^4.6.0"
|
|
77
78
|
}
|
|
78
79
|
}
|