@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,10 +1,11 @@
|
|
|
1
1
|
import { createWithUniqueConstraintRecoveryAsync, ViewerContext } from '@expo/entity';
|
|
2
|
+
import nullthrows from '@expo/nullthrows';
|
|
2
3
|
import { afterAll, beforeAll, beforeEach, describe, expect, it } from '@jest/globals';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
4
|
+
import type { Knex } from 'knex';
|
|
5
|
+
import knex from 'knex';
|
|
5
6
|
|
|
6
|
-
import { PostgresUniqueTestEntity } from '../__testfixtures__/PostgresUniqueTestEntity';
|
|
7
|
-
import { createKnexIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createKnexIntegrationTestEntityCompanionProvider';
|
|
7
|
+
import { PostgresUniqueTestEntity } from '../__testfixtures__/PostgresUniqueTestEntity.ts';
|
|
8
|
+
import { createKnexIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createKnexIntegrationTestEntityCompanionProvider.ts';
|
|
8
9
|
|
|
9
10
|
describe(createWithUniqueConstraintRecoveryAsync, () => {
|
|
10
11
|
let knexInstance: Knex;
|
|
@@ -4,23 +4,23 @@ import {
|
|
|
4
4
|
ViewerContext,
|
|
5
5
|
} from '@expo/entity';
|
|
6
6
|
import { createUnitTestEntityCompanionProvider } from '@expo/entity-testing-utils';
|
|
7
|
+
import nullthrows from '@expo/nullthrows';
|
|
7
8
|
import { enforceAsyncResult } from '@expo/results';
|
|
8
9
|
import { afterAll, beforeAll, beforeEach, describe, expect, it, test } from '@jest/globals';
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
10
|
+
import type { Knex } from 'knex';
|
|
11
|
+
import knex from 'knex';
|
|
11
12
|
import { setTimeout } from 'timers/promises';
|
|
12
13
|
|
|
13
|
-
import { PaginationSpecification } from '../AuthorizationResultBasedKnexEntityLoader';
|
|
14
|
-
import { NullsOrdering, OrderByOrdering } from '../BasePostgresEntityDatabaseAdapter';
|
|
15
|
-
import { PaginationStrategy } from '../PaginationStrategy';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from '../__testfixtures__/
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import { createKnexIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createKnexIntegrationTestEntityCompanionProvider';
|
|
14
|
+
import type { PaginationSpecification } from '../AuthorizationResultBasedKnexEntityLoader.ts';
|
|
15
|
+
import { NullsOrdering, OrderByOrdering } from '../BasePostgresEntityDatabaseAdapter.ts';
|
|
16
|
+
import { PaginationStrategy } from '../PaginationStrategy.ts';
|
|
17
|
+
import type { SQLFragment } from '../SQLOperator.ts';
|
|
18
|
+
import { entityField, sql, SQLExpression, unsafeRaw } from '../SQLOperator.ts';
|
|
19
|
+
import type { PostgresTestEntityFields } from '../__testfixtures__/PostgresTestEntity.ts';
|
|
20
|
+
import { PostgresTestEntity } from '../__testfixtures__/PostgresTestEntity.ts';
|
|
21
|
+
import { PostgresTriggerTestEntity } from '../__testfixtures__/PostgresTriggerTestEntity.ts';
|
|
22
|
+
import { PostgresValidatorTestEntity } from '../__testfixtures__/PostgresValidatorTestEntity.ts';
|
|
23
|
+
import { createKnexIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createKnexIntegrationTestEntityCompanionProvider.ts';
|
|
24
24
|
|
|
25
25
|
describe('postgres entity integration', () => {
|
|
26
26
|
let knexInstance: Knex;
|
|
@@ -456,7 +456,7 @@ describe('postgres entity integration', () => {
|
|
|
456
456
|
|
|
457
457
|
it('supports SQL helper functions', async () => {
|
|
458
458
|
const vc1 = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
459
|
-
const { and, or, eq, neq, inArray } =
|
|
459
|
+
const { and, or, eq, neq, inArray } = SQLExpression;
|
|
460
460
|
|
|
461
461
|
await enforceAsyncResult(
|
|
462
462
|
PostgresTestEntity.creatorWithAuthorizationResults(vc1)
|
|
@@ -521,6 +521,33 @@ describe('postgres entity integration', () => {
|
|
|
521
521
|
expect(complexQuery[1]!.getField('name')).toBe('User3');
|
|
522
522
|
});
|
|
523
523
|
|
|
524
|
+
it('handles empty-array and empty-condition edge cases with TRUE/FALSE', async () => {
|
|
525
|
+
const vc1 = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
526
|
+
const { and, or, inArray } = SQLExpression;
|
|
527
|
+
|
|
528
|
+
await enforceAsyncResult(
|
|
529
|
+
PostgresTestEntity.creatorWithAuthorizationResults(vc1)
|
|
530
|
+
.setField('name', 'TrueFalseUser')
|
|
531
|
+
.setField('hasACat', true)
|
|
532
|
+
.setField('hasADog', false)
|
|
533
|
+
.createAsync(),
|
|
534
|
+
);
|
|
535
|
+
|
|
536
|
+
// inArray([]) produces FALSE — should return no results
|
|
537
|
+
const emptyIn = await PostgresTestEntity.knexLoader(vc1)
|
|
538
|
+
.loadManyBySQL(inArray('name', []))
|
|
539
|
+
.executeAsync();
|
|
540
|
+
expect(emptyIn).toHaveLength(0);
|
|
541
|
+
|
|
542
|
+
// and() with no conditions produces TRUE — should return all results
|
|
543
|
+
const emptyAnd = await PostgresTestEntity.knexLoader(vc1).loadManyBySQL(and()).executeAsync();
|
|
544
|
+
expect(emptyAnd.length).toBeGreaterThanOrEqual(1);
|
|
545
|
+
|
|
546
|
+
// or() with no conditions produces FALSE — should return no results
|
|
547
|
+
const emptyOr = await PostgresTestEntity.knexLoader(vc1).loadManyBySQL(or()).executeAsync();
|
|
548
|
+
expect(emptyOr).toHaveLength(0);
|
|
549
|
+
});
|
|
550
|
+
|
|
524
551
|
it('supports entityField for entity-to-DB field name translation', async () => {
|
|
525
552
|
const vc1 = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
526
553
|
|
|
@@ -743,7 +770,7 @@ describe('postgres entity integration', () => {
|
|
|
743
770
|
sql`(has_a_cat = ${true} AND has_a_dog = ${true})`,
|
|
744
771
|
];
|
|
745
772
|
const joinedResults = await PostgresTestEntity.knexLoader(vc1)
|
|
746
|
-
.loadManyBySQL(
|
|
773
|
+
.loadManyBySQL(SQLExpression.or<PostgresTestEntityFields>(...conditions))
|
|
747
774
|
.orderBy('name', OrderByOrdering.ASCENDING)
|
|
748
775
|
.executeAsync();
|
|
749
776
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { TransactionalDataLoaderMode, ViewerContext } from '@expo/entity';
|
|
2
|
+
import nullthrows from '@expo/nullthrows';
|
|
2
3
|
import { afterAll, beforeAll, beforeEach, describe, expect, it, test } from '@jest/globals';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
4
|
+
import type { Knex } from 'knex';
|
|
5
|
+
import knex from 'knex';
|
|
5
6
|
|
|
6
|
-
import { PostgresEntityQueryContextProvider } from '../PostgresEntityQueryContextProvider';
|
|
7
|
-
import { PostgresUniqueTestEntity } from '../__testfixtures__/PostgresUniqueTestEntity';
|
|
8
|
-
import { createKnexIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createKnexIntegrationTestEntityCompanionProvider';
|
|
7
|
+
import { PostgresEntityQueryContextProvider } from '../PostgresEntityQueryContextProvider.ts';
|
|
8
|
+
import { PostgresUniqueTestEntity } from '../__testfixtures__/PostgresUniqueTestEntity.ts';
|
|
9
|
+
import { createKnexIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createKnexIntegrationTestEntityCompanionProvider.ts';
|
|
9
10
|
|
|
10
11
|
describe(PostgresEntityQueryContextProvider, () => {
|
|
11
12
|
let knexInstance: Knex;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ViewerContext } from '@expo/entity';
|
|
2
|
+
import nullthrows from '@expo/nullthrows';
|
|
2
3
|
import { enforceAsyncResult } from '@expo/results';
|
|
3
4
|
import { afterAll, beforeAll, beforeEach, describe, expect, it } from '@jest/globals';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
5
|
+
import type { Knex } from 'knex';
|
|
6
|
+
import knex from 'knex';
|
|
6
7
|
|
|
7
|
-
import { InvalidTestEntity } from '../__testfixtures__/InvalidTestEntity';
|
|
8
|
-
import { createKnexIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createKnexIntegrationTestEntityCompanionProvider';
|
|
8
|
+
import { InvalidTestEntity } from '../__testfixtures__/InvalidTestEntity.ts';
|
|
9
|
+
import { createKnexIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createKnexIntegrationTestEntityCompanionProvider.ts';
|
|
9
10
|
|
|
10
11
|
describe('postgres entity integration', () => {
|
|
11
12
|
let knexInstance: Knex;
|
|
@@ -8,12 +8,13 @@ import {
|
|
|
8
8
|
EntityDatabaseAdapterUnknownError,
|
|
9
9
|
ViewerContext,
|
|
10
10
|
} from '@expo/entity';
|
|
11
|
+
import nullthrows from '@expo/nullthrows';
|
|
11
12
|
import { afterAll, beforeAll, beforeEach, describe, expect, it } from '@jest/globals';
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
13
|
+
import type { Knex } from 'knex';
|
|
14
|
+
import knex from 'knex';
|
|
14
15
|
|
|
15
|
-
import { ErrorsTestEntity } from '../__testfixtures__/ErrorsTestEntity';
|
|
16
|
-
import { createKnexIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createKnexIntegrationTestEntityCompanionProvider';
|
|
16
|
+
import { ErrorsTestEntity } from '../__testfixtures__/ErrorsTestEntity.ts';
|
|
17
|
+
import { createKnexIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createKnexIntegrationTestEntityCompanionProvider.ts';
|
|
17
18
|
|
|
18
19
|
describe('postgres errors', () => {
|
|
19
20
|
let knexInstance: Knex;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
import type { EntityCompanionDefinition, ViewerContext } from '@expo/entity';
|
|
1
2
|
import {
|
|
2
3
|
AlwaysAllowPrivacyPolicyRule,
|
|
3
4
|
Entity,
|
|
4
|
-
EntityCompanionDefinition,
|
|
5
5
|
EntityConfiguration,
|
|
6
6
|
EntityPrivacyPolicy,
|
|
7
7
|
IntField,
|
|
8
8
|
StringField,
|
|
9
|
-
ViewerContext,
|
|
10
9
|
} from '@expo/entity';
|
|
11
|
-
import { Knex } from 'knex';
|
|
10
|
+
import type { Knex } from 'knex';
|
|
12
11
|
|
|
13
12
|
type ErrorsTestEntityFields = {
|
|
14
13
|
id: number;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
import type { EntityCompanionDefinition, ViewerContext } from '@expo/entity';
|
|
1
2
|
import {
|
|
2
3
|
AlwaysAllowPrivacyPolicyRule,
|
|
3
4
|
Entity,
|
|
4
|
-
EntityCompanionDefinition,
|
|
5
5
|
EntityConfiguration,
|
|
6
6
|
EntityPrivacyPolicy,
|
|
7
7
|
IntField,
|
|
8
8
|
StringField,
|
|
9
|
-
ViewerContext,
|
|
10
9
|
} from '@expo/entity';
|
|
11
|
-
import { Knex } from 'knex';
|
|
10
|
+
import type { Knex } from 'knex';
|
|
12
11
|
|
|
13
12
|
type InvalidTestEntityFields = {
|
|
14
13
|
id: number;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
+
import type { EntityCompanionDefinition, ViewerContext } from '@expo/entity';
|
|
1
2
|
import {
|
|
2
3
|
AlwaysAllowPrivacyPolicyRule,
|
|
3
4
|
BooleanField,
|
|
5
|
+
BufferField,
|
|
4
6
|
DateField,
|
|
5
|
-
EntityCompanionDefinition,
|
|
6
7
|
EntityConfiguration,
|
|
7
8
|
EntityPrivacyPolicy,
|
|
8
9
|
JSONObjectField,
|
|
9
10
|
StringArrayField,
|
|
10
11
|
StringField,
|
|
11
12
|
UUIDField,
|
|
12
|
-
ViewerContext,
|
|
13
|
-
BufferField,
|
|
14
13
|
} from '@expo/entity';
|
|
15
|
-
import { Knex } from 'knex';
|
|
14
|
+
import type { Knex } from 'knex';
|
|
16
15
|
|
|
17
|
-
import { BigIntField, JSONArrayField, MaybeJSONArrayField } from '../EntityFields';
|
|
18
|
-
import { PostgresEntity } from '../PostgresEntity';
|
|
16
|
+
import { BigIntField, JSONArrayField, MaybeJSONArrayField } from '../EntityFields.ts';
|
|
17
|
+
import { PostgresEntity } from '../PostgresEntity.ts';
|
|
19
18
|
|
|
20
19
|
export type PostgresTestEntityFields = {
|
|
21
20
|
id: string;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EntityCompanionDefinition,
|
|
3
|
+
EntityQueryContext,
|
|
4
|
+
EntityTriggerMutationInfo,
|
|
5
|
+
ViewerContext,
|
|
6
|
+
} from '@expo/entity';
|
|
1
7
|
import {
|
|
2
8
|
AlwaysAllowPrivacyPolicyRule,
|
|
3
9
|
Entity,
|
|
4
|
-
EntityCompanionDefinition,
|
|
5
10
|
EntityConfiguration,
|
|
6
11
|
EntityMutationTrigger,
|
|
7
12
|
EntityNonTransactionalMutationTrigger,
|
|
8
13
|
EntityPrivacyPolicy,
|
|
9
|
-
EntityQueryContext,
|
|
10
|
-
EntityTriggerMutationInfo,
|
|
11
14
|
StringField,
|
|
12
15
|
UUIDField,
|
|
13
|
-
ViewerContext,
|
|
14
16
|
} from '@expo/entity';
|
|
15
|
-
import { Knex } from 'knex';
|
|
17
|
+
import type { Knex } from 'knex';
|
|
16
18
|
|
|
17
19
|
type PostgresTriggerTestEntityFields = {
|
|
18
20
|
id: string;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EntityCompanionDefinition,
|
|
3
|
+
EntityTransactionalQueryContext,
|
|
4
|
+
ViewerContext,
|
|
5
|
+
} from '@expo/entity';
|
|
1
6
|
import {
|
|
2
7
|
AlwaysAllowPrivacyPolicyRule,
|
|
3
8
|
Entity,
|
|
4
|
-
EntityCompanionDefinition,
|
|
5
9
|
EntityConfiguration,
|
|
6
10
|
EntityPrivacyPolicy,
|
|
7
|
-
EntityTransactionalQueryContext,
|
|
8
11
|
StringField,
|
|
9
12
|
UUIDField,
|
|
10
|
-
ViewerContext,
|
|
11
13
|
} from '@expo/entity';
|
|
12
|
-
import { Knex } from 'knex';
|
|
14
|
+
import type { Knex } from 'knex';
|
|
13
15
|
|
|
14
16
|
type PostgresUniqueTestEntityFields = {
|
|
15
17
|
id: string;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EntityCompanionDefinition,
|
|
3
|
+
EntityQueryContext,
|
|
4
|
+
EntityValidatorMutationInfo,
|
|
5
|
+
ViewerContext,
|
|
6
|
+
} from '@expo/entity';
|
|
1
7
|
import {
|
|
2
8
|
AlwaysAllowPrivacyPolicyRule,
|
|
3
9
|
Entity,
|
|
4
|
-
EntityCompanionDefinition,
|
|
5
10
|
EntityConfiguration,
|
|
6
11
|
EntityMutationTrigger,
|
|
7
12
|
EntityPrivacyPolicy,
|
|
8
|
-
EntityQueryContext,
|
|
9
|
-
EntityValidatorMutationInfo,
|
|
10
13
|
StringField,
|
|
11
14
|
UUIDField,
|
|
12
|
-
ViewerContext,
|
|
13
15
|
} from '@expo/entity';
|
|
14
|
-
import { Knex } from 'knex';
|
|
16
|
+
import type { Knex } from 'knex';
|
|
15
17
|
|
|
16
18
|
type PostgresValidatorTestEntityFields = {
|
|
17
19
|
id: string;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
IEntityMetricsAdapter,
|
|
4
|
-
NoOpEntityMetricsAdapter,
|
|
5
|
-
} from '@expo/entity';
|
|
1
|
+
import type { IEntityMetricsAdapter } from '@expo/entity';
|
|
2
|
+
import { EntityCompanionProvider, NoOpEntityMetricsAdapter } from '@expo/entity';
|
|
6
3
|
import { InMemoryFullCacheStubCacheAdapterProvider } from '@expo/entity-testing-utils';
|
|
7
|
-
import { Knex } from 'knex';
|
|
4
|
+
import type { Knex } from 'knex';
|
|
8
5
|
|
|
9
|
-
import { PostgresEntityDatabaseAdapterProvider } from '../PostgresEntityDatabaseAdapterProvider';
|
|
10
|
-
import { PostgresEntityQueryContextProvider } from '../PostgresEntityQueryContextProvider';
|
|
6
|
+
import { PostgresEntityDatabaseAdapterProvider } from '../PostgresEntityDatabaseAdapterProvider.ts';
|
|
7
|
+
import { PostgresEntityQueryContextProvider } from '../PostgresEntityQueryContextProvider.ts';
|
|
11
8
|
|
|
12
9
|
export const createKnexIntegrationTestEntityCompanionProvider = (
|
|
13
10
|
knex: Knex,
|
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
EntityPrivacyPolicyEvaluationContext,
|
|
3
|
-
ViewerContext,
|
|
4
|
-
enforceResultsAsync,
|
|
5
|
-
IEntityMetricsAdapter,
|
|
6
|
-
EntityConstructionUtils,
|
|
7
3
|
EntityQueryContext,
|
|
4
|
+
IEntityMetricsAdapter,
|
|
8
5
|
} from '@expo/entity';
|
|
6
|
+
import { enforceResultsAsync, EntityConstructionUtils, ViewerContext } from '@expo/entity';
|
|
9
7
|
import { describe, expect, it } from '@jest/globals';
|
|
10
8
|
import { anyOfClass, anything, instance, mock, spy, verify, when } from 'ts-mockito';
|
|
11
9
|
import { v4 as uuidv4 } from 'uuid';
|
|
12
10
|
|
|
13
|
-
import { AuthorizationResultBasedKnexEntityLoader } from '../AuthorizationResultBasedKnexEntityLoader';
|
|
14
|
-
import { OrderByOrdering } from '../BasePostgresEntityDatabaseAdapter';
|
|
15
|
-
import { PaginationStrategy } from '../PaginationStrategy';
|
|
16
|
-
import { sql } from '../SQLOperator';
|
|
11
|
+
import { AuthorizationResultBasedKnexEntityLoader } from '../AuthorizationResultBasedKnexEntityLoader.ts';
|
|
12
|
+
import { OrderByOrdering } from '../BasePostgresEntityDatabaseAdapter.ts';
|
|
13
|
+
import { PaginationStrategy } from '../PaginationStrategy.ts';
|
|
14
|
+
import { sql } from '../SQLOperator.ts';
|
|
15
|
+
import { EntityKnexDataManager } from '../internal/EntityKnexDataManager.ts';
|
|
16
|
+
import type { TestFields } from './fixtures/TestEntity.ts';
|
|
17
17
|
import {
|
|
18
18
|
TestEntity,
|
|
19
19
|
testEntityConfiguration,
|
|
20
20
|
TestEntityPrivacyPolicy,
|
|
21
|
-
|
|
22
|
-
} from './fixtures/
|
|
21
|
+
} from './fixtures/TestEntity.ts';
|
|
22
|
+
import type { TestPaginationFields } from './fixtures/TestPaginationEntity.ts';
|
|
23
23
|
import {
|
|
24
24
|
TestPaginationEntity,
|
|
25
25
|
testPaginationEntityConfiguration,
|
|
26
26
|
TestPaginationPrivacyPolicy,
|
|
27
|
-
|
|
28
|
-
} from './fixtures/TestPaginationEntity';
|
|
29
|
-
import { EntityKnexDataManager } from '../internal/EntityKnexDataManager';
|
|
27
|
+
} from './fixtures/TestPaginationEntity.ts';
|
|
30
28
|
|
|
31
29
|
describe(AuthorizationResultBasedKnexEntityLoader, () => {
|
|
32
30
|
it('loads entities with loadManyByFieldEqualityConjunction', async () => {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FieldTransformerMap } from '@expo/entity';
|
|
2
|
+
import { EntityQueryContext } from '@expo/entity';
|
|
2
3
|
import { describe, expect, it } from '@jest/globals';
|
|
3
4
|
import { instance, mock } from 'ts-mockito';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
-
BasePostgresEntityDatabaseAdapter,
|
|
6
|
+
import type {
|
|
7
7
|
TableFieldMultiValueEqualityCondition,
|
|
8
8
|
TableFieldSingleValueEqualityCondition,
|
|
9
|
-
} from '../BasePostgresEntityDatabaseAdapter';
|
|
10
|
-
import {
|
|
9
|
+
} from '../BasePostgresEntityDatabaseAdapter.ts';
|
|
10
|
+
import { BasePostgresEntityDatabaseAdapter } from '../BasePostgresEntityDatabaseAdapter.ts';
|
|
11
|
+
import type { TestFields } from './fixtures/TestEntity.ts';
|
|
12
|
+
import { testEntityConfiguration } from './fixtures/TestEntity.ts';
|
|
11
13
|
|
|
12
14
|
class TestEntityDatabaseAdapter extends BasePostgresEntityDatabaseAdapter<
|
|
13
15
|
TestFields,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IEntityMetricsAdapter } from '@expo/entity';
|
|
2
|
+
import { EntityConstructionUtils, EntityQueryContext } from '@expo/entity';
|
|
2
3
|
import { result } from '@expo/results';
|
|
3
4
|
import { describe, expect, it } from '@jest/globals';
|
|
4
5
|
import { anything, instance, mock, when } from 'ts-mockito';
|
|
@@ -6,11 +7,11 @@ import { anything, instance, mock, when } from 'ts-mockito';
|
|
|
6
7
|
import {
|
|
7
8
|
AuthorizationResultBasedKnexEntityLoader,
|
|
8
9
|
AuthorizationResultBasedSQLQueryBuilder,
|
|
9
|
-
} from '../AuthorizationResultBasedKnexEntityLoader';
|
|
10
|
-
import { EnforcingKnexEntityLoader } from '../EnforcingKnexEntityLoader';
|
|
11
|
-
import { PaginationStrategy } from '../PaginationStrategy';
|
|
12
|
-
import { sql } from '../SQLOperator';
|
|
13
|
-
import { EntityKnexDataManager } from '../internal/EntityKnexDataManager';
|
|
10
|
+
} from '../AuthorizationResultBasedKnexEntityLoader.ts';
|
|
11
|
+
import { EnforcingKnexEntityLoader } from '../EnforcingKnexEntityLoader.ts';
|
|
12
|
+
import { PaginationStrategy } from '../PaginationStrategy.ts';
|
|
13
|
+
import { sql } from '../SQLOperator.ts';
|
|
14
|
+
import { EntityKnexDataManager } from '../internal/EntityKnexDataManager.ts';
|
|
14
15
|
|
|
15
16
|
describe(EnforcingKnexEntityLoader, () => {
|
|
16
17
|
describe('loadFirstByFieldEqualityConjunction', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describeFieldTestCase } from '@expo/entity-testing-utils';
|
|
2
2
|
|
|
3
|
-
import { BigIntField, JSONArrayField, MaybeJSONArrayField } from '../EntityFields';
|
|
3
|
+
import { BigIntField, JSONArrayField, MaybeJSONArrayField } from '../EntityFields.ts';
|
|
4
4
|
|
|
5
5
|
describeFieldTestCase(
|
|
6
6
|
new JSONArrayField({ columnName: 'wat' }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { EntityCompanionDefinition } from '@expo/entity';
|
|
1
2
|
import {
|
|
2
3
|
AlwaysAllowPrivacyPolicyRule,
|
|
3
|
-
EntityCompanionDefinition,
|
|
4
4
|
EntityConfiguration,
|
|
5
5
|
EntityPrivacyPolicy,
|
|
6
6
|
StringField,
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
} from '@expo/entity';
|
|
10
10
|
import { describe, expect, it } from '@jest/globals';
|
|
11
11
|
|
|
12
|
-
import { AuthorizationResultBasedKnexEntityLoader } from '../AuthorizationResultBasedKnexEntityLoader';
|
|
13
|
-
import { EnforcingKnexEntityLoader } from '../EnforcingKnexEntityLoader';
|
|
14
|
-
import { PostgresEntity } from '../PostgresEntity';
|
|
15
|
-
import { ReadonlyPostgresEntity } from '../ReadonlyPostgresEntity';
|
|
16
|
-
import { createUnitTestPostgresEntityCompanionProvider } from './fixtures/createUnitTestPostgresEntityCompanionProvider';
|
|
12
|
+
import { AuthorizationResultBasedKnexEntityLoader } from '../AuthorizationResultBasedKnexEntityLoader.ts';
|
|
13
|
+
import { EnforcingKnexEntityLoader } from '../EnforcingKnexEntityLoader.ts';
|
|
14
|
+
import { PostgresEntity } from '../PostgresEntity.ts';
|
|
15
|
+
import { ReadonlyPostgresEntity } from '../ReadonlyPostgresEntity.ts';
|
|
16
|
+
import { createUnitTestPostgresEntityCompanionProvider } from './fixtures/createUnitTestPostgresEntityCompanionProvider.ts';
|
|
17
17
|
|
|
18
18
|
type TestPostgresFields = {
|
|
19
19
|
id: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ViewerContext } from '@expo/entity';
|
|
2
2
|
import { describe, expect, it } from '@jest/globals';
|
|
3
3
|
|
|
4
|
-
import { AuthorizationResultBasedKnexEntityLoader } from '../AuthorizationResultBasedKnexEntityLoader';
|
|
5
|
-
import { EnforcingKnexEntityLoader } from '../EnforcingKnexEntityLoader';
|
|
6
|
-
import { knexLoader, knexLoaderWithAuthorizationResults } from '../knexLoader';
|
|
7
|
-
import { TestEntity } from './fixtures/TestEntity';
|
|
8
|
-
import { createUnitTestPostgresEntityCompanionProvider } from './fixtures/createUnitTestPostgresEntityCompanionProvider';
|
|
4
|
+
import { AuthorizationResultBasedKnexEntityLoader } from '../AuthorizationResultBasedKnexEntityLoader.ts';
|
|
5
|
+
import { EnforcingKnexEntityLoader } from '../EnforcingKnexEntityLoader.ts';
|
|
6
|
+
import { knexLoader, knexLoaderWithAuthorizationResults } from '../knexLoader.ts';
|
|
7
|
+
import { TestEntity } from './fixtures/TestEntity.ts';
|
|
8
|
+
import { createUnitTestPostgresEntityCompanionProvider } from './fixtures/createUnitTestPostgresEntityCompanionProvider.ts';
|
|
9
9
|
|
|
10
10
|
describe('knexLoader', () => {
|
|
11
11
|
describe('knexLoader', () => {
|