@decaf-ts/for-couchdb 0.13.0 → 0.14.1
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/for-couchdb.cjs +1 -1
- package/dist/for-couchdb.cjs.map +1 -1
- package/dist/for-couchdb.js +1 -1
- package/dist/for-couchdb.js.map +1 -1
- package/lib/cjs/adapter.cjs +6 -12
- package/lib/cjs/adapter.cjs.map +1 -1
- package/lib/cjs/{errors.cjs → errors/IndexError.cjs} +2 -2
- package/lib/cjs/errors/IndexError.cjs.map +1 -0
- package/lib/cjs/errors/IndexPlanningError.cjs +15 -0
- package/lib/cjs/errors/IndexPlanningError.cjs.map +1 -0
- package/lib/cjs/errors/index.cjs +20 -0
- package/lib/cjs/errors/index.cjs.map +1 -0
- package/lib/cjs/index.cjs +22 -4
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/indexes/generator.cjs +13 -9
- package/lib/cjs/indexes/generator.cjs.map +1 -1
- package/lib/cjs/query/Paginator.cjs +32 -16
- package/lib/cjs/query/Paginator.cjs.map +1 -1
- package/lib/cjs/query/Statement.cjs +13 -8
- package/lib/cjs/query/Statement.cjs.map +1 -1
- package/lib/cjs/query/index.cjs +1 -0
- package/lib/cjs/query/index.cjs.map +1 -1
- package/lib/cjs/query/planner.cjs +431 -0
- package/lib/cjs/query/planner.cjs.map +1 -0
- package/lib/esm/adapter.js +1 -7
- package/lib/esm/adapter.js.map +1 -1
- package/lib/esm/{errors.js → errors/IndexError.js} +1 -1
- package/lib/esm/errors/IndexError.js.map +1 -0
- package/lib/esm/errors/IndexPlanningError.js +10 -0
- package/lib/esm/errors/IndexPlanningError.js.map +1 -0
- package/lib/esm/errors/index.js +3 -0
- package/lib/esm/errors/index.js.map +1 -0
- package/lib/esm/index.js +17 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/indexes/generator.js +12 -10
- package/lib/esm/indexes/generator.js.map +1 -1
- package/lib/esm/query/Paginator.js +32 -16
- package/lib/esm/query/Paginator.js.map +1 -1
- package/lib/esm/query/Statement.js +14 -9
- package/lib/esm/query/Statement.js.map +1 -1
- package/lib/esm/query/index.js +1 -0
- package/lib/esm/query/index.js.map +1 -1
- package/lib/esm/query/planner.js +413 -0
- package/lib/esm/query/planner.js.map +1 -0
- package/lib/types/adapter.d.cts +3 -3
- package/lib/types/adapter.d.mts +3 -3
- package/lib/types/errors/IndexPlanningError.d.cts +17 -0
- package/lib/types/errors/IndexPlanningError.d.mts +17 -0
- package/lib/types/errors/index.d.cts +2 -0
- package/lib/types/errors/index.d.mts +2 -0
- package/lib/types/index.d.cts +17 -3
- package/lib/types/index.d.mts +17 -3
- package/lib/types/indexes/generator.d.cts +13 -0
- package/lib/types/indexes/generator.d.mts +13 -0
- package/lib/types/query/Paginator.d.cts +3 -0
- package/lib/types/query/Paginator.d.mts +3 -0
- package/lib/types/query/Statement.d.cts +3 -2
- package/lib/types/query/Statement.d.mts +3 -2
- package/lib/types/query/index.d.cts +1 -0
- package/lib/types/query/index.d.mts +1 -0
- package/lib/types/query/planner.d.cts +64 -0
- package/lib/types/query/planner.d.mts +64 -0
- package/lib/types/types.d.cts +8 -0
- package/lib/types/types.d.mts +8 -0
- package/package.json +2 -1
- package/lib/cjs/errors.cjs.map +0 -1
- package/lib/esm/errors.js.map +0 -1
- /package/lib/types/{errors.d.cts → errors/IndexError.d.cts} +0 -0
- /package/lib/types/{errors.d.mts → errors/IndexError.d.mts} +0 -0
|
@@ -26,6 +26,8 @@ import { Constructor } from "@decaf-ts/decoration";
|
|
|
26
26
|
* const page2 = await paginator.page(2);
|
|
27
27
|
*/
|
|
28
28
|
export declare class CouchDBPaginator<M extends Model> extends Paginator<M, M[], MangoQuery> {
|
|
29
|
+
protected _bookmarks: Map<number, string>;
|
|
30
|
+
protected _knownLastPage?: number;
|
|
29
31
|
/**
|
|
30
32
|
* @description Creates a new CouchDBPaginator instance
|
|
31
33
|
* @summary Initializes a paginator for CouchDB query results
|
|
@@ -35,6 +37,7 @@ export declare class CouchDBPaginator<M extends Model> extends Paginator<M, M[],
|
|
|
35
37
|
* @param {Constructor<M>} clazz - The model constructor
|
|
36
38
|
*/
|
|
37
39
|
constructor(adapter: CouchDBAdapter<any, any, any>, query: MangoQuery, size: number, clazz: Constructor<M>);
|
|
40
|
+
private isValidBookmark;
|
|
38
41
|
/**
|
|
39
42
|
* @description Prepares a query for pagination
|
|
40
43
|
* @summary Modifies the raw query to include pagination parameters
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Adapter,
|
|
1
|
+
import { Adapter, Condition, ContextOf, SelectSelector, Statement, UnsupportedError, ViewKind } from "@decaf-ts/core";
|
|
2
2
|
import { MangoQuery, MangoSelector, ViewResponse } from "../types.d.cts";
|
|
3
3
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
4
|
import { CouchDBViewMetadata } from "../views/types.d.cts";
|
|
5
5
|
import { CouchDBAdapter } from "../adapter.d.cts";
|
|
6
|
+
import { CouchDBFlags } from "../types.d.cts";
|
|
6
7
|
type CouchDBViewDescriptor = {
|
|
7
8
|
ddoc: string;
|
|
8
9
|
view: string;
|
|
@@ -42,7 +43,7 @@ type CouchDBAggregateInfo = {
|
|
|
42
43
|
export declare class CouchDBStatement<M extends Model, A extends Adapter<any, any, MangoQuery, any>, R> extends Statement<M, A, R, MangoQuery> {
|
|
43
44
|
protected manualAggregation?: CouchDBAggregateInfo;
|
|
44
45
|
protected attributeTypeCache: Map<string, string | undefined>;
|
|
45
|
-
constructor(adapter: A, overrides?: Partial<
|
|
46
|
+
constructor(adapter: A, overrides?: Partial<CouchDBFlags>);
|
|
46
47
|
/**
|
|
47
48
|
* @description Builds a CouchDB Mango query from the statement
|
|
48
49
|
* @summary Converts the statement's conditions, selectors, and options into a CouchDB Mango query
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Adapter,
|
|
1
|
+
import { Adapter, Condition, ContextOf, SelectSelector, Statement, UnsupportedError, ViewKind } from "@decaf-ts/core";
|
|
2
2
|
import { MangoQuery, MangoSelector, ViewResponse } from "../types.d.mts";
|
|
3
3
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
4
|
import { CouchDBViewMetadata } from "../views/types.d.mts";
|
|
5
5
|
import { CouchDBAdapter } from "../adapter.d.mts";
|
|
6
|
+
import { CouchDBFlags } from "../types.d.mts";
|
|
6
7
|
type CouchDBViewDescriptor = {
|
|
7
8
|
ddoc: string;
|
|
8
9
|
view: string;
|
|
@@ -42,7 +43,7 @@ type CouchDBAggregateInfo = {
|
|
|
42
43
|
export declare class CouchDBStatement<M extends Model, A extends Adapter<any, any, MangoQuery, any>, R> extends Statement<M, A, R, MangoQuery> {
|
|
43
44
|
protected manualAggregation?: CouchDBAggregateInfo;
|
|
44
45
|
protected attributeTypeCache: Map<string, string | undefined>;
|
|
45
|
-
constructor(adapter: A, overrides?: Partial<
|
|
46
|
+
constructor(adapter: A, overrides?: Partial<CouchDBFlags>);
|
|
46
47
|
/**
|
|
47
48
|
* @description Builds a CouchDB Mango query from the statement
|
|
48
49
|
* @summary Converts the statement's conditions, selectors, and options into a CouchDB Mango query
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { OrderDirection } from "@decaf-ts/core";
|
|
2
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
3
|
+
import { MangoQuery, MangoSelector, SortOrder } from "../types.d.cts";
|
|
4
|
+
export type MangoIndexCandidate = {
|
|
5
|
+
name: string;
|
|
6
|
+
ddoc: string;
|
|
7
|
+
fields: string[];
|
|
8
|
+
direction?: OrderDirection;
|
|
9
|
+
source: "table" | "defaultQuery" | "index";
|
|
10
|
+
};
|
|
11
|
+
export type MangoIndexResolution = {
|
|
12
|
+
candidate: MangoIndexCandidate;
|
|
13
|
+
use_index: string | [string, string];
|
|
14
|
+
};
|
|
15
|
+
export type MangoPlannerLog = {
|
|
16
|
+
debug?: (message: string) => void;
|
|
17
|
+
warn?: (message: string) => void;
|
|
18
|
+
};
|
|
19
|
+
export type RequiredMangoIndexShape = {
|
|
20
|
+
tableName: string;
|
|
21
|
+
modelName: string;
|
|
22
|
+
equalityFields: string[];
|
|
23
|
+
rangeFields: string[];
|
|
24
|
+
sortFields: string[];
|
|
25
|
+
sortDirection?: OrderDirection;
|
|
26
|
+
requiredFields: string[];
|
|
27
|
+
};
|
|
28
|
+
export type ReversedIndexDeclaration = {
|
|
29
|
+
attribute: string;
|
|
30
|
+
compositions: string[];
|
|
31
|
+
directions: OrderDirection[];
|
|
32
|
+
name: string;
|
|
33
|
+
ddoc: string;
|
|
34
|
+
fields: Array<string | Record<string, OrderDirection>>;
|
|
35
|
+
decorator: string;
|
|
36
|
+
};
|
|
37
|
+
export declare function normalizeSortField(entry: SortOrder): {
|
|
38
|
+
field: string;
|
|
39
|
+
direction?: OrderDirection;
|
|
40
|
+
} | undefined;
|
|
41
|
+
export declare function getSortFields(query: MangoQuery): string[];
|
|
42
|
+
export declare function getSortDirection(query: MangoQuery): OrderDirection | undefined;
|
|
43
|
+
export declare function getEqualitySelectorFields(selector?: MangoSelector): Set<string>;
|
|
44
|
+
export declare function getRangeSelectorFields(selector?: MangoSelector): Set<string>;
|
|
45
|
+
export declare function buildGeneratedIndexCandidates(clazz: Constructor): MangoIndexCandidate[];
|
|
46
|
+
export declare function findGeneratedIndexCandidateByName(clazz: Constructor, expectedName: string): MangoIndexCandidate | undefined;
|
|
47
|
+
export declare function resolveGeneratedIndexForQuery(clazz: Constructor, query: MangoQuery, options?: {
|
|
48
|
+
preserveDefaultQuery?: boolean;
|
|
49
|
+
requireSortCoverage?: boolean;
|
|
50
|
+
}): MangoIndexResolution | undefined;
|
|
51
|
+
export declare function getRequiredMangoIndexShape(clazz: Constructor, query: MangoQuery): RequiredMangoIndexShape;
|
|
52
|
+
export declare function reverseRequiredShapeToIndexDeclaration(clazz: Constructor, query: MangoQuery): ReversedIndexDeclaration;
|
|
53
|
+
export declare function attachGeneratedUseIndex(clazz: Constructor | undefined, query: MangoQuery, log?: MangoPlannerLog, options?: {
|
|
54
|
+
preserveDefaultQuery?: boolean;
|
|
55
|
+
requireSortCoverage?: boolean;
|
|
56
|
+
requireIndex?: boolean;
|
|
57
|
+
forceNamedIndexes?: boolean;
|
|
58
|
+
}): void;
|
|
59
|
+
export declare function requireGeneratedUseIndex(clazz: Constructor, query: MangoQuery, log?: MangoPlannerLog, options?: {
|
|
60
|
+
requireSortCoverage?: boolean;
|
|
61
|
+
}): void;
|
|
62
|
+
export declare function warnScanProneMangoOperators(selector: unknown, log?: MangoPlannerLog, path?: string): void;
|
|
63
|
+
export declare function ensureDeterministicSort(query: MangoQuery, tieBreaker: string, direction?: OrderDirection): void;
|
|
64
|
+
export declare function enableMangoExecutionStats(query: MangoQuery): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { OrderDirection } from "@decaf-ts/core";
|
|
2
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
3
|
+
import { MangoQuery, MangoSelector, SortOrder } from "../types.d.mts";
|
|
4
|
+
export type MangoIndexCandidate = {
|
|
5
|
+
name: string;
|
|
6
|
+
ddoc: string;
|
|
7
|
+
fields: string[];
|
|
8
|
+
direction?: OrderDirection;
|
|
9
|
+
source: "table" | "defaultQuery" | "index";
|
|
10
|
+
};
|
|
11
|
+
export type MangoIndexResolution = {
|
|
12
|
+
candidate: MangoIndexCandidate;
|
|
13
|
+
use_index: string | [string, string];
|
|
14
|
+
};
|
|
15
|
+
export type MangoPlannerLog = {
|
|
16
|
+
debug?: (message: string) => void;
|
|
17
|
+
warn?: (message: string) => void;
|
|
18
|
+
};
|
|
19
|
+
export type RequiredMangoIndexShape = {
|
|
20
|
+
tableName: string;
|
|
21
|
+
modelName: string;
|
|
22
|
+
equalityFields: string[];
|
|
23
|
+
rangeFields: string[];
|
|
24
|
+
sortFields: string[];
|
|
25
|
+
sortDirection?: OrderDirection;
|
|
26
|
+
requiredFields: string[];
|
|
27
|
+
};
|
|
28
|
+
export type ReversedIndexDeclaration = {
|
|
29
|
+
attribute: string;
|
|
30
|
+
compositions: string[];
|
|
31
|
+
directions: OrderDirection[];
|
|
32
|
+
name: string;
|
|
33
|
+
ddoc: string;
|
|
34
|
+
fields: Array<string | Record<string, OrderDirection>>;
|
|
35
|
+
decorator: string;
|
|
36
|
+
};
|
|
37
|
+
export declare function normalizeSortField(entry: SortOrder): {
|
|
38
|
+
field: string;
|
|
39
|
+
direction?: OrderDirection;
|
|
40
|
+
} | undefined;
|
|
41
|
+
export declare function getSortFields(query: MangoQuery): string[];
|
|
42
|
+
export declare function getSortDirection(query: MangoQuery): OrderDirection | undefined;
|
|
43
|
+
export declare function getEqualitySelectorFields(selector?: MangoSelector): Set<string>;
|
|
44
|
+
export declare function getRangeSelectorFields(selector?: MangoSelector): Set<string>;
|
|
45
|
+
export declare function buildGeneratedIndexCandidates(clazz: Constructor): MangoIndexCandidate[];
|
|
46
|
+
export declare function findGeneratedIndexCandidateByName(clazz: Constructor, expectedName: string): MangoIndexCandidate | undefined;
|
|
47
|
+
export declare function resolveGeneratedIndexForQuery(clazz: Constructor, query: MangoQuery, options?: {
|
|
48
|
+
preserveDefaultQuery?: boolean;
|
|
49
|
+
requireSortCoverage?: boolean;
|
|
50
|
+
}): MangoIndexResolution | undefined;
|
|
51
|
+
export declare function getRequiredMangoIndexShape(clazz: Constructor, query: MangoQuery): RequiredMangoIndexShape;
|
|
52
|
+
export declare function reverseRequiredShapeToIndexDeclaration(clazz: Constructor, query: MangoQuery): ReversedIndexDeclaration;
|
|
53
|
+
export declare function attachGeneratedUseIndex(clazz: Constructor | undefined, query: MangoQuery, log?: MangoPlannerLog, options?: {
|
|
54
|
+
preserveDefaultQuery?: boolean;
|
|
55
|
+
requireSortCoverage?: boolean;
|
|
56
|
+
requireIndex?: boolean;
|
|
57
|
+
forceNamedIndexes?: boolean;
|
|
58
|
+
}): void;
|
|
59
|
+
export declare function requireGeneratedUseIndex(clazz: Constructor, query: MangoQuery, log?: MangoPlannerLog, options?: {
|
|
60
|
+
requireSortCoverage?: boolean;
|
|
61
|
+
}): void;
|
|
62
|
+
export declare function warnScanProneMangoOperators(selector: unknown, log?: MangoPlannerLog, path?: string): void;
|
|
63
|
+
export declare function ensureDeterministicSort(query: MangoQuery, tieBreaker: string, direction?: OrderDirection): void;
|
|
64
|
+
export declare function enableMangoExecutionStats(query: MangoQuery): void;
|
package/lib/types/types.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AdapterFlags } from "@decaf-ts/core";
|
|
1
2
|
/**
|
|
2
3
|
* @description Response from a CouchDB Mango query
|
|
3
4
|
* @summary Contains the matching documents and additional metadata about the query execution
|
|
@@ -164,3 +165,10 @@ export interface ViewResponse<D = any> {
|
|
|
164
165
|
offset?: number;
|
|
165
166
|
rows: ViewRow<D>[];
|
|
166
167
|
}
|
|
168
|
+
export interface CouchDBFlags extends Partial<AdapterFlags> {
|
|
169
|
+
/**
|
|
170
|
+
* When true, non-default Mango queries try to attach a generated named index.
|
|
171
|
+
* Default-query index selection remains unchanged.
|
|
172
|
+
*/
|
|
173
|
+
forceNamedIndexes?: boolean;
|
|
174
|
+
}
|
package/lib/types/types.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AdapterFlags } from "@decaf-ts/core";
|
|
1
2
|
/**
|
|
2
3
|
* @description Response from a CouchDB Mango query
|
|
3
4
|
* @summary Contains the matching documents and additional metadata about the query execution
|
|
@@ -164,3 +165,10 @@ export interface ViewResponse<D = any> {
|
|
|
164
165
|
offset?: number;
|
|
165
166
|
rows: ViewRow<D>[];
|
|
166
167
|
}
|
|
168
|
+
export interface CouchDBFlags extends Partial<AdapterFlags> {
|
|
169
|
+
/**
|
|
170
|
+
* When true, non-default Mango queries try to attach a generated named index.
|
|
171
|
+
* Default-query index selection remains unchanged.
|
|
172
|
+
*/
|
|
173
|
+
forceNamedIndexes?: boolean;
|
|
174
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decaf-ts/for-couchdb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "decaf-ts couchdb wrappers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"publish-docs": "docker run -it --rm --user $(id -u):$(id -g) -v \"$(pwd)/workdocs/confluence:/content\" -e ATLASSIAN_API_TOKEN=$(cat .confluence-token) ghcr.io/markdown-confluence/publish:latest",
|
|
46
46
|
"docker:login": "echo $(cat .token) | docker login ghcr.io -u decaf --password-stdin",
|
|
47
47
|
"docker:build": "npm run docker:build-booter && npm run docker:build-couchdb",
|
|
48
|
+
"docker:pull": "npm run docker:login && docker pull ghcr.io/decaf-ts/couchdb:latest && docker pull ghcr.io/decaf-ts/couchdb-booter:latest",
|
|
48
49
|
"docker:build-booter": "docker build -t ghcr.io/decaf-ts/couchdb-booter:$(cat package.json | jq -r '.version') -t ghcr.io/decaf-ts/couchdb-booter:latest -f ./docker/Dockerfile-booter ./docker",
|
|
49
50
|
"docker:build-couchdb": "docker build -t ghcr.io/decaf-ts/couchdb:$(cat package.json | jq -r '.version') -t ghcr.io/decaf-ts/couchdb:latest -f ./docker/Dockerfile-couchdb ./docker",
|
|
50
51
|
"docker:publish": "npm run docker:publish-booter && npm run docker:publish-couchdb",
|
package/lib/cjs/errors.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["errors.js"],"names":[],"mappings":";;;AAAA,2DAAoD;AACpD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,UAAW,SAAQ,yBAAS;IACrC,YAAY,GAAG;QACX,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;CACJ;AAJD,gCAIC;AACD,kCAAkC"}
|
package/lib/esm/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,UAAW,SAAQ,SAAS;IACvC,YAAY,GAAmB;QAC7B,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
File without changes
|
|
File without changes
|