@snowtop/ent 0.1.0-alpha10 → 0.1.0-alpha101

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 (158) hide show
  1. package/action/action.d.ts +37 -31
  2. package/action/action.js +22 -7
  3. package/action/executor.d.ts +3 -3
  4. package/action/executor.js +8 -3
  5. package/action/experimental_action.d.ts +32 -22
  6. package/action/experimental_action.js +35 -9
  7. package/action/index.d.ts +2 -0
  8. package/action/index.js +7 -1
  9. package/action/orchestrator.d.ts +40 -16
  10. package/action/orchestrator.js +230 -62
  11. package/action/privacy.d.ts +2 -2
  12. package/action/relative_value.d.ts +47 -0
  13. package/action/relative_value.js +125 -0
  14. package/action/transaction.d.ts +10 -0
  15. package/action/transaction.js +23 -0
  16. package/auth/auth.d.ts +1 -1
  17. package/core/base.d.ts +49 -26
  18. package/core/base.js +7 -1
  19. package/core/clause.d.ts +88 -7
  20. package/core/clause.js +355 -63
  21. package/core/config.d.ts +12 -1
  22. package/core/config.js +7 -1
  23. package/core/context.d.ts +5 -3
  24. package/core/context.js +20 -2
  25. package/core/convert.d.ts +1 -1
  26. package/core/date.js +1 -5
  27. package/core/db.d.ts +11 -8
  28. package/core/db.js +20 -8
  29. package/core/ent.d.ts +81 -25
  30. package/core/ent.js +636 -193
  31. package/core/loaders/assoc_count_loader.d.ts +3 -2
  32. package/core/loaders/assoc_count_loader.js +10 -2
  33. package/core/loaders/assoc_edge_loader.d.ts +2 -2
  34. package/core/loaders/assoc_edge_loader.js +8 -11
  35. package/core/loaders/index.d.ts +1 -1
  36. package/core/loaders/index.js +1 -3
  37. package/core/loaders/index_loader.d.ts +2 -2
  38. package/core/loaders/loader.js +5 -5
  39. package/core/loaders/object_loader.d.ts +6 -5
  40. package/core/loaders/object_loader.js +67 -59
  41. package/core/loaders/query_loader.d.ts +6 -12
  42. package/core/loaders/query_loader.js +52 -11
  43. package/core/loaders/raw_count_loader.d.ts +2 -2
  44. package/core/loaders/raw_count_loader.js +5 -1
  45. package/core/logger.d.ts +1 -1
  46. package/core/logger.js +1 -0
  47. package/core/privacy.d.ts +25 -24
  48. package/core/privacy.js +21 -25
  49. package/core/query/assoc_query.d.ts +7 -6
  50. package/core/query/assoc_query.js +9 -1
  51. package/core/query/custom_clause_query.d.ts +26 -0
  52. package/core/query/custom_clause_query.js +78 -0
  53. package/core/query/custom_query.d.ts +20 -5
  54. package/core/query/custom_query.js +87 -12
  55. package/core/query/index.d.ts +1 -0
  56. package/core/query/index.js +3 -1
  57. package/core/query/query.d.ts +8 -4
  58. package/core/query/query.js +101 -53
  59. package/core/query/shared_assoc_test.d.ts +2 -1
  60. package/core/query/shared_assoc_test.js +35 -45
  61. package/core/query/shared_test.d.ts +8 -1
  62. package/core/query/shared_test.js +469 -236
  63. package/core/viewer.d.ts +3 -3
  64. package/core/viewer.js +1 -1
  65. package/graphql/graphql.d.ts +14 -7
  66. package/graphql/graphql.js +23 -7
  67. package/graphql/index.d.ts +0 -1
  68. package/graphql/index.js +1 -4
  69. package/graphql/query/connection_type.d.ts +9 -9
  70. package/graphql/query/edge_connection.d.ts +9 -9
  71. package/graphql/query/page_info.d.ts +1 -1
  72. package/graphql/query/shared_assoc_test.js +1 -1
  73. package/graphql/query/shared_edge_connection.js +1 -19
  74. package/imports/index.d.ts +6 -1
  75. package/imports/index.js +19 -4
  76. package/index.d.ts +12 -5
  77. package/index.js +20 -7
  78. package/package.json +17 -16
  79. package/parse_schema/parse.d.ts +29 -9
  80. package/parse_schema/parse.js +118 -11
  81. package/schema/base_schema.d.ts +5 -3
  82. package/schema/base_schema.js +5 -0
  83. package/schema/field.d.ts +74 -20
  84. package/schema/field.js +174 -69
  85. package/schema/index.d.ts +2 -2
  86. package/schema/index.js +5 -1
  87. package/schema/json_field.d.ts +13 -1
  88. package/schema/json_field.js +28 -1
  89. package/schema/schema.d.ts +81 -18
  90. package/schema/schema.js +24 -17
  91. package/schema/struct_field.d.ts +11 -1
  92. package/schema/struct_field.js +57 -21
  93. package/scripts/custom_compiler.js +10 -6
  94. package/scripts/custom_graphql.js +117 -30
  95. package/scripts/{transform_code.d.ts → migrate_v0.1.d.ts} +0 -0
  96. package/scripts/migrate_v0.1.js +36 -0
  97. package/scripts/{transform_schema.d.ts → move_types.d.ts} +0 -0
  98. package/scripts/move_types.js +117 -0
  99. package/scripts/read_schema.js +20 -5
  100. package/testutils/action/complex_schemas.d.ts +69 -0
  101. package/testutils/action/complex_schemas.js +398 -0
  102. package/testutils/builder.d.ts +46 -47
  103. package/testutils/builder.js +108 -65
  104. package/testutils/db/fixture.d.ts +10 -0
  105. package/testutils/db/fixture.js +26 -0
  106. package/testutils/db/{test_db.d.ts → temp_db.d.ts} +24 -8
  107. package/testutils/db/{test_db.js → temp_db.js} +179 -44
  108. package/testutils/db/value.d.ts +7 -0
  109. package/testutils/db/value.js +251 -0
  110. package/testutils/db_mock.d.ts +16 -4
  111. package/testutils/db_mock.js +51 -6
  112. package/testutils/db_time_zone.d.ts +4 -0
  113. package/testutils/db_time_zone.js +41 -0
  114. package/testutils/ent-graphql-tests/index.d.ts +7 -1
  115. package/testutils/ent-graphql-tests/index.js +27 -8
  116. package/testutils/fake_data/const.d.ts +2 -1
  117. package/testutils/fake_data/const.js +3 -0
  118. package/testutils/fake_data/fake_contact.d.ts +7 -3
  119. package/testutils/fake_data/fake_contact.js +15 -8
  120. package/testutils/fake_data/fake_event.d.ts +5 -2
  121. package/testutils/fake_data/fake_event.js +9 -7
  122. package/testutils/fake_data/fake_tag.d.ts +36 -0
  123. package/testutils/fake_data/fake_tag.js +89 -0
  124. package/testutils/fake_data/fake_user.d.ts +7 -4
  125. package/testutils/fake_data/fake_user.js +18 -16
  126. package/testutils/fake_data/index.js +5 -1
  127. package/testutils/fake_data/internal.d.ts +2 -0
  128. package/testutils/fake_data/internal.js +7 -1
  129. package/testutils/fake_data/tag_query.d.ts +13 -0
  130. package/testutils/fake_data/tag_query.js +43 -0
  131. package/testutils/fake_data/test_helpers.d.ts +11 -4
  132. package/testutils/fake_data/test_helpers.js +28 -12
  133. package/testutils/fake_data/user_query.d.ts +13 -6
  134. package/testutils/fake_data/user_query.js +54 -22
  135. package/testutils/fake_log.d.ts +3 -3
  136. package/testutils/parse_sql.d.ts +6 -0
  137. package/testutils/parse_sql.js +16 -2
  138. package/testutils/test_edge_global_schema.d.ts +15 -0
  139. package/testutils/test_edge_global_schema.js +62 -0
  140. package/testutils/write.d.ts +2 -2
  141. package/testutils/write.js +33 -7
  142. package/tsc/ast.d.ts +26 -2
  143. package/tsc/ast.js +163 -17
  144. package/tsc/compilerOptions.d.ts +2 -1
  145. package/tsc/compilerOptions.js +11 -2
  146. package/tsc/move_generated.d.ts +1 -0
  147. package/tsc/move_generated.js +164 -0
  148. package/tsc/transform.d.ts +22 -0
  149. package/tsc/transform.js +181 -0
  150. package/tsc/transform_action.d.ts +22 -0
  151. package/tsc/transform_action.js +183 -0
  152. package/tsc/transform_ent.d.ts +17 -0
  153. package/tsc/transform_ent.js +59 -0
  154. package/tsc/transform_schema.d.ts +27 -0
  155. package/{scripts → tsc}/transform_schema.js +145 -119
  156. package/graphql/enums.d.ts +0 -3
  157. package/graphql/enums.js +0 -25
  158. package/scripts/transform_code.js +0 -114
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.maybeConvertRelativeInputPlusExpressions = exports.convertRelativeInput = exports.NumberOps = void 0;
4
+ const clause_1 = require("../core/clause");
5
+ function addNumber(delta) {
6
+ return {
7
+ delta,
8
+ sqlExpression(col) {
9
+ return (0, clause_1.Add)(col, delta);
10
+ },
11
+ eval(curr) {
12
+ // @ts-expect-error
13
+ return curr + delta;
14
+ },
15
+ };
16
+ }
17
+ function subtractNumber(delta) {
18
+ return {
19
+ delta,
20
+ sqlExpression(col) {
21
+ return (0, clause_1.Subtract)(col, delta);
22
+ },
23
+ eval(curr) {
24
+ // @ts-expect-error
25
+ return curr - delta;
26
+ },
27
+ };
28
+ }
29
+ function multiplyNumber(delta) {
30
+ return {
31
+ delta,
32
+ sqlExpression(col) {
33
+ return (0, clause_1.Multiply)(col, delta);
34
+ },
35
+ eval(curr) {
36
+ // @ts-expect-error
37
+ return curr * delta;
38
+ },
39
+ };
40
+ }
41
+ function divideNumber(delta) {
42
+ return {
43
+ delta,
44
+ sqlExpression(col) {
45
+ return (0, clause_1.Divide)(col, delta);
46
+ },
47
+ eval(curr) {
48
+ // @ts-expect-error
49
+ return curr / delta;
50
+ },
51
+ };
52
+ }
53
+ function moduloNumber(delta) {
54
+ return {
55
+ delta,
56
+ sqlExpression(col) {
57
+ return (0, clause_1.Modulo)(col, delta);
58
+ },
59
+ eval(curr) {
60
+ // @ts-expect-error
61
+ return curr % delta;
62
+ },
63
+ };
64
+ }
65
+ exports.NumberOps = {
66
+ addNumber,
67
+ moduloNumber,
68
+ divideNumber,
69
+ subtractNumber,
70
+ multiplyNumber,
71
+ };
72
+ function convertRelativeInput(rel, col, existing) {
73
+ if (Object.keys(rel).length !== 1) {
74
+ throw new Error(`only 1 key is expected. ${Object.keys(rel).length} given`);
75
+ }
76
+ const ret = (relField) => {
77
+ return {
78
+ value: relField.eval(existing),
79
+ clause: relField.sqlExpression(col),
80
+ };
81
+ };
82
+ if (rel.add !== undefined) {
83
+ // @ts-expect-error
84
+ return ret(addNumber(rel.add));
85
+ }
86
+ if (rel.subtract !== undefined) {
87
+ // @ts-expect-error
88
+ return ret(subtractNumber(rel.subtract));
89
+ }
90
+ if (rel.multiply !== undefined) {
91
+ // @ts-expect-error
92
+ return ret(multiplyNumber(rel.multiply));
93
+ }
94
+ if (rel.divide !== undefined) {
95
+ // @ts-expect-error
96
+ return ret(divideNumber(rel.divide));
97
+ }
98
+ if (rel.modulo !== undefined) {
99
+ // @ts-expect-error
100
+ return ret(moduloNumber(rel.modulo));
101
+ }
102
+ throw new Error(`error in convertRelativeInput. shouldn't have gotten here`);
103
+ }
104
+ exports.convertRelativeInput = convertRelativeInput;
105
+ function maybeConvertRelativeInputPlusExpressions(rel, col, existing, expressions) {
106
+ if (rel === null) {
107
+ return rel;
108
+ }
109
+ if (rel === undefined) {
110
+ return rel;
111
+ }
112
+ if (typeof rel === "bigint" || typeof rel === "number") {
113
+ return rel;
114
+ }
115
+ // // TODO is this the behavior we want? should we coalesce as 0?
116
+ // if (existing === null) {
117
+ // throw new Error(`cannot perform a relative operation on null`);
118
+ // }
119
+ // @ts-ignore
120
+ // shouldn't be failing like it currently is. it thinks rel can be bigint and it shouldn't be???
121
+ const { clause, value } = convertRelativeInput(rel, col, existing);
122
+ expressions.set(col, clause);
123
+ return value;
124
+ }
125
+ exports.maybeConvertRelativeInputPlusExpressions = maybeConvertRelativeInputPlusExpressions;
@@ -0,0 +1,10 @@
1
+ import { Ent, Viewer } from "../core/base";
2
+ import { Action, Builder } from "./action";
3
+ type ActionAny = Action<Ent<Viewer<any, any>>, Builder<Ent<Viewer<any, any>>, Viewer<any, any>, any>, Viewer<any, any>, any, any>;
4
+ export declare class Transaction {
5
+ private viewer;
6
+ private actions;
7
+ constructor(viewer: Viewer, actions: ActionAny[]);
8
+ run(): Promise<void>;
9
+ }
10
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Transaction = void 0;
4
+ const executor_1 = require("./executor");
5
+ class Transaction {
6
+ constructor(viewer,
7
+ // independent operations
8
+ actions) {
9
+ this.viewer = viewer;
10
+ this.actions = actions;
11
+ }
12
+ async run() {
13
+ const changesets = [];
14
+ await Promise.all(this.actions.map(async (action) => {
15
+ const c = await action.changeset();
16
+ changesets.push(c);
17
+ }));
18
+ const executor = new executor_1.ComplexExecutor(this.viewer, "", // no placeholder, no opers
19
+ [], new Map(), changesets);
20
+ await executor.execute();
21
+ }
22
+ }
23
+ exports.Transaction = Transaction;
package/auth/auth.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Viewer } from "../core/base";
3
3
  import { RequestContext } from "../core/context";
4
4
  import { IncomingMessage, ServerResponse } from "http";
5
- export declare type AuthViewer = Viewer | null;
5
+ export type AuthViewer = Viewer | null;
6
6
  export interface AuthHandler {
7
7
  authViewer(ctx: RequestContext): AuthViewer | Promise<AuthViewer>;
8
8
  }
package/core/base.d.ts CHANGED
@@ -5,19 +5,27 @@ export interface Loader<T, V> {
5
5
  loadMany?(keys: T[]): Promise<(V | null)[]>;
6
6
  clearAll(): any;
7
7
  }
8
- export interface LoaderFactory<T, V> {
8
+ export interface LoaderWithLoadMany<T, V> extends Loader<T, V> {
9
+ loadMany(keys: T[]): Promise<V[]>;
10
+ }
11
+ export interface LoaderFactory<K, V> {
9
12
  name: string;
10
- createLoader(context?: Context): Loader<T, V>;
13
+ createLoader(context?: Context): Loader<K, V>;
14
+ }
15
+ interface LoaderFactoryWithLoaderMany<T, V> extends LoaderFactory<T, V> {
16
+ createLoader(context?: Context): LoaderWithLoadMany<T, V>;
11
17
  }
12
18
  export interface ConfigurableLoaderFactory<T, V> extends LoaderFactory<T, V> {
13
19
  createConfigurableLoader(options: EdgeQueryableDataOptions, context?: Context): Loader<T, V>;
14
20
  }
15
- export declare type EdgeQueryableDataOptions = Partial<Pick<QueryableDataOptions, "limit" | "orderby" | "clause">>;
21
+ export type EdgeQueryableDataOptions = Partial<Pick<QueryableDataOptions, "limit" | "orderby" | "clause">>;
16
22
  export interface PrimableLoader<T, V> extends Loader<T, V> {
17
23
  prime(d: Data): void;
24
+ primeAll?(d: Data): void;
18
25
  }
19
26
  interface cache {
20
27
  getLoader<T, V>(name: string, create: () => Loader<T, V>): Loader<T, V>;
28
+ getLoaderWithLoadMany<T, V>(name: string, create: () => LoaderWithLoadMany<T, V>): LoaderWithLoadMany<T, V>;
21
29
  getCachedRows(options: queryOptions): Data[] | null;
22
30
  getCachedRow(options: queryOptions): Data | null;
23
31
  primeCache(options: queryOptions, rows: Data[]): void;
@@ -30,29 +38,30 @@ interface queryOptions {
30
38
  clause: clause.Clause;
31
39
  orderby?: string;
32
40
  }
33
- export interface Context {
34
- getViewer(): Viewer;
41
+ export interface Context<TViewer extends Viewer = Viewer> {
42
+ getViewer(): TViewer;
35
43
  cache?: cache;
36
44
  }
37
- export interface Viewer {
38
- viewerID: ID | null;
39
- viewer: () => Promise<Ent | null>;
45
+ export interface Viewer<TEnt extends any = Ent<any> | null, TID extends any = ID | null> {
46
+ viewerID: TID;
47
+ viewer: () => Promise<TEnt>;
40
48
  instanceKey: () => string;
41
- context?: Context;
49
+ context?: Context<any>;
42
50
  }
43
- export interface Ent {
51
+ export interface Ent<TViewer extends Viewer = Viewer> {
44
52
  id: ID;
45
- viewer: Viewer;
46
- getPrivacyPolicy(): PrivacyPolicy<this>;
53
+ viewer: TViewer;
54
+ getPrivacyPolicy(): PrivacyPolicy<this, TViewer>;
47
55
  nodeType: string;
56
+ __setRawDBData<T extends Data = Data>(data: T): any;
48
57
  }
49
58
  export declare type Data = {
50
59
  [key: string]: any;
51
60
  };
52
- export interface EntConstructor<T extends Ent> {
53
- new (viewer: Viewer, data: Data): T;
61
+ export interface EntConstructor<TEnt extends Ent, TViewer extends Viewer = Viewer> {
62
+ new (viewer: TViewer, data: Data): TEnt;
54
63
  }
55
- export declare type ID = string | number;
64
+ export type ID = string | number;
56
65
  export interface DataOptions {
57
66
  tableName: string;
58
67
  context?: Context;
@@ -72,6 +81,7 @@ export interface QueryDataOptions {
72
81
  orderby?: string;
73
82
  groupby?: string;
74
83
  limit?: number;
84
+ disableTransformations?: boolean;
75
85
  }
76
86
  export interface LoadRowOptions extends QueryableDataOptions {
77
87
  }
@@ -82,17 +92,25 @@ export interface CreateRowOptions extends DataOptions {
82
92
  fieldsToLog?: Data;
83
93
  }
84
94
  export interface EditRowOptions extends CreateRowOptions {
85
- key: string;
95
+ whereClause: clause.Clause;
96
+ expressions?: Map<string, clause.Clause>;
86
97
  }
87
- interface LoadableEntOptions<T extends Ent> {
88
- loaderFactory: LoaderFactory<any, Data | null>;
89
- ent: EntConstructor<T>;
98
+ interface LoadableEntOptions<TEnt extends Ent, TViewer extends Viewer = Viewer> {
99
+ loaderFactory: LoaderFactoryWithOptions;
100
+ ent: EntConstructor<TEnt, TViewer>;
101
+ }
102
+ export interface LoaderFactoryWithOptions extends LoaderFactoryWithLoaderMany<any, Data | null> {
103
+ options?: SelectDataOptions;
90
104
  }
91
- export interface LoadEntOptions<T extends Ent> extends LoadableEntOptions<T>, SelectBaseDataOptions {
105
+ export interface LoadEntOptions<TEnt extends Ent, TViewer extends Viewer = Viewer> extends LoadableEntOptions<TEnt, TViewer>, SelectBaseDataOptions {
92
106
  fieldPrivacy?: Map<string, PrivacyPolicy>;
93
107
  }
94
- export interface LoadCustomEntOptions<T extends Ent> extends SelectBaseDataOptions {
95
- ent: EntConstructor<T>;
108
+ export interface SelectCustomDataOptions extends SelectBaseDataOptions {
109
+ loaderFactory: LoaderFactoryWithOptions;
110
+ prime?: boolean;
111
+ }
112
+ export interface LoadCustomEntOptions<TEnt extends Ent, TViewer extends Viewer = Viewer> extends SelectCustomDataOptions {
113
+ ent: EntConstructor<TEnt, TViewer>;
96
114
  fieldPrivacy?: Map<string, PrivacyPolicy>;
97
115
  }
98
116
  export interface LoaderInfo {
@@ -121,10 +139,15 @@ export declare function Allow(): PrivacyResult;
121
139
  export declare function Skip(): PrivacyResult;
122
140
  export declare function Deny(): PrivacyResult;
123
141
  export declare function DenyWithReason(e: PrivacyError | string): PrivacyResult;
124
- export interface PrivacyPolicyRule<TEnt extends Ent = Ent> {
125
- apply(v: Viewer, ent?: TEnt): Promise<PrivacyResult>;
142
+ export interface PrivacyPolicyRule<TEnt extends Ent = Ent, TViewer = Viewer> {
143
+ apply(v: TViewer, ent?: TEnt): Promise<PrivacyResult>;
144
+ }
145
+ export interface PrivacyPolicy<TEnt extends Ent = Ent, TViewer = Viewer> {
146
+ rules: PrivacyPolicyRule<TEnt, TViewer>[];
126
147
  }
127
- export interface PrivacyPolicy<TEnt extends Ent = Ent> {
128
- rules: PrivacyPolicyRule<TEnt>[];
148
+ export declare enum WriteOperation {
149
+ Insert = "insert",
150
+ Edit = "edit",
151
+ Delete = "delete"
129
152
  }
130
153
  export {};
package/core/base.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DenyWithReason = exports.Deny = exports.Skip = exports.Allow = void 0;
3
+ exports.WriteOperation = exports.DenyWithReason = exports.Deny = exports.Skip = exports.Allow = void 0;
4
4
  // Privacy
5
5
  var privacyResult;
6
6
  (function (privacyResult) {
@@ -53,3 +53,9 @@ function DenyWithReason(e) {
53
53
  };
54
54
  }
55
55
  exports.DenyWithReason = DenyWithReason;
56
+ var WriteOperation;
57
+ (function (WriteOperation) {
58
+ WriteOperation["Insert"] = "insert";
59
+ WriteOperation["Edit"] = "edit";
60
+ WriteOperation["Delete"] = "delete";
61
+ })(WriteOperation = exports.WriteOperation || (exports.WriteOperation = {}));
package/core/clause.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  export interface Clause {
2
2
  clause(idx: number): string;
3
+ columns(): string[];
3
4
  values(): any[];
4
5
  instanceKey(): string;
5
6
  logValues(): any[];
7
+ compositeOp?: string;
6
8
  }
7
9
  export interface SensitiveValue {
8
10
  value(): any;
@@ -12,10 +14,23 @@ declare class simpleClause implements Clause {
12
14
  protected col: string;
13
15
  private value;
14
16
  private op;
15
- private handleSqliteNull?;
16
- constructor(col: string, value: any, op: string, handleSqliteNull?: Clause | undefined);
17
+ private handleNull?;
18
+ constructor(col: string, value: any, op: string, handleNull?: Clause | undefined);
17
19
  clause(idx: number): string;
18
- private sqliteNull;
20
+ private nullClause;
21
+ columns(): string[];
22
+ values(): any[];
23
+ logValues(): any[];
24
+ instanceKey(): string;
25
+ }
26
+ export declare class inClause implements Clause {
27
+ private col;
28
+ private value;
29
+ private type;
30
+ static getPostgresInClauseValuesThreshold(): number;
31
+ constructor(col: string, value: any[], type?: string);
32
+ clause(idx: number): string;
33
+ columns(): string[];
19
34
  values(): any[];
20
35
  logValues(): any[];
21
36
  instanceKey(): string;
@@ -23,18 +38,58 @@ declare class simpleClause implements Clause {
23
38
  declare class compositeClause implements Clause {
24
39
  private clauses;
25
40
  private sep;
41
+ compositeOp: string;
26
42
  constructor(clauses: Clause[], sep: string);
27
43
  clause(idx: number): string;
44
+ columns(): string[];
28
45
  values(): any[];
29
46
  logValues(): any[];
30
47
  instanceKey(): string;
31
48
  }
49
+ /**
50
+ * creates a clause to determine if the given value is contained in the array stored in the column in the db
51
+ * only works with postgres gin indexes
52
+ * https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
53
+ */
54
+ export declare function PostgresArrayContainsValue(col: string, value: any): Clause;
55
+ /**
56
+ * creates a clause to determine if every item in the list is stored in the array stored in the column in the db
57
+ * only works with postgres gin indexes
58
+ * https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
59
+ */
60
+ export declare function PostgresArrayContains(col: string, value: any[]): Clause;
61
+ /**
62
+ * creates a clause to determine if the given value is NOT contained in the array stored in the column in the db
63
+ * only works with postgres gin indexes
64
+ * https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
65
+ */
66
+ export declare function PostgresArrayNotContainsValue(col: string, value: any): Clause;
67
+ /**
68
+ * creates a clause to determine if every item in the list is NOT stored in the array stored in the column in the db
69
+ * only works with postgres gin indexes
70
+ * https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
71
+ */
72
+ export declare function PostgresArrayNotContains(col: string, value: any[]): Clause;
73
+ /**
74
+ * creates a clause to determine if the arrays overlap, that is, do they have any elements in common
75
+ * only works with postgres gin indexes
76
+ * https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
77
+ */
78
+ export declare function PostgresArrayOverlaps(col: string, value: any[]): Clause;
79
+ /**
80
+ * creates a clause to determine if the arrays do not overlap, that is, do they have any elements in common
81
+ * only works with postgres gin indexes
82
+ * https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
83
+ */
84
+ export declare function PostgresArrayNotOverlaps(col: string, value: any[]): Clause;
85
+ /**
86
+ * @deprecated use PostgresArrayContainsValue
87
+ */
32
88
  export declare function ArrayEq(col: string, value: any): Clause;
89
+ /**
90
+ * @deprecated use PostgresNotArrayContains
91
+ */
33
92
  export declare function ArrayNotEq(col: string, value: any): Clause;
34
- export declare function ArrayGreater(col: string, value: any): Clause;
35
- export declare function ArrayLess(col: string, value: any): Clause;
36
- export declare function ArrayGreaterEq(col: string, value: any): Clause;
37
- export declare function ArrayLessEq(col: string, value: any): Clause;
38
93
  export declare function Eq(col: string, value: any): Clause;
39
94
  export declare function NotEq(col: string, value: any): Clause;
40
95
  export declare function Greater(col: string, value: any): simpleClause;
@@ -44,7 +99,9 @@ export declare function LessEq(col: string, value: any): simpleClause;
44
99
  export declare function And(...args: Clause[]): compositeClause;
45
100
  export declare function AndOptional(...args: (Clause | undefined)[]): Clause;
46
101
  export declare function Or(...args: Clause[]): compositeClause;
102
+ export declare function OrOptional(...args: (Clause | undefined)[]): Clause;
47
103
  export declare function In(col: string, ...values: any): Clause;
104
+ export declare function In(col: string, values: any[], type?: string): Clause;
48
105
  interface TsQuery {
49
106
  language: "english" | "french" | "german" | "simple";
50
107
  value: string;
@@ -58,4 +115,28 @@ export declare function TsVectorPlainToTsQuery(col: string, val: string | TsQuer
58
115
  export declare function TsVectorPhraseToTsQuery(col: string, val: string | TsQuery): Clause;
59
116
  export declare function TsVectorWebsearchToTsQuery(col: string, val: string | TsQuery): Clause;
60
117
  export declare function sensitiveValue(val: any): SensitiveValue;
118
+ export declare function JSONObjectFieldKeyASJSON(col: string, field: string): string;
119
+ export declare function JSONObjectFieldKeyAsText(col: string, field: string): string;
120
+ type predicate = "==" | ">" | "<" | "!=" | ">=" | "<=";
121
+ export declare function JSONPathValuePredicate(dbCol: string, path: string, val: any, pred: predicate): Clause;
122
+ declare class paginationMultipleColumnsSubQueryClause implements Clause {
123
+ private col;
124
+ private op;
125
+ private tableName;
126
+ private uniqueCol;
127
+ private val;
128
+ constructor(col: string, op: string, tableName: string, uniqueCol: string, val: any);
129
+ private buildSimpleQuery;
130
+ clause(idx: number): string;
131
+ columns(): string[];
132
+ values(): any[];
133
+ logValues(): any[];
134
+ instanceKey(): string;
135
+ }
136
+ export declare function PaginationMultipleColsSubQuery(col: string, op: string, tableName: string, uniqueCol: string, val: any): paginationMultipleColumnsSubQueryClause;
137
+ export declare function Add(col: string, value: any): Clause;
138
+ export declare function Subtract(col: string, value: any): Clause;
139
+ export declare function Multiply(col: string, value: any): Clause;
140
+ export declare function Divide(col: string, value: any): Clause;
141
+ export declare function Modulo(col: string, value: any): Clause;
61
142
  export {};