@expo/entity-database-adapter-knex 0.59.0 → 0.61.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.
- package/build/src/AuthorizationResultBasedKnexEntityLoader.d.ts +8 -9
- package/build/src/AuthorizationResultBasedKnexEntityLoader.js +5 -11
- package/build/src/BasePostgresEntityDatabaseAdapter.d.ts +4 -3
- package/build/src/BasePostgresEntityDatabaseAdapter.js +13 -19
- package/build/src/BaseSQLQueryBuilder.d.ts +4 -3
- package/build/src/BaseSQLQueryBuilder.js +4 -9
- package/build/src/EnforcingKnexEntityLoader.d.ts +7 -7
- package/build/src/EnforcingKnexEntityLoader.js +4 -10
- package/build/src/EntityFields.js +4 -11
- package/build/src/KnexEntityLoaderFactory.d.ts +4 -4
- package/build/src/KnexEntityLoaderFactory.js +8 -13
- package/build/src/PaginationStrategy.js +2 -6
- package/build/src/PostgresEntity.d.ts +4 -3
- package/build/src/PostgresEntity.js +5 -10
- package/build/src/PostgresEntityDatabaseAdapter.d.ts +6 -5
- package/build/src/PostgresEntityDatabaseAdapter.js +19 -24
- package/build/src/PostgresEntityDatabaseAdapterProvider.d.ts +1 -1
- package/build/src/PostgresEntityDatabaseAdapterProvider.js +3 -8
- package/build/src/PostgresEntityQueryContextProvider.d.ts +3 -2
- package/build/src/PostgresEntityQueryContextProvider.js +5 -10
- package/build/src/ReadonlyPostgresEntity.d.ts +4 -3
- package/build/src/ReadonlyPostgresEntity.js +5 -10
- package/build/src/SQLOperator.d.ts +324 -56
- package/build/src/SQLOperator.js +490 -150
- package/build/src/errors/wrapNativePostgresCallAsync.js +11 -15
- package/build/src/index.d.ts +20 -20
- package/build/src/index.js +20 -37
- package/build/src/internal/EntityKnexDataManager.d.ts +5 -5
- package/build/src/internal/EntityKnexDataManager.js +76 -84
- package/build/src/internal/getKnexDataManager.d.ts +2 -2
- package/build/src/internal/getKnexDataManager.js +7 -14
- package/build/src/internal/getKnexEntityLoaderFactory.d.ts +2 -2
- package/build/src/internal/getKnexEntityLoaderFactory.js +5 -9
- package/build/src/internal/utilityTypes.js +1 -3
- package/build/src/internal/weakMaps.js +1 -6
- package/build/src/knexLoader.d.ts +3 -3
- package/build/src/knexLoader.js +5 -10
- package/package.json +7 -6
- package/src/AuthorizationResultBasedKnexEntityLoader.ts +15 -12
- package/src/BasePostgresEntityDatabaseAdapter.ts +3 -3
- package/src/BaseSQLQueryBuilder.ts +5 -4
- package/src/EnforcingKnexEntityLoader.ts +8 -8
- package/src/KnexEntityLoaderFactory.ts +6 -6
- package/src/PostgresEntity.ts +5 -5
- package/src/PostgresEntityDatabaseAdapter.ts +13 -15
- package/src/PostgresEntityDatabaseAdapterProvider.ts +2 -2
- package/src/PostgresEntityQueryContextProvider.ts +3 -6
- package/src/ReadonlyPostgresEntity.ts +5 -5
- package/src/SQLOperator.ts +875 -194
- package/src/__integration-tests__/EntityCreationUtils-test.ts +5 -4
- package/src/__integration-tests__/PostgresEntityIntegration-test.ts +42 -15
- package/src/__integration-tests__/PostgresEntityQueryContextProvider-test.ts +6 -5
- package/src/__integration-tests__/PostgresInvalidSetup-test.ts +5 -4
- package/src/__integration-tests__/errors-test.ts +5 -4
- package/src/__testfixtures__/ErrorsTestEntity.ts +2 -3
- package/src/__testfixtures__/InvalidTestEntity.ts +2 -3
- package/src/__testfixtures__/PostgresTestEntity.ts +5 -6
- package/src/__testfixtures__/PostgresTriggerTestEntity.ts +7 -5
- package/src/__testfixtures__/PostgresUniqueTestEntity.ts +6 -4
- package/src/__testfixtures__/PostgresValidatorTestEntity.ts +7 -5
- package/src/__testfixtures__/createKnexIntegrationTestEntityCompanionProvider.ts +5 -8
- package/src/__tests__/AuthorizationResultBasedKnexEntityLoader-test.ts +12 -14
- package/src/__tests__/BasePostgresEntityDatabaseAdapter-test.ts +7 -5
- package/src/__tests__/EnforcingKnexEntityLoader-test.ts +7 -6
- package/src/__tests__/EntityFields-test.ts +1 -1
- package/src/__tests__/PostgresEntity-test.ts +6 -6
- package/src/__tests__/ReadonlyEntity-test.ts +5 -5
- package/src/__tests__/SQLOperator-test.ts +675 -95
- package/src/__tests__/fixtures/StubPostgresDatabaseAdapter.ts +9 -8
- package/src/__tests__/fixtures/StubPostgresDatabaseAdapterProvider.ts +2 -2
- package/src/__tests__/fixtures/TestEntity.ts +7 -7
- package/src/__tests__/fixtures/TestPaginationEntity.ts +9 -7
- package/src/__tests__/fixtures/createUnitTestPostgresEntityCompanionProvider.ts +3 -6
- package/src/errors/__tests__/wrapNativePostgresCallAsync-test.ts +1 -1
- package/src/errors/wrapNativePostgresCallAsync.ts +2 -2
- package/src/index.ts +20 -20
- package/src/internal/EntityKnexDataManager.ts +14 -17
- package/src/internal/__tests__/EntityKnexDataManager-test.ts +8 -15
- package/src/internal/__tests__/weakMaps-test.ts +1 -1
- package/src/internal/getKnexDataManager.ts +4 -4
- package/src/internal/getKnexEntityLoaderFactory.ts +4 -4
- package/src/knexLoader.ts +4 -4
- package/build/src/AuthorizationResultBasedKnexEntityLoader.js.map +0 -1
- package/build/src/BasePostgresEntityDatabaseAdapter.js.map +0 -1
- package/build/src/BaseSQLQueryBuilder.js.map +0 -1
- package/build/src/EnforcingKnexEntityLoader.js.map +0 -1
- package/build/src/EntityFields.js.map +0 -1
- package/build/src/KnexEntityLoaderFactory.js.map +0 -1
- package/build/src/PaginationStrategy.js.map +0 -1
- package/build/src/PostgresEntity.js.map +0 -1
- package/build/src/PostgresEntityDatabaseAdapter.js.map +0 -1
- package/build/src/PostgresEntityDatabaseAdapterProvider.js.map +0 -1
- package/build/src/PostgresEntityQueryContextProvider.js.map +0 -1
- package/build/src/ReadonlyPostgresEntity.js.map +0 -1
- package/build/src/SQLOperator.js.map +0 -1
- package/build/src/errors/wrapNativePostgresCallAsync.js.map +0 -1
- package/build/src/index.js.map +0 -1
- package/build/src/internal/EntityKnexDataManager.js.map +0 -1
- package/build/src/internal/getKnexDataManager.js.map +0 -1
- package/build/src/internal/getKnexEntityLoaderFactory.js.map +0 -1
- package/build/src/internal/utilityTypes.js.map +0 -1
- package/build/src/internal/weakMaps.js.map +0 -1
- package/build/src/knexLoader.js.map +0 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { EntityConstructionUtils, EntityPrivacyPolicy, EntityQueryContext, ReadonlyEntity, ViewerContext
|
|
2
|
-
import { Result } from '@expo/results';
|
|
3
|
-
import { FieldEqualityCondition, NullsOrdering, OrderByOrdering } from './BasePostgresEntityDatabaseAdapter';
|
|
4
|
-
import { BaseSQLQueryBuilder } from './BaseSQLQueryBuilder';
|
|
5
|
-
import { PaginationStrategy } from './PaginationStrategy';
|
|
6
|
-
import { SQLFragment } from './SQLOperator';
|
|
7
|
-
import type { Connection } from './internal/EntityKnexDataManager';
|
|
8
|
-
import {
|
|
9
|
-
import { NonNullableKeys } from './internal/utilityTypes';
|
|
1
|
+
import type { EntityConstructionUtils, EntityPrivacyPolicy, EntityQueryContext, IEntityMetricsAdapter, ReadonlyEntity, ViewerContext } from '@expo/entity';
|
|
2
|
+
import type { Result } from '@expo/results';
|
|
3
|
+
import type { FieldEqualityCondition, NullsOrdering, OrderByOrdering } from './BasePostgresEntityDatabaseAdapter.ts';
|
|
4
|
+
import { BaseSQLQueryBuilder } from './BaseSQLQueryBuilder.ts';
|
|
5
|
+
import type { PaginationStrategy } from './PaginationStrategy.ts';
|
|
6
|
+
import type { SQLFragment } from './SQLOperator.ts';
|
|
7
|
+
import type { Connection, EntityKnexDataManager } from './internal/EntityKnexDataManager.ts';
|
|
8
|
+
import type { NonNullableKeys } from './internal/utilityTypes.ts';
|
|
10
9
|
export type EntityLoaderBaseOrderByClause = {
|
|
11
10
|
/**
|
|
12
11
|
* The OrderByOrdering to order by.
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.AuthorizationResultBasedSQLQueryBuilder = exports.AuthorizationResultBasedKnexEntityLoader = void 0;
|
|
4
|
-
const BasePostgresEntityDatabaseAdapter_1 = require("./BasePostgresEntityDatabaseAdapter");
|
|
5
|
-
const BaseSQLQueryBuilder_1 = require("./BaseSQLQueryBuilder");
|
|
1
|
+
import { isSingleValueFieldEqualityCondition } from "./BasePostgresEntityDatabaseAdapter.js";
|
|
2
|
+
import { BaseSQLQueryBuilder } from "./BaseSQLQueryBuilder.js";
|
|
6
3
|
/**
|
|
7
4
|
* Authorization-result-based knex entity loader for non-data-loader-based load methods.
|
|
8
5
|
* All loads through this loader are results (or null for some loader methods), where an
|
|
9
6
|
* unsuccessful result means an authorization error or entity construction error occurred.
|
|
10
7
|
* Other errors are thrown.
|
|
11
8
|
*/
|
|
12
|
-
class AuthorizationResultBasedKnexEntityLoader {
|
|
9
|
+
export class AuthorizationResultBasedKnexEntityLoader {
|
|
13
10
|
queryContext;
|
|
14
11
|
knexDataManager;
|
|
15
12
|
metricsAdapter;
|
|
@@ -38,7 +35,7 @@ class AuthorizationResultBasedKnexEntityLoader {
|
|
|
38
35
|
*/
|
|
39
36
|
async loadManyByFieldEqualityConjunctionAsync(fieldEqualityOperands, querySelectionModifiers = {}) {
|
|
40
37
|
for (const fieldEqualityOperand of fieldEqualityOperands) {
|
|
41
|
-
const fieldValues =
|
|
38
|
+
const fieldValues = isSingleValueFieldEqualityCondition(fieldEqualityOperand)
|
|
42
39
|
? [fieldEqualityOperand.fieldValue]
|
|
43
40
|
: fieldEqualityOperand.fieldValues;
|
|
44
41
|
this.constructionUtils.validateFieldAndValues(fieldEqualityOperand.fieldName, fieldValues);
|
|
@@ -101,11 +98,10 @@ class AuthorizationResultBasedKnexEntityLoader {
|
|
|
101
98
|
return this.knexDataManager.getCursorForEntityID(entity.getID());
|
|
102
99
|
}
|
|
103
100
|
}
|
|
104
|
-
exports.AuthorizationResultBasedKnexEntityLoader = AuthorizationResultBasedKnexEntityLoader;
|
|
105
101
|
/**
|
|
106
102
|
* SQL query builder implementation for AuthorizationResultBasedKnexEntityLoader.
|
|
107
103
|
*/
|
|
108
|
-
class AuthorizationResultBasedSQLQueryBuilder extends
|
|
104
|
+
export class AuthorizationResultBasedSQLQueryBuilder extends BaseSQLQueryBuilder {
|
|
109
105
|
knexDataManager;
|
|
110
106
|
constructionUtils;
|
|
111
107
|
queryContext;
|
|
@@ -123,5 +119,3 @@ class AuthorizationResultBasedSQLQueryBuilder extends BaseSQLQueryBuilder_1.Base
|
|
|
123
119
|
return await this.constructionUtils.constructAndAuthorizeEntitiesArrayAsync(fieldObjects);
|
|
124
120
|
}
|
|
125
121
|
}
|
|
126
|
-
exports.AuthorizationResultBasedSQLQueryBuilder = AuthorizationResultBasedSQLQueryBuilder;
|
|
127
|
-
//# sourceMappingURL=AuthorizationResultBasedKnexEntityLoader.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { EntityQueryContext } from '@expo/entity';
|
|
2
|
+
import { EntityDatabaseAdapter } from '@expo/entity';
|
|
3
|
+
import type { Knex } from 'knex';
|
|
4
|
+
import type { SQLFragment } from './SQLOperator.ts';
|
|
4
5
|
/**
|
|
5
6
|
* Equality operand that is used for selecting entities with a field with a single value.
|
|
6
7
|
*/
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.BasePostgresEntityDatabaseAdapter = exports.OrderByOrdering = exports.NullsOrdering = void 0;
|
|
4
|
-
exports.isSingleValueFieldEqualityCondition = isSingleValueFieldEqualityCondition;
|
|
5
|
-
const entity_1 = require("@expo/entity");
|
|
6
|
-
function isSingleValueFieldEqualityCondition(condition) {
|
|
1
|
+
import { EntityDatabaseAdapter, getDatabaseFieldForEntityField, transformDatabaseObjectToFields, } from '@expo/entity';
|
|
2
|
+
export function isSingleValueFieldEqualityCondition(condition) {
|
|
7
3
|
return condition.fieldValue !== undefined;
|
|
8
4
|
}
|
|
9
|
-
var NullsOrdering;
|
|
5
|
+
export var NullsOrdering;
|
|
10
6
|
(function (NullsOrdering) {
|
|
11
7
|
NullsOrdering["FIRST"] = "first";
|
|
12
8
|
NullsOrdering["LAST"] = "last";
|
|
13
|
-
})(NullsOrdering || (
|
|
9
|
+
})(NullsOrdering || (NullsOrdering = {}));
|
|
14
10
|
/**
|
|
15
11
|
* Ordering options for `orderBy` clauses.
|
|
16
12
|
*/
|
|
17
|
-
var OrderByOrdering;
|
|
13
|
+
export var OrderByOrdering;
|
|
18
14
|
(function (OrderByOrdering) {
|
|
19
15
|
/**
|
|
20
16
|
* Ascending order (lowest to highest).
|
|
@@ -26,8 +22,8 @@ var OrderByOrdering;
|
|
|
26
22
|
* Descending order puts larger values first, where "larger" is defined in terms of the %3E operator.
|
|
27
23
|
*/
|
|
28
24
|
OrderByOrdering["DESCENDING"] = "desc";
|
|
29
|
-
})(OrderByOrdering || (
|
|
30
|
-
class BasePostgresEntityDatabaseAdapter extends
|
|
25
|
+
})(OrderByOrdering || (OrderByOrdering = {}));
|
|
26
|
+
export class BasePostgresEntityDatabaseAdapter extends EntityDatabaseAdapter {
|
|
31
27
|
/**
|
|
32
28
|
* Get the maximum page size for pagination.
|
|
33
29
|
* @returns maximum page size if configured, undefined otherwise
|
|
@@ -50,19 +46,19 @@ class BasePostgresEntityDatabaseAdapter extends entity_1.EntityDatabaseAdapter {
|
|
|
50
46
|
for (const operand of fieldEqualityOperands) {
|
|
51
47
|
if (isSingleValueFieldEqualityCondition(operand)) {
|
|
52
48
|
tableFieldSingleValueOperands.push({
|
|
53
|
-
tableField:
|
|
49
|
+
tableField: getDatabaseFieldForEntityField(this.entityConfiguration, operand.fieldName),
|
|
54
50
|
tableValue: operand.fieldValue,
|
|
55
51
|
});
|
|
56
52
|
}
|
|
57
53
|
else {
|
|
58
54
|
tableFieldMultipleValueOperands.push({
|
|
59
|
-
tableField:
|
|
55
|
+
tableField: getDatabaseFieldForEntityField(this.entityConfiguration, operand.fieldName),
|
|
60
56
|
tableValues: operand.fieldValues,
|
|
61
57
|
});
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
const results = await this.fetchManyByFieldEqualityConjunctionInternalAsync(queryContext.getQueryInterface(), this.entityConfiguration.tableName, tableFieldSingleValueOperands, tableFieldMultipleValueOperands, this.convertToTableQueryModifiers(querySelectionModifiers));
|
|
65
|
-
return results.map((result) =>
|
|
61
|
+
return results.map((result) => transformDatabaseObjectToFields(this.entityConfiguration, this.fieldTransformerMap, result));
|
|
66
62
|
}
|
|
67
63
|
/**
|
|
68
64
|
* Fetch many objects matching the raw WHERE clause.
|
|
@@ -75,7 +71,7 @@ class BasePostgresEntityDatabaseAdapter extends entity_1.EntityDatabaseAdapter {
|
|
|
75
71
|
*/
|
|
76
72
|
async fetchManyByRawWhereClauseAsync(queryContext, rawWhereClause, bindings, querySelectionModifiers) {
|
|
77
73
|
const results = await this.fetchManyByRawWhereClauseInternalAsync(queryContext.getQueryInterface(), this.entityConfiguration.tableName, rawWhereClause, bindings, this.convertToTableQueryModifiers(querySelectionModifiers));
|
|
78
|
-
return results.map((result) =>
|
|
74
|
+
return results.map((result) => transformDatabaseObjectToFields(this.entityConfiguration, this.fieldTransformerMap, result));
|
|
79
75
|
}
|
|
80
76
|
/**
|
|
81
77
|
* Fetch many objects matching the SQL fragment.
|
|
@@ -87,7 +83,7 @@ class BasePostgresEntityDatabaseAdapter extends entity_1.EntityDatabaseAdapter {
|
|
|
87
83
|
*/
|
|
88
84
|
async fetchManyBySQLFragmentAsync(queryContext, sqlFragment, querySelectionModifiers) {
|
|
89
85
|
const results = await this.fetchManyBySQLFragmentInternalAsync(queryContext.getQueryInterface(), this.entityConfiguration.tableName, sqlFragment, this.convertToTableQueryModifiers(querySelectionModifiers));
|
|
90
|
-
return results.map((result) =>
|
|
86
|
+
return results.map((result) => transformDatabaseObjectToFields(this.entityConfiguration, this.fieldTransformerMap, result));
|
|
91
87
|
}
|
|
92
88
|
convertToTableQueryModifiers(querySelectionModifiers) {
|
|
93
89
|
const orderBy = querySelectionModifiers.orderBy;
|
|
@@ -96,7 +92,7 @@ class BasePostgresEntityDatabaseAdapter extends entity_1.EntityDatabaseAdapter {
|
|
|
96
92
|
? orderBy.map((orderBySpecification) => {
|
|
97
93
|
if ('fieldName' in orderBySpecification) {
|
|
98
94
|
return {
|
|
99
|
-
columnName:
|
|
95
|
+
columnName: getDatabaseFieldForEntityField(this.entityConfiguration, orderBySpecification.fieldName),
|
|
100
96
|
order: orderBySpecification.order,
|
|
101
97
|
nulls: orderBySpecification.nulls,
|
|
102
98
|
};
|
|
@@ -115,5 +111,3 @@ class BasePostgresEntityDatabaseAdapter extends entity_1.EntityDatabaseAdapter {
|
|
|
115
111
|
};
|
|
116
112
|
}
|
|
117
113
|
}
|
|
118
|
-
exports.BasePostgresEntityDatabaseAdapter = BasePostgresEntityDatabaseAdapter;
|
|
119
|
-
//# sourceMappingURL=BasePostgresEntityDatabaseAdapter.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EntityLoaderOrderByClause, EntityLoaderQuerySelectionModifiers } from './AuthorizationResultBasedKnexEntityLoader';
|
|
2
|
-
import { NullsOrdering
|
|
3
|
-
import {
|
|
1
|
+
import type { EntityLoaderOrderByClause, EntityLoaderQuerySelectionModifiers } from './AuthorizationResultBasedKnexEntityLoader.ts';
|
|
2
|
+
import type { NullsOrdering } from './BasePostgresEntityDatabaseAdapter.ts';
|
|
3
|
+
import { OrderByOrdering } from './BasePostgresEntityDatabaseAdapter.ts';
|
|
4
|
+
import type { SQLFragment } from './SQLOperator.ts';
|
|
4
5
|
/**
|
|
5
6
|
* Base SQL query builder that provides common functionality for building SQL queries.
|
|
6
7
|
*/
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseSQLQueryBuilder = void 0;
|
|
4
|
-
const BasePostgresEntityDatabaseAdapter_1 = require("./BasePostgresEntityDatabaseAdapter");
|
|
1
|
+
import { OrderByOrdering } from "./BasePostgresEntityDatabaseAdapter.js";
|
|
5
2
|
/**
|
|
6
3
|
* Base SQL query builder that provides common functionality for building SQL queries.
|
|
7
4
|
*/
|
|
8
|
-
class BaseSQLQueryBuilder {
|
|
5
|
+
export class BaseSQLQueryBuilder {
|
|
9
6
|
sqlFragment;
|
|
10
7
|
modifiers;
|
|
11
8
|
executed = false;
|
|
@@ -30,7 +27,7 @@ class BaseSQLQueryBuilder {
|
|
|
30
27
|
/**
|
|
31
28
|
* Order by a field. Can be called multiple times to add multiple order bys.
|
|
32
29
|
*/
|
|
33
|
-
orderBy(fieldName, order =
|
|
30
|
+
orderBy(fieldName, order = OrderByOrdering.ASCENDING, nulls = undefined) {
|
|
34
31
|
this.modifiers.orderBy = [...(this.modifiers.orderBy ?? []), { fieldName, order, nulls }];
|
|
35
32
|
return this;
|
|
36
33
|
}
|
|
@@ -52,7 +49,7 @@ class BaseSQLQueryBuilder {
|
|
|
52
49
|
* @param fragment - The SQL fragment to order by. Must not include the ASC/DESC keyword, as ordering direction is determined by the `order` parameter.
|
|
53
50
|
* @param order - The ordering direction (ascending or descending). Defaults to ascending.
|
|
54
51
|
*/
|
|
55
|
-
orderBySQL(fragment, order =
|
|
52
|
+
orderBySQL(fragment, order = OrderByOrdering.ASCENDING, nulls = undefined) {
|
|
56
53
|
this.modifiers.orderBy = [
|
|
57
54
|
...(this.modifiers.orderBy ?? []),
|
|
58
55
|
{ fieldFragment: fragment, order, nulls },
|
|
@@ -83,5 +80,3 @@ class BaseSQLQueryBuilder {
|
|
|
83
80
|
return await this.executeInternalAsync();
|
|
84
81
|
}
|
|
85
82
|
}
|
|
86
|
-
exports.BaseSQLQueryBuilder = BaseSQLQueryBuilder;
|
|
87
|
-
//# sourceMappingURL=BaseSQLQueryBuilder.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { EntityConstructionUtils, EntityPrivacyPolicy, EntityQueryContext, IEntityMetricsAdapter, ReadonlyEntity, ViewerContext } from '@expo/entity';
|
|
2
|
-
import { AuthorizationResultBasedKnexEntityLoader, EntityLoaderLoadPageArgs, EntityLoaderQuerySelectionModifiers } from './AuthorizationResultBasedKnexEntityLoader';
|
|
3
|
-
import { FieldEqualityCondition } from './BasePostgresEntityDatabaseAdapter';
|
|
4
|
-
import { BaseSQLQueryBuilder } from './BaseSQLQueryBuilder';
|
|
5
|
-
import { SQLFragment } from './SQLOperator';
|
|
6
|
-
import type { Connection, EntityKnexDataManager } from './internal/EntityKnexDataManager';
|
|
1
|
+
import type { EntityConstructionUtils, EntityPrivacyPolicy, EntityQueryContext, IEntityMetricsAdapter, ReadonlyEntity, ViewerContext } from '@expo/entity';
|
|
2
|
+
import type { AuthorizationResultBasedKnexEntityLoader, EntityLoaderLoadPageArgs, EntityLoaderQuerySelectionModifiers } from './AuthorizationResultBasedKnexEntityLoader.ts';
|
|
3
|
+
import type { FieldEqualityCondition } from './BasePostgresEntityDatabaseAdapter.ts';
|
|
4
|
+
import { BaseSQLQueryBuilder } from './BaseSQLQueryBuilder.ts';
|
|
5
|
+
import type { SQLFragment } from './SQLOperator.ts';
|
|
6
|
+
import type { Connection, EntityKnexDataManager } from './internal/EntityKnexDataManager.ts';
|
|
7
7
|
/**
|
|
8
8
|
* Enforcing knex entity loader for non-data-loader-based load methods.
|
|
9
9
|
* All loads through this loader will throw if the load is not successful.
|
|
@@ -81,7 +81,7 @@ export declare class EnforcingKnexEntityLoader<TFields extends Record<string, an
|
|
|
81
81
|
* .limit(10)
|
|
82
82
|
* .executeAsync();
|
|
83
83
|
*
|
|
84
|
-
* const { between, inArray } =
|
|
84
|
+
* const { between, inArray } = SQLExpression;
|
|
85
85
|
* const filtered = await ExampleEntity.loader(vc)
|
|
86
86
|
* .loadManyBySQL(
|
|
87
87
|
* sql`${between('age', 18, 65)} AND ${inArray('role', ['admin', 'moderator'])}`
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EnforcingSQLQueryBuilder = exports.EnforcingKnexEntityLoader = void 0;
|
|
4
|
-
const BaseSQLQueryBuilder_1 = require("./BaseSQLQueryBuilder");
|
|
1
|
+
import { BaseSQLQueryBuilder } from "./BaseSQLQueryBuilder.js";
|
|
5
2
|
/**
|
|
6
3
|
* Enforcing knex entity loader for non-data-loader-based load methods.
|
|
7
4
|
* All loads through this loader will throw if the load is not successful.
|
|
8
5
|
*/
|
|
9
|
-
class EnforcingKnexEntityLoader {
|
|
6
|
+
export class EnforcingKnexEntityLoader {
|
|
10
7
|
knexEntityLoader;
|
|
11
8
|
queryContext;
|
|
12
9
|
knexDataManager;
|
|
@@ -94,7 +91,7 @@ class EnforcingKnexEntityLoader {
|
|
|
94
91
|
* .limit(10)
|
|
95
92
|
* .executeAsync();
|
|
96
93
|
*
|
|
97
|
-
* const { between, inArray } =
|
|
94
|
+
* const { between, inArray } = SQLExpression;
|
|
98
95
|
* const filtered = await ExampleEntity.loader(vc)
|
|
99
96
|
* .loadManyBySQL(
|
|
100
97
|
* sql`${between('age', 18, 65)} AND ${inArray('role', ['admin', 'moderator'])}`
|
|
@@ -139,12 +136,11 @@ class EnforcingKnexEntityLoader {
|
|
|
139
136
|
return this.knexEntityLoader.getPaginationCursorForEntity(entity);
|
|
140
137
|
}
|
|
141
138
|
}
|
|
142
|
-
exports.EnforcingKnexEntityLoader = EnforcingKnexEntityLoader;
|
|
143
139
|
/**
|
|
144
140
|
* SQL query builder for EnforcingKnexEntityLoader.
|
|
145
141
|
* Provides a fluent API for building and executing SQL queries with enforced authorization.
|
|
146
142
|
*/
|
|
147
|
-
class EnforcingSQLQueryBuilder extends
|
|
143
|
+
export class EnforcingSQLQueryBuilder extends BaseSQLQueryBuilder {
|
|
148
144
|
knexEntityLoader;
|
|
149
145
|
constructor(knexEntityLoader, sqlFragment, modifiers) {
|
|
150
146
|
super(sqlFragment, modifiers);
|
|
@@ -162,5 +158,3 @@ class EnforcingSQLQueryBuilder extends BaseSQLQueryBuilder_1.BaseSQLQueryBuilder
|
|
|
162
158
|
return entityResults.map((result) => result.enforceValue());
|
|
163
159
|
}
|
|
164
160
|
}
|
|
165
|
-
exports.EnforcingSQLQueryBuilder = EnforcingSQLQueryBuilder;
|
|
166
|
-
//# sourceMappingURL=EnforcingKnexEntityLoader.js.map
|
|
@@ -1,33 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BigIntField = exports.MaybeJSONArrayField = exports.JSONArrayField = void 0;
|
|
4
|
-
const entity_1 = require("@expo/entity");
|
|
1
|
+
import { EntityFieldDefinition } from '@expo/entity';
|
|
5
2
|
/**
|
|
6
3
|
* EntityFieldDefinition for a Postres column with a JS JSON array type.
|
|
7
4
|
*/
|
|
8
|
-
class JSONArrayField extends
|
|
5
|
+
export class JSONArrayField extends EntityFieldDefinition {
|
|
9
6
|
validateInputValueInternal(value) {
|
|
10
7
|
return Array.isArray(value);
|
|
11
8
|
}
|
|
12
9
|
}
|
|
13
|
-
exports.JSONArrayField = JSONArrayField;
|
|
14
10
|
/**
|
|
15
11
|
* EntityFieldDefinition for a Postgres column that may be a JS JSON array type.
|
|
16
12
|
* Does not do any validation.
|
|
17
13
|
*/
|
|
18
|
-
class MaybeJSONArrayField extends
|
|
14
|
+
export class MaybeJSONArrayField extends EntityFieldDefinition {
|
|
19
15
|
validateInputValueInternal(_value) {
|
|
20
16
|
return true;
|
|
21
17
|
}
|
|
22
18
|
}
|
|
23
|
-
exports.MaybeJSONArrayField = MaybeJSONArrayField;
|
|
24
19
|
/**
|
|
25
20
|
* EntityFieldDefinition for a Postgres BIGINT column.
|
|
26
21
|
*/
|
|
27
|
-
class BigIntField extends
|
|
22
|
+
export class BigIntField extends EntityFieldDefinition {
|
|
28
23
|
validateInputValueInternal(value) {
|
|
29
24
|
return typeof value === 'string';
|
|
30
25
|
}
|
|
31
26
|
}
|
|
32
|
-
exports.BigIntField = BigIntField;
|
|
33
|
-
//# sourceMappingURL=EntityFields.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EntityCompanion, EntityPrivacyPolicy, EntityPrivacyPolicyEvaluationContext, EntityQueryContext, ReadonlyEntity, ViewerContext
|
|
2
|
-
import { AuthorizationResultBasedKnexEntityLoader } from './AuthorizationResultBasedKnexEntityLoader';
|
|
3
|
-
import { EnforcingKnexEntityLoader } from './EnforcingKnexEntityLoader';
|
|
4
|
-
import { EntityKnexDataManager } from './internal/EntityKnexDataManager';
|
|
1
|
+
import type { EntityCompanion, EntityPrivacyPolicy, EntityPrivacyPolicyEvaluationContext, EntityQueryContext, IEntityMetricsAdapter, ReadonlyEntity, ViewerContext } from '@expo/entity';
|
|
2
|
+
import { AuthorizationResultBasedKnexEntityLoader } from './AuthorizationResultBasedKnexEntityLoader.ts';
|
|
3
|
+
import { EnforcingKnexEntityLoader } from './EnforcingKnexEntityLoader.ts';
|
|
4
|
+
import type { EntityKnexDataManager } from './internal/EntityKnexDataManager.ts';
|
|
5
5
|
/**
|
|
6
6
|
* The primary entry point for loading entities via knex queries (non-data-loader methods).
|
|
7
7
|
*/
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const entity_1 = require("@expo/entity");
|
|
5
|
-
const AuthorizationResultBasedKnexEntityLoader_1 = require("./AuthorizationResultBasedKnexEntityLoader");
|
|
6
|
-
const EnforcingKnexEntityLoader_1 = require("./EnforcingKnexEntityLoader");
|
|
1
|
+
import { EntityConstructionUtils } from '@expo/entity';
|
|
2
|
+
import { AuthorizationResultBasedKnexEntityLoader } from "./AuthorizationResultBasedKnexEntityLoader.js";
|
|
3
|
+
import { EnforcingKnexEntityLoader } from "./EnforcingKnexEntityLoader.js";
|
|
7
4
|
/**
|
|
8
5
|
* The primary entry point for loading entities via knex queries (non-data-loader methods).
|
|
9
6
|
*/
|
|
10
|
-
class KnexEntityLoaderFactory {
|
|
7
|
+
export class KnexEntityLoaderFactory {
|
|
11
8
|
entityCompanion;
|
|
12
9
|
knexDataManager;
|
|
13
10
|
metricsAdapter;
|
|
@@ -22,8 +19,8 @@ class KnexEntityLoaderFactory {
|
|
|
22
19
|
* @param queryContext - query context in which to perform the load
|
|
23
20
|
*/
|
|
24
21
|
forLoad(viewerContext, queryContext, privacyPolicyEvaluationContext) {
|
|
25
|
-
const constructionUtils = new
|
|
26
|
-
return new
|
|
22
|
+
const constructionUtils = new EntityConstructionUtils(viewerContext, queryContext, privacyPolicyEvaluationContext, this.entityCompanion.entityCompanionDefinition.entityConfiguration, this.entityCompanion.entityCompanionDefinition.entityClass, this.entityCompanion.entityCompanionDefinition.entitySelectedFields, this.entityCompanion.privacyPolicy, this.metricsAdapter);
|
|
23
|
+
return new AuthorizationResultBasedKnexEntityLoader(queryContext, this.knexDataManager, this.metricsAdapter, constructionUtils);
|
|
27
24
|
}
|
|
28
25
|
/**
|
|
29
26
|
* Vend enforcing knex loader for loading an entity in a given query context.
|
|
@@ -31,9 +28,7 @@ class KnexEntityLoaderFactory {
|
|
|
31
28
|
* @param queryContext - query context in which to perform the load
|
|
32
29
|
*/
|
|
33
30
|
forLoadEnforcing(viewerContext, queryContext, privacyPolicyEvaluationContext) {
|
|
34
|
-
const constructionUtils = new
|
|
35
|
-
return new
|
|
31
|
+
const constructionUtils = new EntityConstructionUtils(viewerContext, queryContext, privacyPolicyEvaluationContext, this.entityCompanion.entityCompanionDefinition.entityConfiguration, this.entityCompanion.entityCompanionDefinition.entityClass, this.entityCompanion.entityCompanionDefinition.entitySelectedFields, this.entityCompanion.privacyPolicy, this.metricsAdapter);
|
|
32
|
+
return new EnforcingKnexEntityLoader(this.forLoad(viewerContext, queryContext, privacyPolicyEvaluationContext), queryContext, this.knexDataManager, this.metricsAdapter, constructionUtils);
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
exports.KnexEntityLoaderFactory = KnexEntityLoaderFactory;
|
|
39
|
-
//# sourceMappingURL=KnexEntityLoaderFactory.js.map
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PaginationStrategy = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Search strategy for SQL-based pagination.
|
|
6
3
|
*/
|
|
7
|
-
var PaginationStrategy;
|
|
4
|
+
export var PaginationStrategy;
|
|
8
5
|
(function (PaginationStrategy) {
|
|
9
6
|
/**
|
|
10
7
|
* Standard pagination with ORDER BY. Results are ordered by the specified orderBy fields, with ID field automatically included for stable pagination if not already present.
|
|
@@ -31,5 +28,4 @@ var PaginationStrategy;
|
|
|
31
28
|
* ```
|
|
32
29
|
*/
|
|
33
30
|
PaginationStrategy["TRIGRAM_SEARCH"] = "trigram";
|
|
34
|
-
})(PaginationStrategy || (
|
|
35
|
-
//# sourceMappingURL=PaginationStrategy.js.map
|
|
31
|
+
})(PaginationStrategy || (PaginationStrategy = {}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { EntityPrivacyPolicy, EntityQueryContext, IEntityClass, ReadonlyEntity, ViewerContext } from '@expo/entity';
|
|
2
|
+
import { Entity } from '@expo/entity';
|
|
3
|
+
import type { AuthorizationResultBasedKnexEntityLoader } from './AuthorizationResultBasedKnexEntityLoader.ts';
|
|
4
|
+
import type { EnforcingKnexEntityLoader } from './EnforcingKnexEntityLoader.ts';
|
|
4
5
|
/**
|
|
5
6
|
* Abstract base class for mutable entities backed by Postgres.
|
|
6
7
|
* Provides `knexLoader` and `knexLoaderWithAuthorizationResults` as inherited static methods,
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.PostgresEntity = void 0;
|
|
4
|
-
const entity_1 = require("@expo/entity");
|
|
5
|
-
const knexLoader_1 = require("./knexLoader");
|
|
1
|
+
import { Entity } from '@expo/entity';
|
|
2
|
+
import { knexLoader as knexLoaderFn, knexLoaderWithAuthorizationResults as knexLoaderWithAuthorizationResultsFn, } from "./knexLoader.js";
|
|
6
3
|
/**
|
|
7
4
|
* Abstract base class for mutable entities backed by Postgres.
|
|
8
5
|
* Provides `knexLoader` and `knexLoaderWithAuthorizationResults` as inherited static methods,
|
|
9
6
|
* in addition to the mutation methods inherited from `Entity`.
|
|
10
7
|
*/
|
|
11
|
-
class PostgresEntity extends
|
|
8
|
+
export class PostgresEntity extends Entity {
|
|
12
9
|
/**
|
|
13
10
|
* Vend knex loader for loading entities via knex-specific methods in a given query context.
|
|
14
11
|
*
|
|
@@ -19,7 +16,7 @@ class PostgresEntity extends entity_1.Entity {
|
|
|
19
16
|
.getViewerScopedEntityCompanionForClass(this)
|
|
20
17
|
.getQueryContextProvider()
|
|
21
18
|
.getQueryContext()) {
|
|
22
|
-
return (
|
|
19
|
+
return knexLoaderFn(this, viewerContext, queryContext);
|
|
23
20
|
}
|
|
24
21
|
/**
|
|
25
22
|
* Vend knex loader for loading entities via knex-specific methods in a given query context.
|
|
@@ -32,8 +29,6 @@ class PostgresEntity extends entity_1.Entity {
|
|
|
32
29
|
.getViewerScopedEntityCompanionForClass(this)
|
|
33
30
|
.getQueryContextProvider()
|
|
34
31
|
.getQueryContext()) {
|
|
35
|
-
return (
|
|
32
|
+
return knexLoaderWithAuthorizationResultsFn(this, viewerContext, queryContext);
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
exports.PostgresEntity = PostgresEntity;
|
|
39
|
-
//# sourceMappingURL=PostgresEntity.js.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { EntityConfiguration, FieldTransformerMap } from '@expo/entity';
|
|
2
|
-
import { Knex } from 'knex';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { EntityConfiguration, FieldTransformerMap } from '@expo/entity';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { TableFieldMultiValueEqualityCondition, TableFieldSingleValueEqualityCondition, TableQuerySelectionModifiers } from './BasePostgresEntityDatabaseAdapter.ts';
|
|
4
|
+
import { BasePostgresEntityDatabaseAdapter } from './BasePostgresEntityDatabaseAdapter.ts';
|
|
5
|
+
import type { PostgresEntityDatabaseAdapterConfiguration } from './PostgresEntityDatabaseAdapterProvider.ts';
|
|
6
|
+
import type { SQLFragment } from './SQLOperator.ts';
|
|
6
7
|
export declare class PostgresEntityDatabaseAdapter<TFields extends Record<string, any>, TIDField extends keyof TFields> extends BasePostgresEntityDatabaseAdapter<TFields, TIDField> {
|
|
7
8
|
private readonly adapterConfiguration;
|
|
8
9
|
constructor(entityConfiguration: EntityConfiguration<TFields, TIDField>, adapterConfiguration?: PostgresEntityDatabaseAdapterConfiguration);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const EntityFields_1 = require("./EntityFields");
|
|
7
|
-
const wrapNativePostgresCallAsync_1 = require("./errors/wrapNativePostgresCallAsync");
|
|
8
|
-
class PostgresEntityDatabaseAdapter extends BasePostgresEntityDatabaseAdapter_1.BasePostgresEntityDatabaseAdapter {
|
|
1
|
+
import { getDatabaseFieldForEntityField } from '@expo/entity';
|
|
2
|
+
import { BasePostgresEntityDatabaseAdapter, NullsOrdering, OrderByOrdering, } from "./BasePostgresEntityDatabaseAdapter.js";
|
|
3
|
+
import { JSONArrayField, MaybeJSONArrayField } from "./EntityFields.js";
|
|
4
|
+
import { wrapNativePostgresCallAsync } from "./errors/wrapNativePostgresCallAsync.js";
|
|
5
|
+
export class PostgresEntityDatabaseAdapter extends BasePostgresEntityDatabaseAdapter {
|
|
9
6
|
adapterConfiguration;
|
|
10
7
|
constructor(entityConfiguration, adapterConfiguration = {}) {
|
|
11
8
|
super(entityConfiguration);
|
|
@@ -17,7 +14,7 @@ class PostgresEntityDatabaseAdapter extends BasePostgresEntityDatabaseAdapter_1.
|
|
|
17
14
|
getFieldTransformerMap() {
|
|
18
15
|
return new Map([
|
|
19
16
|
[
|
|
20
|
-
|
|
17
|
+
JSONArrayField.name,
|
|
21
18
|
{
|
|
22
19
|
/**
|
|
23
20
|
* JSON array fields must be stringified before insertion using Knex.
|
|
@@ -27,7 +24,7 @@ class PostgresEntityDatabaseAdapter extends BasePostgresEntityDatabaseAdapter_1.
|
|
|
27
24
|
},
|
|
28
25
|
],
|
|
29
26
|
[
|
|
30
|
-
|
|
27
|
+
MaybeJSONArrayField.name,
|
|
31
28
|
{
|
|
32
29
|
/**
|
|
33
30
|
* JSON array fields must be stringified before insertion using Knex.
|
|
@@ -61,7 +58,7 @@ class PostgresEntityDatabaseAdapter extends BasePostgresEntityDatabaseAdapter_1.
|
|
|
61
58
|
// We could use the IN operator for single column queries as well, but we prefer to use ANY to at least keep some
|
|
62
59
|
// consistency in the query shape for the stats table.
|
|
63
60
|
if (tableColumns.length === 1) {
|
|
64
|
-
return await
|
|
61
|
+
return await wrapNativePostgresCallAsync(() => queryInterface
|
|
65
62
|
.select()
|
|
66
63
|
.from(tableName)
|
|
67
64
|
.whereRaw(`(??) = ANY(?)`, [
|
|
@@ -69,7 +66,7 @@ class PostgresEntityDatabaseAdapter extends BasePostgresEntityDatabaseAdapter_1.
|
|
|
69
66
|
tableTuples.map((tableTuple) => tableTuple[0]),
|
|
70
67
|
]));
|
|
71
68
|
}
|
|
72
|
-
return await
|
|
69
|
+
return await wrapNativePostgresCallAsync(() => queryInterface.select().from(tableName).whereIn(tableColumns, tableTuples));
|
|
73
70
|
}
|
|
74
71
|
async fetchOneWhereInternalAsync(queryInterface, tableName, tableColumns, tableTuple) {
|
|
75
72
|
const results = await this.fetchManyByFieldEqualityConjunctionInternalAsync(queryInterface, tableName, tableColumns.map((column, index) => ({
|
|
@@ -87,11 +84,11 @@ class PostgresEntityDatabaseAdapter extends BasePostgresEntityDatabaseAdapter_1.
|
|
|
87
84
|
ret = ret.orderBy(orderBySpecification.columnName, orderBySpecification.order, orderBySpecification.nulls);
|
|
88
85
|
}
|
|
89
86
|
else {
|
|
90
|
-
const orderDirection = orderBySpecification.order ===
|
|
87
|
+
const orderDirection = orderBySpecification.order === OrderByOrdering.ASCENDING ? 'ASC' : 'DESC';
|
|
91
88
|
const nullsSuffix = orderBySpecification.nulls
|
|
92
|
-
? ` NULLS ${orderBySpecification.nulls ===
|
|
89
|
+
? ` NULLS ${orderBySpecification.nulls === NullsOrdering.FIRST ? 'FIRST' : 'LAST'}`
|
|
93
90
|
: '';
|
|
94
|
-
ret = ret.orderByRaw(`(${orderBySpecification.columnFragment.sql}) ${orderDirection}${nullsSuffix}`, orderBySpecification.columnFragment.getKnexBindings((fieldName) =>
|
|
91
|
+
ret = ret.orderByRaw(`(${orderBySpecification.columnFragment.sql}) ${orderDirection}${nullsSuffix}`, orderBySpecification.columnFragment.getKnexBindings((fieldName) => getDatabaseFieldForEntityField(this.entityConfiguration, fieldName)));
|
|
95
92
|
}
|
|
96
93
|
}
|
|
97
94
|
}
|
|
@@ -134,30 +131,28 @@ class PostgresEntityDatabaseAdapter extends BasePostgresEntityDatabaseAdapter_1.
|
|
|
134
131
|
}
|
|
135
132
|
}
|
|
136
133
|
query = this.applyQueryModifiersToQuery(query, querySelectionModifiers);
|
|
137
|
-
return await
|
|
134
|
+
return await wrapNativePostgresCallAsync(() => query);
|
|
138
135
|
}
|
|
139
136
|
async fetchManyByRawWhereClauseInternalAsync(queryInterface, tableName, rawWhereClause, bindings, querySelectionModifiers) {
|
|
140
137
|
let query = queryInterface.select().from(tableName).whereRaw(rawWhereClause, bindings);
|
|
141
138
|
query = this.applyQueryModifiersToQuery(query, querySelectionModifiers);
|
|
142
|
-
return await
|
|
139
|
+
return await wrapNativePostgresCallAsync(() => query);
|
|
143
140
|
}
|
|
144
141
|
async fetchManyBySQLFragmentInternalAsync(queryInterface, tableName, sqlFragment, querySelectionModifiers) {
|
|
145
142
|
let query = queryInterface
|
|
146
143
|
.select()
|
|
147
144
|
.from(tableName)
|
|
148
|
-
.whereRaw(sqlFragment.sql, sqlFragment.getKnexBindings((fieldName) =>
|
|
145
|
+
.whereRaw(sqlFragment.sql, sqlFragment.getKnexBindings((fieldName) => getDatabaseFieldForEntityField(this.entityConfiguration, fieldName)));
|
|
149
146
|
query = this.applyQueryModifiersToQuery(query, querySelectionModifiers);
|
|
150
|
-
return await
|
|
147
|
+
return await wrapNativePostgresCallAsync(() => query);
|
|
151
148
|
}
|
|
152
149
|
async insertInternalAsync(queryInterface, tableName, object) {
|
|
153
|
-
return await
|
|
150
|
+
return await wrapNativePostgresCallAsync(() => queryInterface.insert(object).into(tableName).returning('*'));
|
|
154
151
|
}
|
|
155
152
|
async updateInternalAsync(queryInterface, tableName, tableIdField, id, object) {
|
|
156
|
-
return await
|
|
153
|
+
return await wrapNativePostgresCallAsync(() => queryInterface.update(object).into(tableName).where(tableIdField, id).returning('*'));
|
|
157
154
|
}
|
|
158
155
|
async deleteInternalAsync(queryInterface, tableName, tableIdField, id) {
|
|
159
|
-
return await
|
|
156
|
+
return await wrapNativePostgresCallAsync(() => queryInterface.into(tableName).where(tableIdField, id).del());
|
|
160
157
|
}
|
|
161
158
|
}
|
|
162
|
-
exports.PostgresEntityDatabaseAdapter = PostgresEntityDatabaseAdapter;
|
|
163
|
-
//# sourceMappingURL=PostgresEntityDatabaseAdapter.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityConfiguration, EntityDatabaseAdapter, IEntityDatabaseAdapterProvider } from '@expo/entity';
|
|
1
|
+
import type { EntityConfiguration, EntityDatabaseAdapter, IEntityDatabaseAdapterProvider } from '@expo/entity';
|
|
2
2
|
export interface PostgresEntityDatabaseAdapterConfiguration {
|
|
3
3
|
/**
|
|
4
4
|
* Maximum page size for pagination (first/last parameters).
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.PostgresEntityDatabaseAdapterProvider = void 0;
|
|
4
|
-
const PostgresEntityDatabaseAdapter_1 = require("./PostgresEntityDatabaseAdapter");
|
|
5
|
-
class PostgresEntityDatabaseAdapterProvider {
|
|
1
|
+
import { PostgresEntityDatabaseAdapter } from "./PostgresEntityDatabaseAdapter.js";
|
|
2
|
+
export class PostgresEntityDatabaseAdapterProvider {
|
|
6
3
|
configuration;
|
|
7
4
|
constructor(configuration = {}) {
|
|
8
5
|
this.configuration = configuration;
|
|
9
6
|
}
|
|
10
7
|
getDatabaseAdapter(entityConfiguration) {
|
|
11
|
-
return new
|
|
8
|
+
return new PostgresEntityDatabaseAdapter(entityConfiguration, this.configuration);
|
|
12
9
|
}
|
|
13
10
|
}
|
|
14
|
-
exports.PostgresEntityDatabaseAdapterProvider = PostgresEntityDatabaseAdapterProvider;
|
|
15
|
-
//# sourceMappingURL=PostgresEntityDatabaseAdapterProvider.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { TransactionConfig } from '@expo/entity';
|
|
2
|
+
import { EntityQueryContextProvider } from '@expo/entity';
|
|
3
|
+
import type { Knex } from 'knex';
|
|
3
4
|
/**
|
|
4
5
|
* Query context provider for knex (postgres).
|
|
5
6
|
*/
|