dsqlbase 0.0.1 → 0.1.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/CHANGELOG.md +27 -0
- package/README.md +86 -0
- package/dist/client/create.d.ts +73 -0
- package/dist/client/create.d.ts.map +1 -0
- package/dist/client/create.js +82 -0
- package/dist/client/create.js.map +1 -0
- package/dist/client/database/base.d.ts +8 -0
- package/dist/client/database/base.d.ts.map +1 -0
- package/dist/client/database/base.js +13 -0
- package/dist/client/database/base.js.map +1 -0
- package/dist/client/database/client.d.ts +5 -0
- package/dist/client/database/client.d.ts.map +1 -0
- package/dist/client/database/client.js +4 -0
- package/dist/client/database/client.js.map +1 -0
- package/dist/client/database/index.d.ts +9 -0
- package/dist/client/database/index.d.ts.map +1 -0
- package/dist/client/database/index.js +3 -0
- package/dist/client/database/index.js.map +1 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +5 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/model/base.d.ts +330 -0
- package/dist/client/model/base.d.ts.map +1 -0
- package/dist/client/model/base.js +7 -0
- package/dist/client/model/base.js.map +1 -0
- package/dist/client/model/client.d.ts +102 -0
- package/dist/client/model/client.d.ts.map +1 -0
- package/dist/client/model/client.js +123 -0
- package/dist/client/model/client.js.map +1 -0
- package/dist/client/model/normalizer.d.ts +19 -0
- package/dist/client/model/normalizer.d.ts.map +1 -0
- package/dist/client/model/normalizer.js +221 -0
- package/dist/client/model/normalizer.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/pg/index.d.ts +9 -0
- package/dist/pg/index.d.ts.map +1 -0
- package/dist/pg/index.js +14 -0
- package/dist/pg/index.js.map +1 -0
- package/dist/pglite/index.d.ts +9 -0
- package/dist/pglite/index.d.ts.map +1 -0
- package/dist/pglite/index.js +14 -0
- package/dist/pglite/index.js.map +1 -0
- package/dist/schema/columns/array.d.ts +16 -0
- package/dist/schema/columns/array.d.ts.map +1 -0
- package/dist/schema/columns/array.js +24 -0
- package/dist/schema/columns/array.js.map +1 -0
- package/dist/schema/columns/bigint.d.ts +11 -0
- package/dist/schema/columns/bigint.d.ts.map +1 -0
- package/dist/schema/columns/bigint.js +19 -0
- package/dist/schema/columns/bigint.js.map +1 -0
- package/dist/schema/columns/boolean.d.ts +10 -0
- package/dist/schema/columns/boolean.d.ts.map +1 -0
- package/dist/schema/columns/boolean.js +18 -0
- package/dist/schema/columns/boolean.js.map +1 -0
- package/dist/schema/columns/bytea.d.ts +8 -0
- package/dist/schema/columns/bytea.d.ts.map +1 -0
- package/dist/schema/columns/bytea.js +16 -0
- package/dist/schema/columns/bytea.js.map +1 -0
- package/dist/schema/columns/char.d.ts +10 -0
- package/dist/schema/columns/char.d.ts.map +1 -0
- package/dist/schema/columns/char.js +18 -0
- package/dist/schema/columns/char.js.map +1 -0
- package/dist/schema/columns/date.d.ts +23 -0
- package/dist/schema/columns/date.d.ts.map +1 -0
- package/dist/schema/columns/date.js +29 -0
- package/dist/schema/columns/date.js.map +1 -0
- package/dist/schema/columns/double.d.ts +13 -0
- package/dist/schema/columns/double.d.ts.map +1 -0
- package/dist/schema/columns/double.js +21 -0
- package/dist/schema/columns/double.js.map +1 -0
- package/dist/schema/columns/identity.d.ts +56 -0
- package/dist/schema/columns/identity.d.ts.map +1 -0
- package/dist/schema/columns/identity.js +65 -0
- package/dist/schema/columns/identity.js.map +1 -0
- package/dist/schema/columns/int.d.ts +11 -0
- package/dist/schema/columns/int.d.ts.map +1 -0
- package/dist/schema/columns/int.js +19 -0
- package/dist/schema/columns/int.js.map +1 -0
- package/dist/schema/columns/interval.d.ts +23 -0
- package/dist/schema/columns/interval.d.ts.map +1 -0
- package/dist/schema/columns/interval.js +40 -0
- package/dist/schema/columns/interval.js.map +1 -0
- package/dist/schema/columns/json.d.ts +9 -0
- package/dist/schema/columns/json.d.ts.map +1 -0
- package/dist/schema/columns/json.js +18 -0
- package/dist/schema/columns/json.js.map +1 -0
- package/dist/schema/columns/numeric.d.ts +11 -0
- package/dist/schema/columns/numeric.d.ts.map +1 -0
- package/dist/schema/columns/numeric.js +19 -0
- package/dist/schema/columns/numeric.js.map +1 -0
- package/dist/schema/columns/real.d.ts +13 -0
- package/dist/schema/columns/real.d.ts.map +1 -0
- package/dist/schema/columns/real.js +21 -0
- package/dist/schema/columns/real.js.map +1 -0
- package/dist/schema/columns/smallint.d.ts +11 -0
- package/dist/schema/columns/smallint.d.ts.map +1 -0
- package/dist/schema/columns/smallint.js +19 -0
- package/dist/schema/columns/smallint.js.map +1 -0
- package/dist/schema/columns/text.d.ts +9 -0
- package/dist/schema/columns/text.d.ts.map +1 -0
- package/dist/schema/columns/text.js +17 -0
- package/dist/schema/columns/text.js.map +1 -0
- package/dist/schema/columns/time.d.ts +20 -0
- package/dist/schema/columns/time.d.ts.map +1 -0
- package/dist/schema/columns/time.js +19 -0
- package/dist/schema/columns/time.js.map +1 -0
- package/dist/schema/columns/timestamp.d.ts +40 -0
- package/dist/schema/columns/timestamp.d.ts.map +1 -0
- package/dist/schema/columns/timestamp.js +48 -0
- package/dist/schema/columns/timestamp.js.map +1 -0
- package/dist/schema/columns/uuid.d.ts +17 -0
- package/dist/schema/columns/uuid.d.ts.map +1 -0
- package/dist/schema/columns/uuid.js +27 -0
- package/dist/schema/columns/uuid.js.map +1 -0
- package/dist/schema/columns/varchar.d.ts +9 -0
- package/dist/schema/columns/varchar.d.ts.map +1 -0
- package/dist/schema/columns/varchar.js +17 -0
- package/dist/schema/columns/varchar.js.map +1 -0
- package/dist/schema/domain.d.ts +19 -0
- package/dist/schema/domain.d.ts.map +1 -0
- package/dist/schema/domain.js +37 -0
- package/dist/schema/domain.js.map +1 -0
- package/dist/schema/index.d.ts +27 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +25 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/namespace.d.ts +22 -0
- package/dist/schema/namespace.d.ts.map +1 -0
- package/dist/schema/namespace.js +24 -0
- package/dist/schema/namespace.js.map +1 -0
- package/dist/schema/relations.d.ts +12 -0
- package/dist/schema/relations.d.ts.map +1 -0
- package/dist/schema/relations.js +29 -0
- package/dist/schema/relations.js.map +1 -0
- package/dist/schema/sequence.d.ts +14 -0
- package/dist/schema/sequence.d.ts.map +1 -0
- package/dist/schema/sequence.js +16 -0
- package/dist/schema/sequence.js.map +1 -0
- package/dist/schema/table.d.ts +20 -0
- package/dist/schema/table.d.ts.map +1 -0
- package/dist/schema/table.js +22 -0
- package/dist/schema/table.js.map +1 -0
- package/dist/schema/utils/date.d.ts +33 -0
- package/dist/schema/utils/date.d.ts.map +1 -0
- package/dist/schema/utils/date.js +62 -0
- package/dist/schema/utils/date.js.map +1 -0
- package/dist/schema/utils/duration.d.ts +66 -0
- package/dist/schema/utils/duration.d.ts.map +1 -0
- package/dist/schema/utils/duration.js +167 -0
- package/dist/schema/utils/duration.js.map +1 -0
- package/dist/schema/utils/json.d.ts +2 -0
- package/dist/schema/utils/json.d.ts.map +1 -0
- package/dist/schema/utils/json.js +12 -0
- package/dist/schema/utils/json.js.map +1 -0
- package/package.json +34 -5
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { SQLValue } from "@dsqlbase/core";
|
|
2
|
+
import { AnyColumnDefinition, AnyNamespaceDefinition, AnyFieldRelation, AnyTableRelations, ColumnConfig, TableDefinition } from "@dsqlbase/core/definition";
|
|
3
|
+
import { AnySchema, AnyTable, SchemaTableRelations, Table } from "@dsqlbase/core/runtime";
|
|
4
|
+
import { Prettify } from "@dsqlbase/core/utils";
|
|
5
|
+
export type FieldNamesOf<T extends AnyTable> = keyof T["__type"]["columns"] extends infer K ? K extends string ? T["__type"]["columns"][K] extends AnyColumnDefinition ? K : never : never : never;
|
|
6
|
+
export type RelationFieldNamesOf<T extends AnyTable> = T["__type"]["relations"] extends AnyTableRelations ? keyof T["__type"]["relations"] extends infer K ? K extends string ? T["__type"]["relations"][K] extends AnyFieldRelation ? K : never : never : never : never;
|
|
7
|
+
export type ColumnTypeOf<T extends AnyTable, K extends FieldNamesOf<T>> = T["__type"]["columns"] extends Record<K, infer TColumn> ? TColumn extends AnyColumnDefinition ? TColumn["__type"] : never : never;
|
|
8
|
+
export type FieldRelationOf<T extends AnyTable, K extends RelationFieldNamesOf<T>> = T["__type"]["relations"] extends Record<K, infer R> ? R extends AnyFieldRelation ? R : never : never;
|
|
9
|
+
export type ValueTypeOf<T extends ColumnConfig> = T extends ColumnConfig ? T["notNull"] extends true ? T["valueType"] : T["valueType"] | null : never;
|
|
10
|
+
export type FieldSelectionOf<T extends AnyTable> = Partial<Record<FieldNamesOf<T>, boolean>>;
|
|
11
|
+
export type SelectedFieldsOf<TTable extends AnyTable, TSelection extends FieldSelectionOf<TTable>> = {
|
|
12
|
+
[K in keyof TSelection]: TSelection[K] extends true ? K : never;
|
|
13
|
+
}[keyof TSelection];
|
|
14
|
+
export type RequiredFieldsOf<T extends AnyTable> = {
|
|
15
|
+
[K in FieldNamesOf<T>]: ColumnTypeOf<T, K> extends {
|
|
16
|
+
notNull: true;
|
|
17
|
+
} ? ColumnTypeOf<T, K> extends {
|
|
18
|
+
hasDefault: true;
|
|
19
|
+
} ? never : K : never;
|
|
20
|
+
}[FieldNamesOf<T>];
|
|
21
|
+
export type RelationTypeOf<T extends AnyTable, K extends RelationFieldNamesOf<T>> = FieldRelationOf<T, K>["type"];
|
|
22
|
+
export type RelationTargetOf<T extends AnyTable, K extends RelationFieldNamesOf<T>> = FieldRelationOf<T, K>["target"];
|
|
23
|
+
export type OptionalFieldsOf<T extends AnyTable> = {
|
|
24
|
+
[K in FieldNamesOf<T>]: ColumnTypeOf<T, K> extends {
|
|
25
|
+
notNull: true;
|
|
26
|
+
} ? ColumnTypeOf<T, K> extends {
|
|
27
|
+
hasDefault: true;
|
|
28
|
+
} ? K : never : K;
|
|
29
|
+
}[FieldNamesOf<T>];
|
|
30
|
+
export type CreateValuesOf<T extends AnyTable> = {
|
|
31
|
+
[K in RequiredFieldsOf<T>]: ValueTypeOf<ColumnTypeOf<T, K>>;
|
|
32
|
+
} & {
|
|
33
|
+
[K in OptionalFieldsOf<T>]?: ValueTypeOf<ColumnTypeOf<T, K>>;
|
|
34
|
+
};
|
|
35
|
+
export type ReturningResultOf<T extends AnyTable, TArgs> = TArgs extends {
|
|
36
|
+
return?: infer R;
|
|
37
|
+
} ? R extends FieldSelectionOf<T> ? {
|
|
38
|
+
[K in SelectedFieldsOf<T, R>]: K extends FieldNamesOf<T> ? ValueTypeOf<ColumnTypeOf<T, K>> : never;
|
|
39
|
+
} : R extends true ? {
|
|
40
|
+
[K in FieldNamesOf<T>]: ValueTypeOf<ColumnTypeOf<T, K>>;
|
|
41
|
+
} : Record<string, never> : never;
|
|
42
|
+
export type CreateArgs<TTable extends AnyTable> = Prettify<{
|
|
43
|
+
data: CreateValuesOf<TTable>;
|
|
44
|
+
return?: FieldSelectionOf<TTable> | boolean | null | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
export type UpdateValuesOf<T extends AnyTable> = {
|
|
47
|
+
[K in FieldNamesOf<T>]?: ValueTypeOf<ColumnTypeOf<T, K>>;
|
|
48
|
+
};
|
|
49
|
+
export type UpdateArgs<TTable extends AnyTable> = Prettify<{
|
|
50
|
+
set: UpdateValuesOf<TTable>;
|
|
51
|
+
where: WhereExpressionOf<TTable>;
|
|
52
|
+
return?: FieldSelectionOf<TTable> | boolean | null | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
export type DeleteArgs<TTable extends AnyTable> = Prettify<{
|
|
55
|
+
where: WhereExpressionOf<TTable>;
|
|
56
|
+
return?: FieldSelectionOf<TTable> | boolean | null | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
export interface QueryArgs<TTable extends AnyTable, TSchema extends AnySchema> {
|
|
59
|
+
/**
|
|
60
|
+
* Select specific fields to return in the query result. If not provided, all fields will be returned.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* client.findOne({
|
|
65
|
+
* where: { id: { eq: "123" } },
|
|
66
|
+
* select: {
|
|
67
|
+
* id: true,
|
|
68
|
+
* firstName: true,
|
|
69
|
+
* },
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
* @notes
|
|
73
|
+
* * The `select` clause allows you to specify which fields to retrieve, if not provided, all fields will be selected by default.
|
|
74
|
+
* * You can only select fields that exist on the table, attempting to select a non-existent field will result in a TypeScript error.
|
|
75
|
+
*
|
|
76
|
+
* @typeParam TTable - The table being queried, used for type inference of selectable fields.
|
|
77
|
+
* @typeParam TSchema - The overall schema, used for type inference of relations in join expressions.
|
|
78
|
+
*/
|
|
79
|
+
select?: FieldSelectionOf<TTable>;
|
|
80
|
+
/**
|
|
81
|
+
* A filter expression to specify which records to retrieve. This is optional for `findMany`, if not provided, all records will be returned.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* client.findMany({
|
|
86
|
+
* where: { published: true },
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
* @notes
|
|
90
|
+
* * The `where` clause is optional for `findMany`, if not provided, all records will be returned.
|
|
91
|
+
* * The `where` clause supports various filter conditions such as equality, inequality, range queries, and more.
|
|
92
|
+
* * You can combine multiple conditions using logical operators like `and`, `or`, and `not`.
|
|
93
|
+
* * The fields used in the `where` clause must exist on the table, attempting to filter by a non-existent field will result in a TypeScript error.
|
|
94
|
+
*
|
|
95
|
+
* @typeParam TTable - The table being queried, used for type inference of filterable fields.
|
|
96
|
+
*/
|
|
97
|
+
where?: WhereExpressionOf<TTable>;
|
|
98
|
+
/**
|
|
99
|
+
* Specify the order in which to return the records. The keys must be field names of the table, and the values must be either "asc" for ascending order or "desc" for descending order.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* client.findMany({
|
|
104
|
+
* orderBy: { createdAt: "desc" },
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
* @notes
|
|
108
|
+
* * The `orderBy` clause allows you to specify the order in which to return the records. The keys must be field names of the table, and the values must be either "asc" for ascending order or "desc" for descending order.
|
|
109
|
+
* * You can specify multiple fields to order by, in which case the records will be ordered by the first field, and then by the second field in case of ties, and so on.
|
|
110
|
+
* * The fields used in the `orderBy` clause must exist on the table, attempting to order by a non-existent field will result in a TypeScript error.
|
|
111
|
+
*
|
|
112
|
+
* @typeParam TTable - The table being queried, used for type inference of orderable fields.
|
|
113
|
+
*/
|
|
114
|
+
orderBy?: OrderByExpressionOf<TTable>;
|
|
115
|
+
/**
|
|
116
|
+
* Specify that the query should return only distinct records based on the selected fields. This is useful when you want to eliminate duplicate records from the result set.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* client.findMany({
|
|
121
|
+
* where: { published: true },
|
|
122
|
+
* distinct: true,
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
* @notes
|
|
126
|
+
* * The `distinct` flag indicates that the query should return only distinct records based on the selected fields. This is useful when you want to eliminate duplicate records from the result set.
|
|
127
|
+
* * When `distinct` is true, the database will ensure that the returned records are unique based on the fields specified in the `select` clause. If no `select` clause is provided, all fields will be considered for determining uniqueness.
|
|
128
|
+
* * The `distinct` flag is typically used in conjunction with the `select` clause to specify which fields should be considered when determining uniqueness. If you want to return distinct records based on specific fields, make sure to include those fields in the `select` clause.
|
|
129
|
+
* * The behavior of the `distinct` flag may vary depending on the underlying database and how it handles distinct queries, especially when combined with joins and other query features.
|
|
130
|
+
*/
|
|
131
|
+
distinct?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Specify the maximum number of records to return and the number of records to skip. This is useful for implementing pagination in your queries.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* client.findMany({
|
|
138
|
+
* where: { published: true },
|
|
139
|
+
* limit: 10,
|
|
140
|
+
* offset: 20,
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
* @notes
|
|
144
|
+
* * The `limit` parameter specifies the maximum number of records to return. If not provided, the default limit _(100)_ will be applied.
|
|
145
|
+
* * The `offset` parameter specifies the number of records to skip before starting to return records. This is useful for implementing pagination in your queries. If not provided, no records will be skipped.
|
|
146
|
+
* * When using `limit` and `offset` together, the query will return records starting from the `offset` position up to the number specified by `limit`. For example, if `offset` is 20 and `limit` is 10, the query will return records 21 through 30.
|
|
147
|
+
*/
|
|
148
|
+
limit?: number;
|
|
149
|
+
/**
|
|
150
|
+
* The `offset` parameter specifies the number of records to skip before starting to return records. This is useful for implementing pagination in your queries. If not provided, no records will be skipped.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* client.findMany({
|
|
155
|
+
* where: { published: true },
|
|
156
|
+
* offset: 20,
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
* @notes
|
|
160
|
+
* * The `offset` parameter specifies the number of records to skip before starting to return records. This is useful for implementing pagination in your queries. If not provided, no records will be skipped.
|
|
161
|
+
* * When using `limit` and `offset` together, the query will return records starting from the `offset` position up to the number specified by `limit`. For example, if `offset` is 20 and `limit` is 10, the query will return records 21 through 30.
|
|
162
|
+
*/
|
|
163
|
+
offset?: number;
|
|
164
|
+
/**
|
|
165
|
+
* Join related records based on the relations defined in the schema. The value can be a boolean or a nested query object for more complex queries.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* client.findOne({
|
|
170
|
+
* where: { id: "123" },
|
|
171
|
+
* select: {
|
|
172
|
+
* id: true,
|
|
173
|
+
* firstName: true,
|
|
174
|
+
* },
|
|
175
|
+
* join: {
|
|
176
|
+
* posts: {
|
|
177
|
+
* where: { published: true },
|
|
178
|
+
* select: {
|
|
179
|
+
* title: true,
|
|
180
|
+
* },
|
|
181
|
+
* },
|
|
182
|
+
* profile: true,
|
|
183
|
+
* },
|
|
184
|
+
* })
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
join?: Prettify<JoinExpressionOf<TTable, TSchema>>;
|
|
188
|
+
}
|
|
189
|
+
export interface FindOneArgs<TTable extends AnyTable, TSchema extends AnySchema> extends Pick<QueryArgs<TTable, TSchema>, "select" | "join"> {
|
|
190
|
+
/**
|
|
191
|
+
* A filter expression to specify which record to retrieve. This is required for `findOne` to ensure that the operation is deterministic and does not accidentally return an unintended record.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* client.findOne({
|
|
196
|
+
* where: { id: { eq: "123" } },
|
|
197
|
+
* });
|
|
198
|
+
* ```
|
|
199
|
+
* @notes
|
|
200
|
+
* * The `where` clause is required for `findOne` to ensure that the operation is deterministic and does not accidentally return an unintended record.
|
|
201
|
+
* * The `where` clause supports various filter conditions such as equality, inequality, range queries, and more.
|
|
202
|
+
* * You can combine multiple conditions using logical operators like `and`, `or`, and `not`.
|
|
203
|
+
* * The fields used in the `where` clause must exist on the table, attempting to filter by a non-existent field will result in a TypeScript error.
|
|
204
|
+
*
|
|
205
|
+
* @typeParam TTable - The table being queried, used for type inference of filterable fields.
|
|
206
|
+
*/
|
|
207
|
+
where: WhereExpressionOf<TTable>;
|
|
208
|
+
}
|
|
209
|
+
export type RelationQueryOf<T extends AnyTable, S extends AnySchema, K extends RelationFieldNamesOf<T>> = RelationTargetOf<T, K> extends TableDefinition<infer TName, infer TCols, infer TSchema> ? RelationTypeOf<T, K> extends "has_many" ? QueryArgs<Table<TName, TCols, TSchema, SchemaTableRelations<S, TName>>, S> : Pick<QueryArgs<Table<TName, TCols, TSchema, SchemaTableRelations<S, TName>>, S>, "select" | "join"> : never;
|
|
210
|
+
export type SelectionResultOf<TTable extends AnyTable, TSchema extends AnySchema, TArgs extends QueryArgs<TTable, TSchema>> = TArgs["select"] extends FieldSelectionOf<TTable> ? {
|
|
211
|
+
[K in SelectedFieldsOf<TTable, TArgs["select"]>]: K extends FieldNamesOf<TTable> ? ValueTypeOf<ColumnTypeOf<TTable, K>> : never;
|
|
212
|
+
} : {
|
|
213
|
+
[K in FieldNamesOf<TTable>]: ValueTypeOf<ColumnTypeOf<TTable, K>>;
|
|
214
|
+
};
|
|
215
|
+
export type RelationJoinResultOf<TTable extends AnyTable, TSchema extends AnySchema, TArgs extends QueryArgs<TTable, TSchema>, TRelationField extends RelationFieldNamesOf<TTable>, TTargetName extends string, TTargetCols extends Record<string, AnyColumnDefinition>, TTargetSchema extends AnyNamespaceDefinition> = RelationTypeOf<TTable, TRelationField> extends "has_many" ? QueryResultOf<Table<TTargetName, TTargetCols, TTargetSchema, SchemaTableRelations<TSchema, TTargetName>>, TSchema, TArgs>[] : QueryResultOf<Table<TTargetName, TTargetCols, TTargetSchema, SchemaTableRelations<TSchema, TTargetName>>, TSchema, TArgs> | null;
|
|
216
|
+
export type QueryResultOf<TTable extends AnyTable, TSchema extends AnySchema, TArgs extends QueryArgs<TTable, TSchema>> = Prettify<SelectionResultOf<TTable, TSchema, TArgs> & {
|
|
217
|
+
[K in keyof TArgs["join"]]: K extends RelationFieldNamesOf<TTable> ? RelationTargetOf<TTable, K> extends TableDefinition<infer TName, infer TCols, infer TNamespace> ? TArgs["join"][K] extends QueryArgs<Table<TName, TCols, TNamespace, SchemaTableRelations<TSchema, TName>>, TSchema> ? RelationJoinResultOf<TTable, TSchema, TArgs["join"][K], K, TName, TCols, TNamespace> : TArgs["join"][K] extends boolean ? TArgs["join"][K] extends true ? RelationJoinResultOf<TTable, TSchema, QueryArgs<Table<TName, TCols, TNamespace, SchemaTableRelations<TSchema, TName>>, TSchema>, K, TName, TCols, TNamespace> : never : never : never : never;
|
|
218
|
+
}>;
|
|
219
|
+
export interface FilterCondition<Value = unknown> {
|
|
220
|
+
/**
|
|
221
|
+
* Equality condition - matches records where the field is equal to the specified value.
|
|
222
|
+
*
|
|
223
|
+
* ```sql
|
|
224
|
+
* "table"."column" = value
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
eq?: Value;
|
|
228
|
+
/**
|
|
229
|
+
* Inequality condition - matches records where the field is not equal to the specified value.
|
|
230
|
+
*
|
|
231
|
+
* ```sql
|
|
232
|
+
* "table"."column" <> value
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
neq?: Value;
|
|
236
|
+
/**
|
|
237
|
+
* Greater than condition - matches records where the field is greater than the specified value.
|
|
238
|
+
*
|
|
239
|
+
* ```sql
|
|
240
|
+
* "table"."column" > value
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
gt?: Value;
|
|
244
|
+
/**
|
|
245
|
+
* Greater than or equal condition - matches records where the field is greater than or equal to the specified value.
|
|
246
|
+
*
|
|
247
|
+
* ```sql
|
|
248
|
+
* "table"."column" >= value
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
gte?: Value;
|
|
252
|
+
/**
|
|
253
|
+
* Less than condition - matches records where the field is less than the specified value.
|
|
254
|
+
*
|
|
255
|
+
* ```sql
|
|
256
|
+
* "table"."column" < value
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
lt?: Value;
|
|
260
|
+
/**
|
|
261
|
+
* Less than or equal condition - matches records where the field is less than or equal to the specified value.
|
|
262
|
+
*
|
|
263
|
+
* ```sql
|
|
264
|
+
* "table"."column" <= value
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
lte?: Value;
|
|
268
|
+
/**
|
|
269
|
+
* In condition - matches records where the field is equal to any of the values in the specified array.
|
|
270
|
+
*
|
|
271
|
+
* ```sql
|
|
272
|
+
* "table"."column" IN (value1, value2, ...)
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
in?: Value[];
|
|
276
|
+
/**
|
|
277
|
+
* Between condition - matches records where the field is between the two specified values (inclusive).
|
|
278
|
+
*
|
|
279
|
+
* ```sql
|
|
280
|
+
* "table"."column" BETWEEN value1 AND value2
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
between?: [Value, Value];
|
|
284
|
+
/**
|
|
285
|
+
* Exists condition - matches records where the field exists (is not null).
|
|
286
|
+
*
|
|
287
|
+
* ```sql
|
|
288
|
+
* "table"."column" IS NOT NULL
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
exists?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Begins with condition - matches records where the field starts with the specified string.
|
|
294
|
+
*
|
|
295
|
+
* ```sql
|
|
296
|
+
* "table"."column" LIKE 'value%'
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
beginsWith?: string;
|
|
300
|
+
/**
|
|
301
|
+
* Ends with condition - matches records where the field ends with the specified string.
|
|
302
|
+
*
|
|
303
|
+
* ```sql
|
|
304
|
+
* "table"."column" LIKE '%value'
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
endsWith?: string;
|
|
308
|
+
/**
|
|
309
|
+
* Contains condition - matches records where the field contains the specified string.
|
|
310
|
+
*
|
|
311
|
+
* ```sql
|
|
312
|
+
* "table"."column" LIKE '%value%'
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
contains?: string;
|
|
316
|
+
}
|
|
317
|
+
export type WhereExpressionOf<T extends AnyTable> = {
|
|
318
|
+
[K in FieldNamesOf<T>]?: T["__type"]["columns"][K] extends AnyColumnDefinition ? FilterCondition<ValueTypeOf<ColumnTypeOf<T, K>>> | ValueTypeOf<ColumnTypeOf<T, K>> : never;
|
|
319
|
+
} & {
|
|
320
|
+
and?: WhereExpressionOf<T>[];
|
|
321
|
+
or?: WhereExpressionOf<T>[];
|
|
322
|
+
not?: WhereExpressionOf<T>;
|
|
323
|
+
};
|
|
324
|
+
export type OrderByExpressionOf<T extends AnyTable> = Partial<Record<FieldNamesOf<T>, "asc" | "desc">>;
|
|
325
|
+
export type JoinExpressionOf<T extends AnyTable, S extends AnySchema> = {
|
|
326
|
+
[K in RelationFieldNamesOf<T>]?: RelationQueryOf<T, S, K> | boolean | null | undefined;
|
|
327
|
+
};
|
|
328
|
+
export type AnyRelationQuery = RelationQueryOf<AnyTable, AnySchema, RelationFieldNamesOf<AnyTable>> | boolean;
|
|
329
|
+
export declare function isFilterType<T extends keyof FilterCondition>(value: unknown, type: T): value is Required<Pick<FilterCondition<SQLValue>, T>>;
|
|
330
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/client/model/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,QAAQ,IAAI,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,SAAS,MAAM,CAAC,GACvF,CAAC,SAAS,MAAM,GACd,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,mBAAmB,GACnD,CAAC,GACD,KAAK,GACP,KAAK,GACP,KAAK,CAAC;AAEV,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,QAAQ,IACjD,CAAC,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,SAAS,iBAAiB,GAC9C,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,SAAS,MAAM,CAAC,GAC5C,CAAC,SAAS,MAAM,GACd,CAAC,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,CA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ourceRoot":"","sources":["../../../src/client/model/base.ts"],"names":[],"mappings":"AA0fA,MAAM,UAAU,YAAY,CAC1B,KAAc,EACd,IAAO;IAEP,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,IAAI,IAAI,KAAK;QACb,KAAK,CAAC,IAA0B,CAAC,KAAK,SAAS,CAChD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { DefinitionSchema } from "@dsqlbase/core";
|
|
2
|
+
import { TypedObject } from "@dsqlbase/core/utils";
|
|
3
|
+
import { AnyTable, ExecutableQuery, ExecutionContext, OperationResult, Schema } from "@dsqlbase/core/runtime";
|
|
4
|
+
import { FindOneArgs, QueryArgs, CreateArgs, UpdateArgs, DeleteArgs, QueryResultOf, ReturningResultOf } from "./base.js";
|
|
5
|
+
export declare class ModelClient<TTable extends AnyTable, TDefinition extends DefinitionSchema> implements TypedObject<Schema<TDefinition>> {
|
|
6
|
+
readonly __type: Schema<TDefinition>;
|
|
7
|
+
private readonly _ctx;
|
|
8
|
+
private readonly _table;
|
|
9
|
+
private readonly _normalizer;
|
|
10
|
+
constructor(ctx: ExecutionContext<TDefinition>, table: TTable);
|
|
11
|
+
/**
|
|
12
|
+
* Finds a single record matching the specified criteria.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const user = await dsql.users.findOne({
|
|
17
|
+
* where: { id: "123" },
|
|
18
|
+
* select: { id: true, name: true },
|
|
19
|
+
* join: {
|
|
20
|
+
* profile: {
|
|
21
|
+
* select: { bio: true }
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
* @notes
|
|
27
|
+
* * The `where` clause is required to ensure that the operation is deterministic and does not accidentally return an unintended record.
|
|
28
|
+
* * The `select` clause allows you to specify which fields to retrieve, if not provided, all fields will be selected by default.
|
|
29
|
+
*
|
|
30
|
+
* @param args
|
|
31
|
+
* @returns An executable query that can be awaited.
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
findOne<TArgs extends FindOneArgs<TTable, this["__type"]>>(args: TArgs): ExecutableQuery<OperationResult<"one", QueryResultOf<TTable, this["__type"], TArgs>>>;
|
|
35
|
+
/**
|
|
36
|
+
* Finds multiple records matching the specified criteria.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const users = await dsql.users.findMany({
|
|
41
|
+
* where: { age: { gt: 18 } },
|
|
42
|
+
* orderBy: [{ age: "desc" }],
|
|
43
|
+
* limit: 10,
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
* @param args The query arguments, including filtering, ordering, pagination, and field selection options.
|
|
47
|
+
* @returns An executable query that can be awaited to retrieve the matching records.
|
|
48
|
+
*/
|
|
49
|
+
findMany<TArgs extends QueryArgs<TTable, this["__type"]>>(args: TArgs): ExecutableQuery<OperationResult<"many", QueryResultOf<TTable, this["__type"], TArgs>>>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new record in the database with the specified values.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const newUser = await dsql.users.create({
|
|
56
|
+
* data: {
|
|
57
|
+
* firstName: "John",
|
|
58
|
+
* lastName: "Doe",
|
|
59
|
+
* emailAddress: "john.doe@example.com"
|
|
60
|
+
* }
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
* @param args The arguments for creating a new record, including the data to be inserted.
|
|
64
|
+
* @returns An executable query that can be awaited to retrieve the newly created record.
|
|
65
|
+
*/
|
|
66
|
+
create<TArgs extends CreateArgs<TTable>>(args: TArgs): ExecutableQuery<OperationResult<"one", ReturningResultOf<TTable, TArgs>>>;
|
|
67
|
+
/**
|
|
68
|
+
* Updates records in the database matching the specified criteria with the provided values.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const updatedUser = await dsql.users.update({
|
|
73
|
+
* where: { id: "123" },
|
|
74
|
+
* set: { emailAddress: "new.email@example.com" }
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
* @param args The arguments for updating records, including the criteria for selecting records and the values to be updated.
|
|
78
|
+
* @returns An executable query that can be awaited to retrieve the updated record.
|
|
79
|
+
*/
|
|
80
|
+
update<TArgs extends UpdateArgs<TTable>>(args: TArgs): ExecutableQuery<OperationResult<"one", ReturningResultOf<TTable, TArgs>>>;
|
|
81
|
+
/**
|
|
82
|
+
* Deletes records from the database matching the specified criteria.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const deletedUser = await dsql.users.delete({
|
|
87
|
+
* where: { id: "123" }
|
|
88
|
+
* return: {
|
|
89
|
+
* id: true,
|
|
90
|
+
* name: true
|
|
91
|
+
* }
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
* @notes
|
|
95
|
+
* * The `where` clause is required to ensure that the operation is deterministic and does not accidentally delete unintended records.
|
|
96
|
+
*
|
|
97
|
+
* @param args The arguments for deleting records, including the criteria for selecting records to delete.
|
|
98
|
+
* @returns An executable query that can be awaited to retrieve the deleted record.
|
|
99
|
+
*/
|
|
100
|
+
delete<TArgs extends DeleteArgs<TTable>>(args: TArgs): ExecutableQuery<OperationResult<"one", ReturningResultOf<TTable, TArgs>>>;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client/model/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EACL,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,MAAM,EACP,MAAM,wBAAwB,CAAC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C;IAO5E;;;;;;;;;;;;OAYG;IAEI,MAAM,CAAC,KAAK,SAAS,UAAU,CAAC,MAAM,CAAC,EAC5C,IAAI,EAAE,KAAK,GACV,eAAe,CAAC,eAAe,CAAC,KAAK,EAAE,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAO5E;;;;;;;;;;;;;;;;;;OAkBG;IAEI,MAAM,CAAC,KAAK,SAAS,UAAU,CAAC,MAAM,CAAC,EAC5C,IAAI,EAAE,KAAK,GACV,eAAe,CAAC,eAAe,CAAC,KAAK,EAAE,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;CAM7E"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ExecutableQuery, } from "@dsqlbase/core/runtime";
|
|
2
|
+
import { RequestNormalizer } from "./normalizer.js";
|
|
3
|
+
export class ModelClient {
|
|
4
|
+
_ctx;
|
|
5
|
+
_table;
|
|
6
|
+
_normalizer;
|
|
7
|
+
constructor(ctx, table) {
|
|
8
|
+
this._ctx = ctx;
|
|
9
|
+
this._table = table;
|
|
10
|
+
this._normalizer = new RequestNormalizer(ctx);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Finds a single record matching the specified criteria.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const user = await dsql.users.findOne({
|
|
18
|
+
* where: { id: "123" },
|
|
19
|
+
* select: { id: true, name: true },
|
|
20
|
+
* join: {
|
|
21
|
+
* profile: {
|
|
22
|
+
* select: { bio: true }
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
* @notes
|
|
28
|
+
* * The `where` clause is required to ensure that the operation is deterministic and does not accidentally return an unintended record.
|
|
29
|
+
* * The `select` clause allows you to specify which fields to retrieve, if not provided, all fields will be selected by default.
|
|
30
|
+
*
|
|
31
|
+
* @param args
|
|
32
|
+
* @returns An executable query that can be awaited.
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
findOne(args) {
|
|
36
|
+
const request = this._normalizer.normalizeSelect(this._table, args, "one");
|
|
37
|
+
const operation = this._ctx.operations.createSelectOperation(this._table, request);
|
|
38
|
+
return new ExecutableQuery(operation, this._ctx.session);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Finds multiple records matching the specified criteria.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const users = await dsql.users.findMany({
|
|
46
|
+
* where: { age: { gt: 18 } },
|
|
47
|
+
* orderBy: [{ age: "desc" }],
|
|
48
|
+
* limit: 10,
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
* @param args The query arguments, including filtering, ordering, pagination, and field selection options.
|
|
52
|
+
* @returns An executable query that can be awaited to retrieve the matching records.
|
|
53
|
+
*/
|
|
54
|
+
findMany(args) {
|
|
55
|
+
const request = this._normalizer.normalizeSelect(this._table, args, "many");
|
|
56
|
+
const operation = this._ctx.operations.createSelectOperation(this._table, request);
|
|
57
|
+
return new ExecutableQuery(operation, this._ctx.session);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new record in the database with the specified values.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const newUser = await dsql.users.create({
|
|
65
|
+
* data: {
|
|
66
|
+
* firstName: "John",
|
|
67
|
+
* lastName: "Doe",
|
|
68
|
+
* emailAddress: "john.doe@example.com"
|
|
69
|
+
* }
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
* @param args The arguments for creating a new record, including the data to be inserted.
|
|
73
|
+
* @returns An executable query that can be awaited to retrieve the newly created record.
|
|
74
|
+
*/
|
|
75
|
+
create(args) {
|
|
76
|
+
const request = this._normalizer.normalizeInsert(this._table, args, "one");
|
|
77
|
+
const operation = this._ctx.operations.createInsertOperation(this._table, request);
|
|
78
|
+
return new ExecutableQuery(operation, this._ctx.session);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Updates records in the database matching the specified criteria with the provided values.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const updatedUser = await dsql.users.update({
|
|
86
|
+
* where: { id: "123" },
|
|
87
|
+
* set: { emailAddress: "new.email@example.com" }
|
|
88
|
+
* });
|
|
89
|
+
* ```
|
|
90
|
+
* @param args The arguments for updating records, including the criteria for selecting records and the values to be updated.
|
|
91
|
+
* @returns An executable query that can be awaited to retrieve the updated record.
|
|
92
|
+
*/
|
|
93
|
+
update(args) {
|
|
94
|
+
const request = this._normalizer.normalizeUpdate(this._table, args, "one");
|
|
95
|
+
const operation = this._ctx.operations.createUpdateOperation(this._table, request);
|
|
96
|
+
return new ExecutableQuery(operation, this._ctx.session);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Deletes records from the database matching the specified criteria.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const deletedUser = await dsql.users.delete({
|
|
104
|
+
* where: { id: "123" }
|
|
105
|
+
* return: {
|
|
106
|
+
* id: true,
|
|
107
|
+
* name: true
|
|
108
|
+
* }
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
* @notes
|
|
112
|
+
* * The `where` clause is required to ensure that the operation is deterministic and does not accidentally delete unintended records.
|
|
113
|
+
*
|
|
114
|
+
* @param args The arguments for deleting records, including the criteria for selecting records to delete.
|
|
115
|
+
* @returns An executable query that can be awaited to retrieve the deleted record.
|
|
116
|
+
*/
|
|
117
|
+
delete(args) {
|
|
118
|
+
const request = this._normalizer.normalizeDelete(this._table, args, "one");
|
|
119
|
+
const operation = this._ctx.operations.createDeleteOperation(this._table, request);
|
|
120
|
+
return new ExecutableQuery(operation, this._ctx.session);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=client.js.map
|
|
@@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utils";
|
|
2
|
+
import { AnyTable, DefinitionSchema, DeleteOperationArgs, ExecutionContext, InsertOperationArgs, OperationMode, OperationRequest, Schema, SelectOperationArgs, UpdateOperationArgs } from "@dsqlbase/core";
|
|
3
|
+
import { CreateArgs, DeleteArgs, QueryArgs, UpdateArgs } from "./base.js";
|
|
4
|
+
export declare class RequestNormalizer<TDefinition extends DefinitionSchema> implements TypedObject<Schema<TDefinition>> {
|
|
5
|
+
readonly __type: Schema<TDefinition>;
|
|
6
|
+
private readonly _ctx;
|
|
7
|
+
constructor(context: ExecutionContext);
|
|
8
|
+
private _getWhereExpression;
|
|
9
|
+
private _getSelectionEntries;
|
|
10
|
+
private _getOrderByEntries;
|
|
11
|
+
private _getJoinEntries;
|
|
12
|
+
private _getMutationEntries;
|
|
13
|
+
private _getSelectArgs;
|
|
14
|
+
normalizeSelect<TTable extends AnyTable, TArgs extends QueryArgs<TTable, this["__type"]>, TMode extends OperationMode>(table: TTable, args: TArgs, mode: TMode): OperationRequest<SelectOperationArgs, TMode>;
|
|
15
|
+
normalizeInsert<TTable extends AnyTable, TArgs extends CreateArgs<TTable>, TMode extends OperationMode>(table: TTable, args: TArgs, mode: TMode): OperationRequest<InsertOperationArgs, TMode>;
|
|
16
|
+
normalizeUpdate<TTable extends AnyTable, TArgs extends UpdateArgs<TTable>, TMode extends OperationMode>(table: TTable, args: TArgs, mode: TMode): OperationRequest<UpdateOperationArgs, TMode>;
|
|
17
|
+
normalizeDelete<TTable extends AnyTable, TArgs extends DeleteArgs<TTable>, TMode extends OperationMode>(table: TTable, args: TArgs, mode: TMode): OperationRequest<DeleteOperationArgs, TMode>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=normalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../../src/client/model/normalizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACn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