@depup/pg-mem 3.0.14-depup.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.
Files changed (150) hide show
  1. package/README.md +35 -0
  2. package/changes.json +26 -0
  3. package/index.d.ts +1 -0
  4. package/index.js +16547 -0
  5. package/index.js.map +1 -0
  6. package/package.json +196 -0
  7. package/readme.md +297 -0
  8. package/types/adapters/adapters.d.ts +37 -0
  9. package/types/adapters/index.d.ts +2 -0
  10. package/types/adapters/pg-socket-adapter.d.ts +30 -0
  11. package/types/column.d.ts +27 -0
  12. package/types/constraints/foreign-key.d.ts +14 -0
  13. package/types/constraints/generated-from-expr.d.ts +14 -0
  14. package/types/constraints/generated-identity.d.ts +13 -0
  15. package/types/constraints/index-cst.d.ts +9 -0
  16. package/types/constraints/subscription.d.ts +7 -0
  17. package/types/constraints/wrapped.d.ts +9 -0
  18. package/types/datatypes/datatype-base.d.ts +66 -0
  19. package/types/datatypes/datatypes-geometric.d.ts +59 -0
  20. package/types/datatypes/datatypes-geometric.spec.d.ts +2 -0
  21. package/types/datatypes/datatypes.d.ts +101 -0
  22. package/types/datatypes/index.d.ts +2 -0
  23. package/types/datatypes/t-custom-enum.d.ts +21 -0
  24. package/types/datatypes/t-equivalent.d.ts +18 -0
  25. package/types/datatypes/t-inet.d.ts +13 -0
  26. package/types/datatypes/t-interval.d.ts +13 -0
  27. package/types/datatypes/t-jsonb.d.ts +16 -0
  28. package/types/datatypes/t-record.d.ts +17 -0
  29. package/types/datatypes/t-regclass.d.ts +11 -0
  30. package/types/datatypes/t-regtype.d.ts +11 -0
  31. package/types/datatypes/t-time.d.ts +14 -0
  32. package/types/datatypes/t-timestamp.d.ts +18 -0
  33. package/types/db.d.ts +3 -0
  34. package/types/evaluator.d.ts +61 -0
  35. package/types/execution/clean-results.d.ts +5 -0
  36. package/types/execution/exec-utils.d.ts +19 -0
  37. package/types/execution/records-mutations/deletion.d.ts +8 -0
  38. package/types/execution/records-mutations/insert.d.ts +13 -0
  39. package/types/execution/records-mutations/mutation-base.d.ts +31 -0
  40. package/types/execution/records-mutations/truncate-table.d.ts +10 -0
  41. package/types/execution/records-mutations/update.d.ts +10 -0
  42. package/types/execution/schema-amends/alter-enum.d.ts +20 -0
  43. package/types/execution/schema-amends/alter-sequence.d.ts +19 -0
  44. package/types/execution/schema-amends/alter.d.ts +19 -0
  45. package/types/execution/schema-amends/comment.d.ts +19 -0
  46. package/types/execution/schema-amends/create-enum.d.ts +20 -0
  47. package/types/execution/schema-amends/create-function.d.ts +20 -0
  48. package/types/execution/schema-amends/create-index.d.ts +19 -0
  49. package/types/execution/schema-amends/create-materialized-view.d.ts +19 -0
  50. package/types/execution/schema-amends/create-schema.d.ts +19 -0
  51. package/types/execution/schema-amends/create-sequence.d.ts +21 -0
  52. package/types/execution/schema-amends/create-table.d.ts +21 -0
  53. package/types/execution/schema-amends/create-view.d.ts +22 -0
  54. package/types/execution/schema-amends/do.d.ts +9 -0
  55. package/types/execution/schema-amends/drop-index.d.ts +18 -0
  56. package/types/execution/schema-amends/drop-sequence.d.ts +18 -0
  57. package/types/execution/schema-amends/drop-table.d.ts +19 -0
  58. package/types/execution/schema-amends/drop-type.d.ts +18 -0
  59. package/types/execution/select.d.ts +15 -0
  60. package/types/execution/set.d.ts +9 -0
  61. package/types/execution/show.d.ts +8 -0
  62. package/types/execution/statement-exec.d.ts +26 -0
  63. package/types/execution/transaction-statements.d.ts +16 -0
  64. package/types/functions/date.d.ts +3 -0
  65. package/types/functions/index.d.ts +2 -0
  66. package/types/functions/numbers.d.ts +3 -0
  67. package/types/functions/sequence-fns.d.ts +3 -0
  68. package/types/functions/string.d.ts +3 -0
  69. package/types/functions/subquery.d.ts +3 -0
  70. package/types/functions/system.d.ts +3 -0
  71. package/types/index.d.ts +5 -0
  72. package/types/interfaces-private.d.ts +605 -0
  73. package/types/interfaces.d.ts +449 -0
  74. package/types/migrate/migrate-interfaces.d.ts +32 -0
  75. package/types/migrate/migrate.d.ts +8 -0
  76. package/types/misc/buffer-deno.d.ts +7 -0
  77. package/types/misc/buffer-node.d.ts +7 -0
  78. package/types/misc/pg-escape.d.ts +2 -0
  79. package/types/misc/pg-utils.d.ts +3 -0
  80. package/types/parser/context.d.ts +26 -0
  81. package/types/parser/expression-builder.d.ts +8 -0
  82. package/types/parser/function-call.d.ts +4 -0
  83. package/types/parser/parse-cache.d.ts +6 -0
  84. package/types/schema/btree-index.d.ts +48 -0
  85. package/types/schema/consts.d.ts +10 -0
  86. package/types/schema/custom-index.d.ts +31 -0
  87. package/types/schema/function-call-table.d.ts +20 -0
  88. package/types/schema/information-schema/columns-list.d.ts +13 -0
  89. package/types/schema/information-schema/constraint-column-usage.d.ts +10 -0
  90. package/types/schema/information-schema/index.d.ts +3 -0
  91. package/types/schema/information-schema/key-column-usage.d.ts +10 -0
  92. package/types/schema/information-schema/table-constraints.d.ts +10 -0
  93. package/types/schema/information-schema/table-list.d.ts +14 -0
  94. package/types/schema/overload-resolver.d.ts +17 -0
  95. package/types/schema/pg-catalog/binary-operators.d.ts +3 -0
  96. package/types/schema/pg-catalog/index.d.ts +3 -0
  97. package/types/schema/pg-catalog/pg-attribute-list.d.ts +11 -0
  98. package/types/schema/pg-catalog/pg-class.d.ts +13 -0
  99. package/types/schema/pg-catalog/pg-constraints-list.d.ts +13 -0
  100. package/types/schema/pg-catalog/pg-database.d.ts +17 -0
  101. package/types/schema/pg-catalog/pg-enum-list.d.ts +10 -0
  102. package/types/schema/pg-catalog/pg-index-list.d.ts +10 -0
  103. package/types/schema/pg-catalog/pg-namespace-list.d.ts +10 -0
  104. package/types/schema/pg-catalog/pg-proc.d.ts +10 -0
  105. package/types/schema/pg-catalog/pg-range.d.ts +10 -0
  106. package/types/schema/pg-catalog/pg-sequences-list.d.ts +10 -0
  107. package/types/schema/pg-catalog/pg-type-list.d.ts +10 -0
  108. package/types/schema/pg-catalog/pg-user-list.d.ts +10 -0
  109. package/types/schema/pg-catalog/pg_statio_user_tables.d.ts +25 -0
  110. package/types/schema/pg-catalog/sql-function-language.d.ts +3 -0
  111. package/types/schema/prepared-intercepted.d.ts +11 -0
  112. package/types/schema/prepared.d.ts +5 -0
  113. package/types/schema/readonly-table.d.ts +62 -0
  114. package/types/schema/schema.d.ts +73 -0
  115. package/types/schema/sequence.d.ts +27 -0
  116. package/types/schema/table-index.d.ts +32 -0
  117. package/types/schema/values-table.d.ts +16 -0
  118. package/types/schema/view.d.ts +18 -0
  119. package/types/table.d.ts +97 -0
  120. package/types/transaction.d.ts +26 -0
  121. package/types/transforms/aggregation.d.ts +41 -0
  122. package/types/transforms/aggregations/array_agg.d.ts +11 -0
  123. package/types/transforms/aggregations/avg.d.ts +11 -0
  124. package/types/transforms/aggregations/bool-aggregs.d.ts +12 -0
  125. package/types/transforms/aggregations/count.d.ts +19 -0
  126. package/types/transforms/aggregations/json_aggs.d.ts +11 -0
  127. package/types/transforms/aggregations/max-min.d.ts +12 -0
  128. package/types/transforms/aggregations/sum.d.ts +11 -0
  129. package/types/transforms/alias.d.ts +29 -0
  130. package/types/transforms/and-filter.d.ts +15 -0
  131. package/types/transforms/array-filter.d.ts +14 -0
  132. package/types/transforms/between-filter.d.ts +16 -0
  133. package/types/transforms/build-filter.d.ts +4 -0
  134. package/types/transforms/distinct.d.ts +16 -0
  135. package/types/transforms/eq-filter.d.ts +17 -0
  136. package/types/transforms/false-filter.d.ts +11 -0
  137. package/types/transforms/in-filter.d.ts +14 -0
  138. package/types/transforms/ineq-filter.d.ts +16 -0
  139. package/types/transforms/join.d.ts +74 -0
  140. package/types/transforms/limit.d.ts +18 -0
  141. package/types/transforms/not-in-filter.d.ts +15 -0
  142. package/types/transforms/or-filter.d.ts +13 -0
  143. package/types/transforms/order-by.d.ts +26 -0
  144. package/types/transforms/restrictive-index.d.ts +15 -0
  145. package/types/transforms/selection.d.ts +45 -0
  146. package/types/transforms/seq-scan.d.ts +14 -0
  147. package/types/transforms/startswith-filter.d.ts +14 -0
  148. package/types/transforms/transform-base.d.ts +100 -0
  149. package/types/transforms/union.d.ts +32 -0
  150. package/types/utils.d.ts +86 -0
@@ -0,0 +1,66 @@
1
+ import { Evaluator } from '../evaluator';
2
+ import { DataType, IValue, nil, Reg, _IType, _RelationBase, _Transaction } from '../interfaces-private';
3
+ export declare function regGen(typeId: number | null): Reg;
4
+ export declare abstract class TypeBase<TRaw = any> implements _IType<TRaw>, _RelationBase {
5
+ readonly reg: Reg;
6
+ get type(): 'type';
7
+ /**
8
+ * select a.oid, a.typname, b.typcategory from pg_catalog.pg_type a
9
+ left join pg_catalog.pg_type b on b.oid = a.typelem
10
+ */
11
+ constructor(typeId: number | null);
12
+ private _asArray?;
13
+ private _asList?;
14
+ abstract primary: DataType;
15
+ get name(): string;
16
+ get primaryName(): string;
17
+ /** Compute a custom unicty hash for a non null value */
18
+ doGetHash?(value: TRaw): string | number;
19
+ /** Can be casted to */
20
+ doCanCast?(to: _IType<TRaw>): boolean | nil;
21
+ /** Can be built to from (inverse of doCanCast()) */
22
+ doCanBuildFrom?(from: _IType): boolean | nil;
23
+ /**
24
+ * @see this.prefer() doc
25
+ */
26
+ doPrefer?(type: _IType<TRaw>): _IType | null;
27
+ /**
28
+ * @see this.canConvertImplicit() doc
29
+ */
30
+ doCanConvertImplicit?(to: _IType<TRaw>): boolean;
31
+ /** Perform conversion from this type to given type */
32
+ doCast?(value: Evaluator<TRaw>, to: _IType<TRaw>): Evaluator<any> | nil;
33
+ /** Perform conversion given type to this type (inverse of doCast()) */
34
+ doBuildFrom?(value: Evaluator, from: _IType): Evaluator<TRaw> | nil;
35
+ doEquals(a: TRaw, b: TRaw): boolean;
36
+ doGt(a: TRaw, b: TRaw): boolean;
37
+ doLt(a: TRaw, b: TRaw): boolean;
38
+ toString(): string;
39
+ equals(a: TRaw, b: TRaw): boolean | null;
40
+ gt(a: TRaw, b: TRaw): boolean | null;
41
+ lt(a: TRaw, b: TRaw): boolean | null;
42
+ ge(a: TRaw, b: TRaw): boolean | null;
43
+ le(a: TRaw, b: TRaw): boolean | null;
44
+ /**
45
+ * When performing 'a+b', will be given 'b' type,
46
+ * this returns the prefered resulting type, or null if they are not compatible
47
+ */
48
+ prefer(to: _IType<TRaw>): _IType | nil;
49
+ /**
50
+ * Can constant literals be converted implicitely
51
+ * (without a cast... i.e. you can use both values as different values of a case expression, for instance)
52
+ **/
53
+ canConvertImplicit(to: _IType<TRaw>): boolean | nil;
54
+ /** Can be explicitely casted to */
55
+ canCast(to: _IType<TRaw>): boolean | nil;
56
+ /** Perform cast */
57
+ cast(_a: IValue<TRaw>, _to: _IType<any>): IValue;
58
+ /** Perform implicit conversion */
59
+ convertImplicit(_a: IValue<TRaw>, _to: _IType<any>): IValue;
60
+ private _convert;
61
+ asArray(): _IType<TRaw[]>;
62
+ asList(): _IType<TRaw[]>;
63
+ hash(value: any): string | number | null;
64
+ drop(t: _Transaction): void;
65
+ }
66
+ //# sourceMappingURL=datatype-base.d.ts.map
@@ -0,0 +1,59 @@
1
+ import { DataType } from '../interfaces';
2
+ import { _IType } from '../interfaces-private';
3
+ import { Box, Circle, Line, Path, Point, Polygon, Segment } from 'pgsql-ast-parser';
4
+ import { Evaluator } from '../evaluator';
5
+ import { TypeBase } from './datatype-base';
6
+ export declare function pointToStr(p: Point): string;
7
+ export declare function pointEq(a: Point, b: Point): boolean;
8
+ export declare class PointType extends TypeBase<Point> {
9
+ get primary(): DataType;
10
+ get name(): string;
11
+ doCanCast(t: _IType): boolean;
12
+ doCast(value: Evaluator<Point>, to: _IType): Evaluator<Point>;
13
+ doEquals(a: Point, b: Point): boolean;
14
+ doGt(a: Point, b: Point): boolean;
15
+ doLt(a: Point, b: Point): boolean;
16
+ }
17
+ export declare class LineType extends TypeBase<Line> {
18
+ get primary(): DataType;
19
+ get name(): string;
20
+ doCanCast(t: _IType): boolean;
21
+ doCast(value: Evaluator<Line>, to: _IType): Evaluator<Line>;
22
+ doEquals(a: Line, b: Line): boolean;
23
+ }
24
+ export declare class LsegType extends TypeBase<Segment> {
25
+ get primary(): DataType;
26
+ get name(): string;
27
+ doCanCast(t: _IType): boolean;
28
+ doCast(value: Evaluator<Segment>, to: _IType): Evaluator<Segment>;
29
+ doEquals([as, ae]: Segment, [bs, be]: Segment): boolean;
30
+ }
31
+ export declare class BoxType extends TypeBase<Box> {
32
+ get primary(): DataType;
33
+ get name(): string;
34
+ doCanCast(t: _IType): boolean;
35
+ doCast(value: Evaluator<Box>, to: _IType): Evaluator<Box>;
36
+ doEquals([as, ae]: Box, [bs, be]: Box): boolean;
37
+ }
38
+ export declare class PathType extends TypeBase<Path> {
39
+ get primary(): DataType;
40
+ get name(): string;
41
+ doCanCast(t: _IType): boolean;
42
+ doCast(value: Evaluator<Path>, to: _IType): Evaluator<Path>;
43
+ doEquals(a: Path, b: Path): boolean;
44
+ }
45
+ export declare class PolygonType extends TypeBase<Polygon> {
46
+ get primary(): DataType;
47
+ get name(): string;
48
+ doCanCast(t: _IType): boolean;
49
+ doCast(value: Evaluator<Polygon>, to: _IType): Evaluator<Polygon>;
50
+ doEquals(a: Polygon, b: Polygon): boolean;
51
+ }
52
+ export declare class CircleType extends TypeBase<Circle> {
53
+ get primary(): DataType;
54
+ get name(): string;
55
+ doCanCast(t: _IType): boolean;
56
+ doCast(value: Evaluator<Circle>, to: _IType): Evaluator<Circle>;
57
+ doEquals(a: Circle, b: Circle): boolean;
58
+ }
59
+ //# sourceMappingURL=datatypes-geometric.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=datatypes-geometric.spec.d.ts.map
@@ -0,0 +1,101 @@
1
+ import { IValue, _IType } from '../interfaces-private';
2
+ import { DataType, IType, nil } from '../interfaces';
3
+ import { Evaluator } from '../evaluator';
4
+ import { TypeBase } from './datatype-base';
5
+ declare class NullType extends TypeBase<null> {
6
+ get primary(): DataType;
7
+ doCast(value: Evaluator<any>, to: _IType): Evaluator<any>;
8
+ doCanCast(to: _IType): boolean;
9
+ doCanConvertImplicit(): boolean;
10
+ doEquals(a: any, b: any): boolean;
11
+ doGt(a: any, b: any): boolean;
12
+ doLt(a: any, b: any): boolean;
13
+ doPrefer(type: _IType): _IType<any>;
14
+ }
15
+ export declare class DefaultType extends NullType {
16
+ }
17
+ export declare const integers: ReadonlySet<DataType>;
18
+ export declare const floats: ReadonlySet<DataType>;
19
+ export declare const numbers: ReadonlySet<DataType>;
20
+ export declare const numberPriorities: Record<DataType, number>;
21
+ export declare function isNumeric(t: DataType | IType): boolean;
22
+ export declare function isInteger(t: DataType | IType): boolean;
23
+ declare class TextType extends TypeBase<string> {
24
+ readonly len: number | null;
25
+ private citext?;
26
+ get name(): string;
27
+ get primary(): DataType;
28
+ constructor(len: number | null, citext?: boolean | undefined);
29
+ doPrefer(to: _IType, stricterType?: boolean): _IType<any> | TextType | null;
30
+ doCanConvertImplicit(to: _IType): boolean;
31
+ doCanCast(to: _IType): boolean | nil;
32
+ doCast(value: Evaluator<string>, to: _IType): Evaluator<string> | undefined;
33
+ doEquals(a: string, b: string): boolean;
34
+ }
35
+ export declare class ArrayType extends TypeBase<any[]> {
36
+ readonly of: _IType;
37
+ private list;
38
+ static matches(type: IType): type is ArrayType;
39
+ get primary(): DataType;
40
+ get name(): string;
41
+ constructor(of: _IType, list: boolean);
42
+ doCanCast(to: _IType): boolean | nil;
43
+ doCast(value: Evaluator, _to: _IType): Evaluator<any>;
44
+ toText(to: _IType, value: Evaluator): Evaluator<any>;
45
+ toSingleColumn(to: _IType, value: Evaluator): Evaluator<any>;
46
+ doEquals(a: any[], b: any[]): boolean;
47
+ doGt(a: any[], b: any[]): boolean;
48
+ doLt(a: any[], b: any[]): boolean;
49
+ convertLiteral(elts: any): any[] | undefined;
50
+ }
51
+ export interface RecordCol {
52
+ readonly name: string;
53
+ readonly type: _IType;
54
+ }
55
+ /** Basic types */
56
+ export declare const Types: {
57
+ record: (columns: RecordCol[]) => _IType;
58
+ bool: _IType;
59
+ text: (len?: number | nil) => _IType;
60
+ citext: TextType;
61
+ timestamp: (len?: number | nil) => _IType;
62
+ timestamptz: (len?: number | nil) => _IType;
63
+ uuid: _IType;
64
+ date: _IType;
65
+ interval: _IType;
66
+ time: _IType;
67
+ timetz: _IType;
68
+ jsonb: _IType;
69
+ regtype: _IType;
70
+ regclass: _IType;
71
+ json: _IType;
72
+ null: _IType;
73
+ float: _IType;
74
+ integer: _IType;
75
+ bigint: _IType;
76
+ bytea: _IType;
77
+ point: _IType;
78
+ line: _IType;
79
+ lseg: _IType;
80
+ box: _IType;
81
+ inet: _IType;
82
+ path: _IType;
83
+ polygon: _IType;
84
+ circle: _IType;
85
+ default: _IType;
86
+ };
87
+ export declare const dateTypes: ReadonlySet<DataType>;
88
+ export declare function isDateType(_type: _IType | DataType): boolean;
89
+ export declare function isGeometric(dt: DataType): boolean;
90
+ export declare const typeSynonyms: {
91
+ [key: string]: DataType | {
92
+ type: DataType;
93
+ ignoreConfig: boolean;
94
+ };
95
+ };
96
+ /** Finds a common type by implicit conversion */
97
+ export declare function reconciliateTypes(values: IValue[], nullIfNoMatch?: false, stricterType?: boolean): _IType;
98
+ export declare function reconciliateTypes(values: IValue[], nullIfNoMatch: true, stricterType?: boolean): _IType | nil;
99
+ export declare function reconciliateTypes(values: IValue[], nullIfNoMatch?: boolean, stricterType?: boolean): _IType | nil;
100
+ export {};
101
+ //# sourceMappingURL=datatypes.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './datatypes';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { Evaluator } from '../evaluator';
2
+ import { TypeBase } from './datatype-base';
3
+ import { DataType, nil } from '../interfaces';
4
+ import { _IRelation, _ISchema, _IType, _Transaction } from '../interfaces-private';
5
+ export declare function asEnum(o: _IRelation | null): CustomEnumType;
6
+ export declare class CustomEnumType extends TypeBase<string> {
7
+ readonly schema: _ISchema;
8
+ private readonly _name;
9
+ readonly values: string[];
10
+ get primary(): DataType;
11
+ get name(): string;
12
+ constructor(schema: _ISchema, _name: string, values: string[]);
13
+ install(): void;
14
+ doCanCast(to: _IType): boolean;
15
+ doCast(value: Evaluator<string>, to: _IType<string>): Evaluator<any> | nil;
16
+ prefer(type: _IType<any>): _IType | nil;
17
+ doCanBuildFrom(from: _IType): boolean | nil;
18
+ doBuildFrom(value: Evaluator<string>, from: _IType<string>): Evaluator<string> | nil;
19
+ drop(t: _Transaction): void;
20
+ }
21
+ //# sourceMappingURL=t-custom-enum.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { Evaluator } from '../evaluator';
2
+ import { TypeBase } from './datatype-base';
3
+ import { DataType, IEquivalentType, nil } from '../interfaces';
4
+ import { _IType } from '../interfaces-private';
5
+ export declare class EquivalentType extends TypeBase<string> {
6
+ private def;
7
+ private equiv;
8
+ constructor(def: IEquivalentType);
9
+ get primary(): DataType;
10
+ get primaryName(): string;
11
+ get name(): string;
12
+ doCanCast(to: _IType): boolean;
13
+ doCast(value: Evaluator<string>, to: _IType<string>): Evaluator<any> | nil;
14
+ prefer(type: _IType<any>): _IType | nil;
15
+ doCanBuildFrom(from: _IType): boolean | nil;
16
+ doBuildFrom(value: Evaluator<string>, from: _IType<string>): Evaluator<string> | nil;
17
+ }
18
+ //# sourceMappingURL=t-equivalent.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { Evaluator } from '../evaluator';
2
+ import { TypeBase } from './datatype-base';
3
+ import { DataType, nil } from '../interfaces';
4
+ import { _IType } from '../interfaces-private';
5
+ export declare class INetType extends TypeBase<string> {
6
+ get primary(): DataType;
7
+ doCanCast(to: _IType): boolean;
8
+ doCast(value: Evaluator<string>, to: _IType<string>): Evaluator<any> | nil;
9
+ prefer(type: _IType<any>): _IType | nil;
10
+ doCanBuildFrom(from: _IType): boolean | nil;
11
+ doBuildFrom(value: Evaluator<string>, from: _IType<string>): Evaluator<string> | nil;
12
+ }
13
+ //# sourceMappingURL=t-inet.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { DataType, nil, _IType } from '../interfaces-private';
2
+ import { Interval } from 'pgsql-ast-parser';
3
+ import { TypeBase } from './datatype-base';
4
+ import { Evaluator } from '../evaluator';
5
+ export declare class IntervalType extends TypeBase<Interval> {
6
+ get primary(): DataType;
7
+ doCanBuildFrom(from: _IType): boolean;
8
+ doBuildFrom(value: Evaluator, from: _IType): Evaluator<Interval> | nil;
9
+ doEquals(a: Interval, b: Interval): boolean;
10
+ doGt(a: Interval, b: Interval): boolean;
11
+ doLt(a: Interval, b: Interval): boolean;
12
+ }
13
+ //# sourceMappingURL=t-interval.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { DataType, nil, _IType } from '../interfaces-private';
2
+ import { TypeBase } from './datatype-base';
3
+ import { Evaluator } from '../evaluator';
4
+ export declare class JSONBType extends TypeBase<any> {
5
+ readonly primary: DataType;
6
+ constructor(primary: DataType, dataType: number);
7
+ doCanCast(_to: _IType): boolean | nil;
8
+ doCast(a: Evaluator, to: _IType): Evaluator;
9
+ doCanBuildFrom(from: _IType): boolean;
10
+ doBuildFrom(value: Evaluator, from: _IType): Evaluator<Date> | nil;
11
+ doEquals(a: any, b: any): boolean;
12
+ doGt(a: any, b: any): boolean;
13
+ doLt(a: any, b: any): boolean;
14
+ toResult(result: any): any;
15
+ }
16
+ //# sourceMappingURL=t-jsonb.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { DataType, nil, _IType, _ISelection, _Transaction } from '../interfaces-private';
2
+ import { TypeBase } from './datatype-base';
3
+ import { RecordCol } from './datatypes';
4
+ import { Evaluator } from '../evaluator';
5
+ export declare class RecordType extends TypeBase<any> {
6
+ readonly columns: readonly RecordCol[];
7
+ static matches(type: _IType): type is RecordType;
8
+ constructor(columns: readonly RecordCol[]);
9
+ get primary(): DataType;
10
+ doEquals(a: any, b: any): boolean;
11
+ static from(selection: _ISelection): RecordType;
12
+ /** Build a function that will transform a record of this type to a record of the target type */
13
+ transformItemFrom(source: _ISelection): ((raw: any, t: _Transaction, execId: string) => any) | null;
14
+ doCanCast(to: _IType): boolean | nil;
15
+ doCast(value: Evaluator<any>, to: _IType): Evaluator<any> | nil;
16
+ }
17
+ //# sourceMappingURL=t-record.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { DataType, nil, RegClass, _IType } from '../interfaces-private';
2
+ import { TypeBase } from './datatype-base';
3
+ import { Evaluator } from '../evaluator';
4
+ export declare class RegClassImpl extends TypeBase<RegClass> {
5
+ get primary(): DataType;
6
+ doCanCast(_to: _IType): boolean | nil;
7
+ doCast(a: Evaluator, to: _IType): Evaluator;
8
+ doCanBuildFrom(from: _IType): boolean;
9
+ doBuildFrom(value: Evaluator, from: _IType): Evaluator<RegClass> | nil;
10
+ }
11
+ //# sourceMappingURL=t-regclass.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { DataType, nil, RegClass, RegType, _IType } from '../interfaces-private';
2
+ import { TypeBase } from './datatype-base';
3
+ import { Evaluator } from '../evaluator';
4
+ export declare class RegTypeImpl extends TypeBase<RegType> {
5
+ get primary(): DataType;
6
+ doCanCast(_to: _IType): boolean | nil;
7
+ doCast(a: Evaluator<RegType>, to: _IType): Evaluator;
8
+ doCanBuildFrom(from: _IType): boolean;
9
+ doBuildFrom(value: Evaluator, from: _IType): Evaluator<RegClass> | nil;
10
+ }
11
+ //# sourceMappingURL=t-regtype.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { DataType, nil, _IType } from '../interfaces-private';
2
+ import { TypeBase } from './datatype-base';
3
+ import { Evaluator } from '../evaluator';
4
+ export declare class TimeType extends TypeBase<string> {
5
+ readonly primary: DataType.time | DataType.timetz;
6
+ constructor(primary: DataType.time | DataType.timetz);
7
+ get name(): string;
8
+ doCanCast(to: _IType): true | null;
9
+ doCanConvertImplicit(to: _IType): boolean;
10
+ doCast(value: Evaluator, to: _IType): Evaluator<any>;
11
+ doCanBuildFrom(from: _IType): boolean;
12
+ doBuildFrom(value: Evaluator, from: _IType): Evaluator<string> | nil;
13
+ }
14
+ //# sourceMappingURL=t-time.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { DataType, nil, _IType } from '../interfaces-private';
2
+ import { TypeBase } from './datatype-base';
3
+ import { Evaluator } from '../evaluator';
4
+ export declare class TimestampType extends TypeBase<Date> {
5
+ readonly primary: DataType;
6
+ readonly precision: number | null;
7
+ constructor(primary: DataType, typeId: number | null, precision?: number | null);
8
+ get name(): string;
9
+ doCanCast(to: _IType): boolean | null;
10
+ doCanConvertImplicit(to: _IType): boolean;
11
+ doCast(value: Evaluator, to: _IType): Evaluator<any>;
12
+ doCanBuildFrom(from: _IType): boolean;
13
+ doBuildFrom(value: Evaluator, from: _IType): Evaluator<Date> | nil;
14
+ doEquals(a: any, b: any): boolean;
15
+ doGt(a: any, b: any): boolean;
16
+ doLt(a: any, b: any): boolean;
17
+ }
18
+ //# sourceMappingURL=t-timestamp.d.ts.map
package/types/db.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { IMemoryDb, MemoryDbOptions } from './interfaces';
2
+ export declare function newDb(opts?: MemoryDbOptions): IMemoryDb;
3
+ //# sourceMappingURL=db.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { IValue, _IIndex, _ISelection, _IType, _Transaction, _Explainer, _ExprExplanation, Parameter } from './interfaces-private';
2
+ import { nil, ArgDefDetails } from './interfaces';
3
+ import { QName } from 'pgsql-ast-parser';
4
+ export interface EvaluatorOptions {
5
+ isAny?: boolean;
6
+ isColumnOf?: _ISelection;
7
+ /** its type will act as if it is a constant literal (for parameters type resolution) */
8
+ actAsConstantLiteral?: boolean;
9
+ forceNotConstant?: boolean;
10
+ onCast?: (to: _IType) => void;
11
+ unpure?: boolean;
12
+ }
13
+ export declare class Evaluator<T = any> implements IValue<T> {
14
+ readonly type: _IType<T>;
15
+ readonly id: string | nil;
16
+ readonly hash: string;
17
+ val: nil | Object | number | string | Date | ((raw: any, transaction: _Transaction | nil) => any);
18
+ private opts?;
19
+ readonly isConstantLiteral: boolean;
20
+ readonly usedColumns: Set<IValue<any>>;
21
+ readonly forceNotConstant?: boolean;
22
+ get index(): _IIndex | nil;
23
+ get isConstant(): boolean;
24
+ get isConstantReal(): boolean;
25
+ origin: _ISelection | nil;
26
+ get isAny(): boolean;
27
+ constructor(type: _IType<T>, id: string | nil, hash: string, dependencies: IValue | IValue[] | nil, val: nil | Object | number | string | Date | ((raw: any, transaction: _Transaction | nil) => any), opts?: EvaluatorOptions | undefined);
28
+ setType(type: _IType): Evaluator<T>;
29
+ setConversion(converter: (val: T, t: _Transaction | nil) => any, hashConv: (hash: string) => any): Evaluator<T>;
30
+ setOrigin(origin: _ISelection): IValue;
31
+ clone(): Evaluator<T>;
32
+ map<TNew>(mapper: (val: T) => TNew, newType?: _IType<TNew>): IValue<TNew>;
33
+ setWrapper<TNew>(newOrigin: _ISelection, unwrap: (val: T) => TNew, newType?: _IType<TNew>): IValue<TNew>;
34
+ setId(newId: string): IValue;
35
+ get(): T;
36
+ get(raw: any, t: _Transaction | nil): T;
37
+ canCast(to: _IType<T>): boolean;
38
+ cast<T = any>(to: _IType<T>): IValue;
39
+ convertImplicit<T = any>(to: _IType<T>): IValue;
40
+ explain(e: _Explainer): _ExprExplanation;
41
+ }
42
+ export declare const Value: {
43
+ readonly null: (ofType?: _IType) => IValue;
44
+ readonly text: (value: string, length?: number | nil) => IValue;
45
+ readonly number: (value: number, type?: _IType<any>) => IValue;
46
+ readonly function: (value: string | QName, args: IValue[]) => IValue;
47
+ readonly bool: (value: boolean) => IValue;
48
+ /** @deprecated Use with care */
49
+ readonly constant: (_type: _IType, value: any) => IValue;
50
+ /** @deprecated Use with care */
51
+ readonly converter: (type: _IType, to: _IType) => (val: any, t: _Transaction | nil) => any;
52
+ readonly in: (value: IValue, array: IValue, inclusive: boolean) => IValue;
53
+ readonly isNull: (leftValue: IValue, expectNull: boolean) => IValue;
54
+ readonly isTrue: (leftValue: IValue, expectTrue: boolean) => IValue;
55
+ readonly isFalse: (leftValue: IValue, expectFalse: boolean) => IValue;
56
+ readonly negate: (value: IValue) => IValue;
57
+ readonly array: (values: IValue[]) => IValue;
58
+ readonly list: (values: IValue[]) => IValue;
59
+ };
60
+ export declare function buildParameterList(statementName: string | null, args: ArgDefDetails[]): Parameter[];
61
+ //# sourceMappingURL=evaluator.d.ts.map
@@ -0,0 +1,5 @@
1
+ export declare const JSON_NIL: unique symbol;
2
+ export declare const IS_PARTIAL_INDEXING: unique symbol;
3
+ export declare const SELECT_ALL: unique symbol;
4
+ export declare function cleanResults<T>(results: T): T;
5
+ //# sourceMappingURL=clean-results.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { QName, Statement, NodeLocation } from 'pgsql-ast-parser';
2
+ import { _ISchema, _Transaction } from '../interfaces-private';
3
+ export declare function checkExistence(schema: _ISchema, name: QName, ifNotExists: boolean | undefined, act: () => void): boolean;
4
+ export declare function locOf(p: Statement): NodeLocation;
5
+ export declare abstract class ExecHelper {
6
+ private statement;
7
+ constructor(statement: Statement);
8
+ protected noData(t: _Transaction, name?: string): {
9
+ result: {
10
+ command: string;
11
+ fields: never[];
12
+ rowCount: number;
13
+ rows: never[];
14
+ location: NodeLocation;
15
+ };
16
+ state: _Transaction;
17
+ };
18
+ }
19
+ //# sourceMappingURL=exec-utils.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { _Transaction } from '../../interfaces-private';
2
+ import { DeleteStatement } from 'pgsql-ast-parser';
3
+ import { MutationDataSourceBase } from './mutation-base';
4
+ export declare class Deletion extends MutationDataSourceBase {
5
+ constructor(ast: DeleteStatement);
6
+ protected performMutation(t: _Transaction): any[];
7
+ }
8
+ //# sourceMappingURL=deletion.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { _Transaction } from '../../interfaces-private';
2
+ import { InsertStatement } from 'pgsql-ast-parser';
3
+ import { MutationDataSourceBase } from './mutation-base';
4
+ export declare class Insert extends MutationDataSourceBase {
5
+ private valueRawSource;
6
+ private insertColumns;
7
+ private valueConvertedSource;
8
+ private opts;
9
+ constructor(ast: InsertStatement);
10
+ private visit;
11
+ protected performMutation(t: _Transaction): any[];
12
+ }
13
+ //# sourceMappingURL=insert.d.ts.map
@@ -0,0 +1,31 @@
1
+ import { DataSourceBase } from '../../transforms/transform-base';
2
+ import { _ISelection, _ITable, _Transaction, IValue, _IIndex, _Explainer, _IAggregation, Row } from '../../interfaces-private';
3
+ import { InsertStatement, UpdateStatement, DeleteStatement, SetStatement, ExprRef } from 'pgsql-ast-parser';
4
+ type MutationStatement = InsertStatement | UpdateStatement | DeleteStatement;
5
+ export declare abstract class MutationDataSourceBase extends DataSourceBase {
6
+ protected table: _ITable;
7
+ protected mutatedSel: _ISelection;
8
+ static readonly affectedRows: unique symbol;
9
+ /** Perform the mutation, and returns the affected elements */
10
+ protected abstract performMutation(t: _Transaction): Row[];
11
+ private returningRows?;
12
+ private returning?;
13
+ private mutationResult;
14
+ get isExecutionWithNoResult(): boolean;
15
+ isAggregation(): this is _IAggregation;
16
+ get columns(): readonly IValue<any>[];
17
+ constructor(table: _ITable, mutatedSel: _ISelection, p: MutationStatement);
18
+ private _doExecuteOnce;
19
+ enumerate(t: _Transaction): Iterable<any>;
20
+ entropy(t: _Transaction): number;
21
+ getColumn(column: string | ExprRef, nullIfNotFound?: boolean | undefined): IValue;
22
+ hasItem(value: any, t: _Transaction): boolean;
23
+ getIndex(forValue: IValue): _IIndex | null | undefined;
24
+ explain(e: _Explainer): never;
25
+ isOriginOf(a: IValue): boolean;
26
+ stats(t: _Transaction): null;
27
+ }
28
+ export type Setter = (t: _Transaction, target: any, source: any) => void;
29
+ export declare function createSetter(this: void, setTable: _ITable, setSelection: _ISelection, _sets: SetStatement[]): Setter;
30
+ export {};
31
+ //# sourceMappingURL=mutation-base.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { _Transaction, _IStatementExecutor, StatementResult } from '../../interfaces-private';
2
+ import { TruncateTableStatement } from 'pgsql-ast-parser';
3
+ import { ExecHelper } from '../exec-utils';
4
+ export declare class TruncateTable extends ExecHelper implements _IStatementExecutor {
5
+ private table;
6
+ private opts;
7
+ constructor(statement: TruncateTableStatement);
8
+ execute(t: _Transaction): StatementResult;
9
+ }
10
+ //# sourceMappingURL=truncate-table.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { _Transaction } from '../../interfaces-private';
2
+ import { UpdateStatement } from 'pgsql-ast-parser';
3
+ import { MutationDataSourceBase } from './mutation-base';
4
+ export declare class Update extends MutationDataSourceBase {
5
+ private setter;
6
+ private fetchObjectToUpdate?;
7
+ constructor(ast: UpdateStatement);
8
+ protected performMutation(t: _Transaction): any[];
9
+ }
10
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { _Transaction, _IStatementExecutor, _IStatement } from '../../interfaces-private';
2
+ import { AlterEnumType } from 'pgsql-ast-parser';
3
+ import { ExecHelper } from '../exec-utils';
4
+ export declare class AlterEnum extends ExecHelper implements _IStatementExecutor {
5
+ private p;
6
+ private onSchema;
7
+ private originalEnum;
8
+ constructor({ schema }: _IStatement, p: AlterEnumType);
9
+ execute(t: _Transaction): {
10
+ result: {
11
+ command: string;
12
+ fields: never[];
13
+ rowCount: number;
14
+ rows: never[];
15
+ location: import("pgsql-ast-parser").NodeLocation;
16
+ };
17
+ state: _Transaction;
18
+ };
19
+ }
20
+ //# sourceMappingURL=alter-enum.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { _Transaction, _IStatementExecutor, _IStatement } from '../../interfaces-private';
2
+ import { AlterSequenceStatement } from 'pgsql-ast-parser';
3
+ import { ExecHelper } from '../exec-utils';
4
+ export declare class AlterSequence extends ExecHelper implements _IStatementExecutor {
5
+ private p;
6
+ private seq;
7
+ constructor({ schema }: _IStatement, p: AlterSequenceStatement);
8
+ execute(t: _Transaction): {
9
+ result: {
10
+ command: string;
11
+ fields: never[];
12
+ rowCount: number;
13
+ rows: never[];
14
+ location: import("pgsql-ast-parser").NodeLocation;
15
+ };
16
+ state: _Transaction;
17
+ };
18
+ }
19
+ //# sourceMappingURL=alter-sequence.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { _Transaction, _IStatementExecutor, _IStatement } from '../../interfaces-private';
2
+ import { AlterTableStatement } from 'pgsql-ast-parser';
3
+ import { ExecHelper } from '../exec-utils';
4
+ export declare class Alter extends ExecHelper implements _IStatementExecutor {
5
+ private p;
6
+ private table;
7
+ constructor({ schema }: _IStatement, p: AlterTableStatement);
8
+ execute(t: _Transaction): {
9
+ result: {
10
+ command: string;
11
+ fields: never[];
12
+ rowCount: number;
13
+ rows: never[];
14
+ location: import("pgsql-ast-parser").NodeLocation;
15
+ };
16
+ state: _Transaction;
17
+ };
18
+ }
19
+ //# sourceMappingURL=alter.d.ts.map