@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,100 @@
1
+ import type { _ISelection, IValue, _IIndex, _ISchema, _IDb, _Transaction, _SelectExplanation, _Explainer, Stats, nil, _IAlias, Row, _IAggregation } from '../interfaces-private';
2
+ import type { buildSelection } from './selection';
3
+ import type { buildAlias } from './alias';
4
+ import type { buildFilter } from './build-filter';
5
+ import type { buildGroupBy } from './aggregation';
6
+ import type { buildLimit } from './limit';
7
+ import type { buildUnion } from './union';
8
+ import type { buildOrderBy } from './order-by';
9
+ import type { buildDistinct } from './distinct';
10
+ import { Expr, SelectedColumn, LimitStatement, OrderByStatement, ExprRef } from 'pgsql-ast-parser';
11
+ interface Fns {
12
+ buildSelection: typeof buildSelection;
13
+ buildAlias: typeof buildAlias;
14
+ buildLimit: typeof buildLimit;
15
+ buildUnion: typeof buildUnion;
16
+ buildFilter: typeof buildFilter;
17
+ buildGroupBy: typeof buildGroupBy;
18
+ buildOrderBy: typeof buildOrderBy;
19
+ buildDistinct: typeof buildDistinct;
20
+ }
21
+ export declare function initialize(init: Fns): void;
22
+ export declare abstract class DataSourceBase implements _ISelection {
23
+ readonly ownerSchema: _ISchema;
24
+ abstract enumerate(t: _Transaction): Iterable<Row>;
25
+ abstract entropy(t: _Transaction): number;
26
+ abstract readonly columns: ReadonlyArray<IValue>;
27
+ abstract getColumn(column: string, nullIfNotFound?: boolean): IValue;
28
+ abstract hasItem(value: Row, t: _Transaction): boolean;
29
+ abstract getIndex(forValue: IValue): _IIndex | null | undefined;
30
+ abstract explain(e: _Explainer): _SelectExplanation;
31
+ abstract isOriginOf(a: IValue): boolean;
32
+ abstract stats(t: _Transaction): Stats | null;
33
+ abstract get isExecutionWithNoResult(): boolean;
34
+ isAggregation(): this is _IAggregation;
35
+ get db(): _IDb;
36
+ constructor(ownerSchema: _ISchema);
37
+ listColumns(): Iterable<IValue>;
38
+ listSelectableIdentities(): Iterable<IValue>;
39
+ select(select: (string | SelectedColumn)[] | nil): _ISelection;
40
+ selectAlias(alias: string): _IAlias | nil;
41
+ filter(filter: Expr | undefined | null): _ISelection;
42
+ groupBy(grouping: Expr[] | nil): _ISelection;
43
+ setAlias(alias?: string): _ISelection;
44
+ limit(limit: LimitStatement): _ISelection;
45
+ orderBy(orderBy: OrderByStatement[] | nil): _ISelection;
46
+ distinct(exprs?: Expr[]): _ISelection;
47
+ union(right: _ISelection): _ISelection;
48
+ }
49
+ export declare abstract class TransformBase extends DataSourceBase {
50
+ readonly base: _ISelection;
51
+ constructor(base: _ISelection);
52
+ get isExecutionWithNoResult(): boolean;
53
+ entropy(t: _Transaction): number;
54
+ isOriginOf(a: IValue): boolean;
55
+ }
56
+ export declare abstract class FilterBase extends TransformBase {
57
+ isAggregation(): this is _IAggregation;
58
+ constructor(_base: _ISelection);
59
+ get columns(): ReadonlyArray<IValue>;
60
+ selectAlias(alias: string): nil | _IAlias;
61
+ /**
62
+ private _columns: IValue[];
63
+ private _columnMappings: Map<IValue, IValue>;
64
+ get columns(): ReadonlyArray<IValue> {
65
+ this.initCols();
66
+ return this._columns;
67
+ // return this.base.columns;
68
+ }
69
+
70
+ private initCols() {
71
+ if (this._columns) {
72
+ return;
73
+ }
74
+ this._columns = [];
75
+ this._columnMappings = new Map();
76
+ for (const c of this.base.columns) {
77
+ const nc = c.setOrigin(this);
78
+ this._columns.push(nc);
79
+ this._columnMappings.set(c, nc);
80
+ }
81
+ }
82
+
83
+ getColumn(column: string, nullIfNotFound?: boolean): IValue {
84
+ if (!this.base) { // istanbul ignore next
85
+ throw new Error('Should not call .getColumn() on join');
86
+ }
87
+ if (!('columns' in this.base)) { // istanbul ignore next
88
+ throw new Error('Should not call getColumn() on table');
89
+ }
90
+ this.initCols();
91
+ const col = this.base.getColumn(column, nullIfNotFound);
92
+ return col && this._columnMappings.get(col);
93
+ }
94
+ */
95
+ getColumn(column: string | ExprRef): IValue;
96
+ getColumn(column: string | ExprRef, nullIfNotFound?: boolean): IValue | nil;
97
+ getIndex(...forValue: IValue[]): _IIndex | null | undefined;
98
+ }
99
+ export {};
100
+ //# sourceMappingURL=transform-base.d.ts.map
@@ -0,0 +1,32 @@
1
+ import { IValue, _ISelection, _Transaction, _Explainer, _SelectExplanation, Stats, _IIndex, _IType, _IAggregation, Row } from '../interfaces-private';
2
+ import { DataSourceBase } from './transform-base';
3
+ import { nil } from '../interfaces';
4
+ import { ExprRef } from 'pgsql-ast-parser';
5
+ export declare function buildUnion(left: _ISelection, right: _ISelection): Union;
6
+ interface UCol {
7
+ name: string;
8
+ type: _IType;
9
+ lval: IValue;
10
+ rval: IValue;
11
+ }
12
+ declare class Union extends DataSourceBase {
13
+ private cols;
14
+ private left;
15
+ private right;
16
+ get isExecutionWithNoResult(): boolean;
17
+ isAggregation(): this is _IAggregation;
18
+ readonly columns: ReadonlyArray<IValue>;
19
+ private readonly colsByName;
20
+ entropy(t: _Transaction): number;
21
+ hasItem(raw: Row, t: _Transaction): boolean;
22
+ constructor(cols: UCol[], left: _ISelection, right: _ISelection);
23
+ stats(t: _Transaction): Stats | null;
24
+ enumerate(t: _Transaction): Iterable<Row>;
25
+ explain(e: _Explainer): _SelectExplanation;
26
+ getColumn(column: string | ExprRef): IValue;
27
+ getColumn(column: string | ExprRef, nullIfNotFound?: boolean): IValue | nil;
28
+ getIndex(...forValue: IValue[]): _IIndex | null | undefined;
29
+ isOriginOf(a: IValue): boolean;
30
+ }
31
+ export {};
32
+ //# sourceMappingURL=union.d.ts.map
@@ -0,0 +1,86 @@
1
+ import moment from 'moment';
2
+ import { IValue, RegClass, _ISchema, _ISelection, _IType, _Transaction } from './interfaces-private';
3
+ import { DataTypeDef, Expr, ExprRef, Interval, nil, QName } from 'pgsql-ast-parser';
4
+ import { ISubscription, IType } from './interfaces';
5
+ export declare const doRequire: any;
6
+ export interface Ctor<T> extends Function {
7
+ new (...params: any[]): T;
8
+ prototype: T;
9
+ }
10
+ export type Optional<T> = {
11
+ [key in keyof T]?: T[key];
12
+ };
13
+ export type SRecord<T> = Record<string, T>;
14
+ export declare function trimNullish<T>(value: T, depth?: number): T;
15
+ export declare function watchUse<T>(rootValue: T): {
16
+ checked: T;
17
+ check?: () => string | null;
18
+ };
19
+ export declare function deepEqual<T>(a: T, b: T, strict?: boolean, depth?: number, numberDelta?: number): boolean;
20
+ export declare function deepCompare<T>(a: T, b: T, strict?: boolean, depth?: number, numberDelta?: number): number;
21
+ type Json = {
22
+ [key: string]: Json;
23
+ } | Json[] | string | number | null;
24
+ export declare function queryJson(a: Json, b: Json): boolean;
25
+ export declare function buildLikeMatcher(likeCondition: string, caseSensitive?: boolean): (stringToMatch: string | number) => boolean | null;
26
+ export declare function nullIsh(v: any): v is nil;
27
+ export declare function hasNullish(...vals: any[]): boolean;
28
+ export declare function sum(v: number[]): number;
29
+ export declare function deepCloneSimple<T>(v: T, noSymbols?: boolean): T;
30
+ export declare function isSelectAllArgList(select: Expr[]): boolean;
31
+ export declare function ignore(...val: any[]): void;
32
+ export declare function combineSubs(...vals: ISubscription[]): ISubscription;
33
+ export interface ExecCtx {
34
+ readonly schema: _ISchema;
35
+ readonly transaction: _Transaction;
36
+ readonly parametersValues?: any[];
37
+ }
38
+ export declare function executionCtx(): ExecCtx;
39
+ export declare function hasExecutionCtx(): boolean;
40
+ export declare function isTopLevelExecutionContext(): boolean;
41
+ export declare function pushExecutionCtx<T>(ctx: ExecCtx, act: () => T): T;
42
+ export declare function indexHash(this: void, vals: (IValue | string)[]): string;
43
+ export declare function randomString(length?: number, chars?: string): string;
44
+ export declare function schemaOf(t: DataTypeDef): string | nil;
45
+ export declare function isType(t: any): t is (_IType | IType);
46
+ export declare namespace isType {
47
+ var TAG: symbol;
48
+ }
49
+ export declare function suggestColumnName(expr: Expr | nil): string | null;
50
+ export declare function findTemplate<T>(this: void, selection: _ISelection, t: _Transaction, template?: T, columns?: (keyof T)[]): Iterable<T>;
51
+ export declare function compareVersions(_a: string, _b: string): number;
52
+ export declare function intervalToSec(v: Interval): number;
53
+ export declare function parseRegClass(_reg: RegClass): QName | number;
54
+ export declare function parseTime(str: string): moment.Moment;
55
+ export declare function colByName<T>(refs: Map<string, T>, ref: string | ExprRef, nullIfNotFound: boolean | nil): T | nil;
56
+ export declare function colToStr(col: string | ExprRef): string;
57
+ export declare function qnameToStr(col: string | QName): string;
58
+ export declare function asSingleName(col: string | ExprRef): string | nil;
59
+ export declare function asSingleQName(col: string | QName, allowedSchema?: string): string | nil;
60
+ export declare function errorMessage(error: unknown): string;
61
+ export declare function it<T>(iterable: Iterable<T>): IteratorHelper<T>;
62
+ export declare class IteratorHelper<T> implements Iterable<T> {
63
+ private underlying;
64
+ constructor(underlying: () => Iterable<T>);
65
+ [Symbol.iterator](): Iterator<T, any, undefined>;
66
+ flatten(): T extends Iterable<infer X> ? IteratorHelper<X> : never;
67
+ reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U;
68
+ }
69
+ export declare function fromEntries<K, V>(iterable: readonly (readonly [K, V])[]): Map<K, V>;
70
+ export declare function notNil<T>(value: (T | nil)[] | nil): Exclude<T, null>[];
71
+ /** Modify an array if necessary */
72
+ export declare function modifyIfNecessary<T>(values: T[], mapper: (input: T) => T | nil): T[];
73
+ export type LazySync<T> = (() => T) & {
74
+ invalidate: () => void;
75
+ };
76
+ export declare function lazySync<T>(ctor: () => T): LazySync<T>;
77
+ export declare function timeoutOrImmediate(fn: () => void, time: number): any;
78
+ export declare const delay: (time: number | undefined) => Promise<void>;
79
+ export declare class AsyncQueue {
80
+ private queue;
81
+ private processing;
82
+ enqueue(task: () => Promise<any>): void;
83
+ private processQueue;
84
+ }
85
+ export {};
86
+ //# sourceMappingURL=utils.d.ts.map