@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.
@@ -1,8 +1,9 @@
1
- import type { CbConnectionLike, CbExecOpt } from "../connection";
2
- import type { KeyValue } from "@leyyo/common";
1
+ import type { CbConnectionLike } from "../connection";
2
+ import { Bucket, BucketSettings, type Cluster, Collection, CollectionSpec, type QueryMetaData, type QueryResult, Scope, ScopeSpec } from "couchbase";
3
+ import { type IgnoreFieldsByType, KeyValue, type ReplaceType } from "@leyyo/common";
3
4
  import type { StrKey } from "@leyyo/common";
4
- import type { CbExistsOpt, CbGetOpt, CbInsertOpt, CbReplaceOpt, CbRepoProps, CbRepoLike, CbRepoOpt, CbUpsertOpt } from "./index.types";
5
- import { DbRepo } from "@samet-it/be-db-common";
5
+ import type { CbExistsOpt, CbGetOpt, CbInsertOpt, CbReplaceOpt, CbRepoProps, CbRepoPropsPart, CbRepoLike, CbRepoOpt, CbUpsertOpt, CbExecOpt } from "./index.types";
6
+ import { type DbLines, type DbQueryResultMore, type DbQueryResultOne, DbRepo } from "@samet-it/be-db-common";
6
7
  import type { DefDims, Entity, Pair, Portion, UrnDef, UrnDocLike, View } from "@samet-it/be-base-common";
7
8
  import type { QueryRegular } from "@leyyo/query";
8
9
  /**
@@ -18,8 +19,12 @@ import type { QueryRegular } from "@leyyo/query";
18
19
  * - 6-`KEYS`: keys to autocomplete, def: keys of {@link Entity}
19
20
  * - 7-`DIMS`: dimensions for presentation layer {@link DefDims}
20
21
  * */
21
- export declare abstract class CbRepo<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 DbRepo<CbConnectionLike, CbExecOpt, ENT, ID, URN, VIEW, PAIR, PORTION, KEYS, DIMS> implements CbRepoLike<ENT, ID, URN, VIEW, PAIR, PORTION, KEYS, DIMS> {
22
+ export declare abstract class CbRepo<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 DbRepo<CbConnectionLike, CbExecOpt, QueryMetaData, ENT, ID, URN, VIEW, PAIR, PORTION, KEYS, DIMS> implements CbRepoLike<ENT, ID, URN, VIEW, PAIR, PORTION, KEYS, DIMS> {
22
23
  private static _specs;
24
+ /**
25
+ * Created indexes, it's temporary property
26
+ * */
27
+ private _createdIndices;
23
28
  /** @inheritDoc */
24
29
  protected _props: CbRepoProps<ENT, ID>;
25
30
  /**
@@ -55,7 +60,7 @@ export declare abstract class CbRepo<ENT extends Entity<ID>, ID extends KeyValue
55
60
  *
56
61
  * @param {...Array<string>} keys - keys of model
57
62
  * */
58
- protected _createMoreIndices(...keys: Array<keyof ENT>): Promise<void>;
63
+ protected _createMoreIndices(...keys: Array<keyof ENT | string>): Promise<void>;
59
64
  /**
60
65
  * Execute the creation of primary key
61
66
  * */
@@ -82,6 +87,46 @@ export declare abstract class CbRepo<ENT extends Entity<ID>, ID extends KeyValue
82
87
  protected $createIndices(): Promise<void>;
83
88
  /** @inheritDoc */
84
89
  get props(): Readonly<CbRepoProps<ENT, ID>>;
90
+ /**
91
+ * Shortcut to {@link CbConnectionLike}
92
+ * */
93
+ get conn(): CbConnectionLike;
94
+ /**
95
+ * Shortcut to {@link CbConnProps#cluster}
96
+ * */
97
+ get cluster(): Cluster;
98
+ /**
99
+ * Bucket instance
100
+ *
101
+ * @type {Bucket}
102
+ * */
103
+ get bucket(): Bucket & CbRepoPropsPart<BucketSettings>;
104
+ /**
105
+ * Scope instance
106
+ *
107
+ * @type {Scope}
108
+ * */
109
+ get scope(): Scope & CbRepoPropsPart<ScopeSpec>;
110
+ /**
111
+ * Collection instance
112
+ *
113
+ * @type {Collection}
114
+ * */
115
+ get collection(): Collection & CbRepoPropsPart<CollectionSpec>;
116
+ /** {@inheritDoc} */
117
+ field(field: string): string;
118
+ /** {@inheritDoc} */
119
+ value(value: unknown): string;
120
+ /** {@inheritDoc} */
121
+ flatten<T>(result: QueryResult<T>): Array<T>;
122
+ /** {@inheritDoc} */
123
+ castDates<T>(given: ReplaceType<T, Date, string> | T, ...fields: Array<IgnoreFieldsByType<T, Date>>): void;
124
+ /** {@inheritDoc} */
125
+ castDatesForList<T>(given: Array<ReplaceType<T, Date, string> | T>, ...fields: Array<IgnoreFieldsByType<T, Date>>): void;
126
+ /** {@inheritDoc} */
127
+ more<T>(lines: string | DbLines, p1?: string | CbExecOpt): Promise<DbQueryResultMore<T, QueryMetaData>>;
128
+ /** {@inheritDoc} */
129
+ one<T>(lines: string | DbLines, p1?: string | CbExecOpt): Promise<DbQueryResultOne<T, QueryMetaData>>;
85
130
  /** @inheritDoc */
86
131
  $getByPrimary(key: string, p1?: CbGetOpt | string, ignoreCheck?: boolean): Promise<ENT | undefined>;
87
132
  /** @inheritDoc */