@expo/entity-database-adapter-knex 0.55.0 → 0.58.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 +278 -0
- package/build/src/AuthorizationResultBasedKnexEntityLoader.js +127 -0
- package/build/src/AuthorizationResultBasedKnexEntityLoader.js.map +1 -0
- package/build/src/BasePostgresEntityDatabaseAdapter.d.ts +150 -0
- package/build/src/BasePostgresEntityDatabaseAdapter.js +119 -0
- package/build/src/BasePostgresEntityDatabaseAdapter.js.map +1 -0
- package/build/src/BaseSQLQueryBuilder.d.ts +61 -0
- package/build/src/BaseSQLQueryBuilder.js +87 -0
- package/build/src/BaseSQLQueryBuilder.js.map +1 -0
- package/build/src/EnforcingKnexEntityLoader.d.ts +124 -0
- package/build/src/EnforcingKnexEntityLoader.js +166 -0
- package/build/src/EnforcingKnexEntityLoader.js.map +1 -0
- package/build/src/KnexEntityLoaderFactory.d.ts +25 -0
- package/build/src/KnexEntityLoaderFactory.js +39 -0
- package/build/src/KnexEntityLoaderFactory.js.map +1 -0
- package/build/src/PaginationStrategy.d.ts +30 -0
- package/build/src/PaginationStrategy.js +35 -0
- package/build/src/PaginationStrategy.js.map +1 -0
- package/build/src/PostgresEntity.d.ts +25 -0
- package/build/src/PostgresEntity.js +39 -0
- package/build/src/PostgresEntity.js.map +1 -0
- package/build/src/PostgresEntityDatabaseAdapter.d.ts +12 -5
- package/build/src/PostgresEntityDatabaseAdapter.js +33 -11
- package/build/src/PostgresEntityDatabaseAdapter.js.map +1 -1
- package/build/src/PostgresEntityDatabaseAdapterProvider.d.ts +9 -0
- package/build/src/PostgresEntityDatabaseAdapterProvider.js +5 -1
- package/build/src/PostgresEntityDatabaseAdapterProvider.js.map +1 -1
- package/build/src/ReadonlyPostgresEntity.d.ts +25 -0
- package/build/src/ReadonlyPostgresEntity.js +39 -0
- package/build/src/ReadonlyPostgresEntity.js.map +1 -0
- package/build/src/SQLOperator.d.ts +267 -0
- package/build/src/SQLOperator.js +474 -0
- package/build/src/SQLOperator.js.map +1 -0
- package/build/src/index.d.ts +15 -0
- package/build/src/index.js +15 -0
- package/build/src/index.js.map +1 -1
- package/build/src/internal/EntityKnexDataManager.d.ts +147 -0
- package/build/src/internal/EntityKnexDataManager.js +453 -0
- package/build/src/internal/EntityKnexDataManager.js.map +1 -0
- package/build/src/internal/getKnexDataManager.d.ts +3 -0
- package/build/src/internal/getKnexDataManager.js +19 -0
- package/build/src/internal/getKnexDataManager.js.map +1 -0
- package/build/src/internal/getKnexEntityLoaderFactory.d.ts +3 -0
- package/build/src/internal/getKnexEntityLoaderFactory.js +11 -0
- package/build/src/internal/getKnexEntityLoaderFactory.js.map +1 -0
- package/build/src/internal/utilityTypes.d.ts +5 -0
- package/build/src/internal/utilityTypes.js +5 -0
- package/build/src/internal/utilityTypes.js.map +1 -0
- package/build/src/internal/weakMaps.d.ts +9 -0
- package/build/src/internal/weakMaps.js +20 -0
- package/build/src/internal/weakMaps.js.map +1 -0
- package/build/src/knexLoader.d.ts +18 -0
- package/build/src/knexLoader.js +31 -0
- package/build/src/knexLoader.js.map +1 -0
- package/package.json +6 -5
- package/src/AuthorizationResultBasedKnexEntityLoader.ts +537 -0
- package/src/BasePostgresEntityDatabaseAdapter.ts +317 -0
- package/src/BaseSQLQueryBuilder.ts +114 -0
- package/src/EnforcingKnexEntityLoader.ts +271 -0
- package/src/KnexEntityLoaderFactory.ts +130 -0
- package/src/PaginationStrategy.ts +32 -0
- package/src/PostgresEntity.ts +118 -0
- package/src/PostgresEntityDatabaseAdapter.ts +81 -24
- package/src/PostgresEntityDatabaseAdapterProvider.ts +11 -1
- package/src/ReadonlyPostgresEntity.ts +115 -0
- package/src/SQLOperator.ts +630 -0
- package/src/__integration-tests__/EntityCreationUtils-test.ts +25 -31
- package/src/__integration-tests__/PostgresEntityIntegration-test.ts +3192 -330
- package/src/__integration-tests__/PostgresEntityQueryContextProvider-test.ts +7 -7
- package/src/__testfixtures__/PostgresTestEntity.ts +17 -3
- package/src/__tests__/AuthorizationResultBasedKnexEntityLoader-test.ts +1167 -0
- package/src/__tests__/BasePostgresEntityDatabaseAdapter-test.ts +160 -0
- package/src/__tests__/EnforcingKnexEntityLoader-test.ts +384 -0
- package/src/__tests__/EntityFields-test.ts +1 -1
- package/src/__tests__/PostgresEntity-test.ts +172 -0
- package/src/__tests__/ReadonlyEntity-test.ts +32 -0
- package/src/__tests__/SQLOperator-test.ts +871 -0
- package/src/__tests__/fixtures/StubPostgresDatabaseAdapter.ts +302 -0
- package/src/__tests__/fixtures/StubPostgresDatabaseAdapterProvider.ts +17 -0
- package/src/__tests__/fixtures/TestEntity.ts +131 -0
- package/src/__tests__/fixtures/TestPaginationEntity.ts +107 -0
- package/src/__tests__/fixtures/createUnitTestPostgresEntityCompanionProvider.ts +42 -0
- package/src/index.ts +15 -0
- package/src/internal/EntityKnexDataManager.ts +832 -0
- package/src/internal/__tests__/EntityKnexDataManager-test.ts +378 -0
- package/src/internal/__tests__/weakMaps-test.ts +25 -0
- package/src/internal/getKnexDataManager.ts +43 -0
- package/src/internal/getKnexEntityLoaderFactory.ts +60 -0
- package/src/internal/utilityTypes.ts +11 -0
- package/src/internal/weakMaps.ts +19 -0
- package/src/knexLoader.ts +110 -0
|
@@ -41,7 +41,7 @@ describe(PostgresEntityQueryContextProvider, () => {
|
|
|
41
41
|
await PostgresUniqueTestEntity.creator(vc1).setField('name', 'wat').createAsync()
|
|
42
42
|
).getID();
|
|
43
43
|
|
|
44
|
-
await vc1.
|
|
44
|
+
await vc1.runInTransactionForDatabaseAdapterFlavorAsync('postgres', async (queryContext) => {
|
|
45
45
|
const entity = await PostgresUniqueTestEntity.loader(vc1, queryContext).loadByIDAsync(id);
|
|
46
46
|
await PostgresUniqueTestEntity.updater(entity, queryContext)
|
|
47
47
|
.setField('name', 'wat2')
|
|
@@ -81,7 +81,7 @@ describe(PostgresEntityQueryContextProvider, () => {
|
|
|
81
81
|
const entityLoaded = await PostgresUniqueTestEntity.loader(vc1).loadByIDAsync(entity.getID());
|
|
82
82
|
expect(entityLoaded.getField('name')).toEqual('who');
|
|
83
83
|
|
|
84
|
-
await vc1.
|
|
84
|
+
await vc1.runInTransactionForDatabaseAdapterFlavorAsync('postgres', async (queryContext) => {
|
|
85
85
|
const entityLoadedOuter = await PostgresUniqueTestEntity.loader(vc1).loadByIDAsync(
|
|
86
86
|
entity.getID(),
|
|
87
87
|
);
|
|
@@ -124,7 +124,7 @@ describe(PostgresEntityQueryContextProvider, () => {
|
|
|
124
124
|
const entityLoaded = await PostgresUniqueTestEntity.loader(vc1).loadByIDAsync(entity.getID());
|
|
125
125
|
expect(entityLoaded.getField('name')).toEqual('who');
|
|
126
126
|
|
|
127
|
-
await vc1.
|
|
127
|
+
await vc1.runInTransactionForDatabaseAdapterFlavorAsync('postgres', async (queryContext) => {
|
|
128
128
|
const entityLoadedOuter = await PostgresUniqueTestEntity.loader(vc1).loadByIDAsync(
|
|
129
129
|
entity.getID(),
|
|
130
130
|
);
|
|
@@ -181,7 +181,7 @@ describe(PostgresEntityQueryContextProvider, () => {
|
|
|
181
181
|
});
|
|
182
182
|
|
|
183
183
|
await Promise.all([
|
|
184
|
-
vc1.
|
|
184
|
+
vc1.runInTransactionForDatabaseAdapterFlavorAsync('postgres', async (queryContext) => {
|
|
185
185
|
const entityLoadedOuter = await PostgresUniqueTestEntity.loader(vc1).loadByIDAsync(
|
|
186
186
|
entity.getID(),
|
|
187
187
|
);
|
|
@@ -235,7 +235,7 @@ describe(PostgresEntityQueryContextProvider, () => {
|
|
|
235
235
|
transactionalDataLoaderMode: TransactionalDataLoaderMode,
|
|
236
236
|
): Promise<void> => {
|
|
237
237
|
const vc1 = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
238
|
-
await vc1.
|
|
238
|
+
await vc1.runInTransactionForDatabaseAdapterFlavorAsync(
|
|
239
239
|
'postgres',
|
|
240
240
|
async (outerQueryContext) => {
|
|
241
241
|
// put it in local dataloader
|
|
@@ -334,7 +334,7 @@ describe(PostgresEntityQueryContextProvider, () => {
|
|
|
334
334
|
transactionalDataLoaderMode: TransactionalDataLoaderMode,
|
|
335
335
|
): Promise<void> => {
|
|
336
336
|
const vc1 = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
337
|
-
await vc1.
|
|
337
|
+
await vc1.runInTransactionForDatabaseAdapterFlavorAsync(
|
|
338
338
|
'postgres',
|
|
339
339
|
async (outerQueryContext) => {
|
|
340
340
|
// put it in local dataloader
|
|
@@ -432,7 +432,7 @@ describe(PostgresEntityQueryContextProvider, () => {
|
|
|
432
432
|
await PostgresUniqueTestEntity.creator(vc1).setField('name', 'wat').createAsync()
|
|
433
433
|
).getID();
|
|
434
434
|
|
|
435
|
-
await vc1.
|
|
435
|
+
await vc1.runInTransactionForDatabaseAdapterFlavorAsync('postgres', async (queryContext) => {
|
|
436
436
|
await queryContext.runInNestedTransactionAsync(async (innerQueryContext) => {
|
|
437
437
|
await innerQueryContext.runInNestedTransactionAsync(async (innerQueryContex2) => {
|
|
438
438
|
await innerQueryContex2.runInNestedTransactionAsync(async (innerQueryContex3) => {
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
AlwaysAllowPrivacyPolicyRule,
|
|
3
3
|
BooleanField,
|
|
4
4
|
DateField,
|
|
5
|
-
Entity,
|
|
6
5
|
EntityCompanionDefinition,
|
|
7
6
|
EntityConfiguration,
|
|
8
7
|
EntityPrivacyPolicy,
|
|
@@ -16,10 +15,12 @@ import {
|
|
|
16
15
|
import { Knex } from 'knex';
|
|
17
16
|
|
|
18
17
|
import { BigIntField, JSONArrayField, MaybeJSONArrayField } from '../EntityFields';
|
|
18
|
+
import { PostgresEntity } from '../PostgresEntity';
|
|
19
19
|
|
|
20
|
-
type PostgresTestEntityFields = {
|
|
20
|
+
export type PostgresTestEntityFields = {
|
|
21
21
|
id: string;
|
|
22
22
|
name: string | null;
|
|
23
|
+
label: string;
|
|
23
24
|
hasADog: boolean | null;
|
|
24
25
|
hasACat: boolean | null;
|
|
25
26
|
stringArray: string[] | null;
|
|
@@ -31,9 +32,14 @@ type PostgresTestEntityFields = {
|
|
|
31
32
|
maybeJsonArrayField: string[] | { hello: string } | null;
|
|
32
33
|
bigintField: string | null;
|
|
33
34
|
binaryField: Buffer | null;
|
|
35
|
+
createdAt: Date;
|
|
34
36
|
};
|
|
35
37
|
|
|
36
|
-
export class PostgresTestEntity extends
|
|
38
|
+
export class PostgresTestEntity extends PostgresEntity<
|
|
39
|
+
PostgresTestEntityFields,
|
|
40
|
+
'id',
|
|
41
|
+
ViewerContext
|
|
42
|
+
> {
|
|
37
43
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
38
44
|
PostgresTestEntityFields,
|
|
39
45
|
'id',
|
|
@@ -55,6 +61,7 @@ export class PostgresTestEntity extends Entity<PostgresTestEntityFields, 'id', V
|
|
|
55
61
|
await knex.schema.createTable(tableName, (table) => {
|
|
56
62
|
table.uuid('id').defaultTo(knex.raw('gen_random_uuid()')).primary();
|
|
57
63
|
table.string('name');
|
|
64
|
+
table.string('label').notNullable().defaultTo('');
|
|
58
65
|
table.boolean('has_a_dog');
|
|
59
66
|
table.boolean('has_a_cat');
|
|
60
67
|
table.specificType('string_array', 'text[]');
|
|
@@ -64,6 +71,7 @@ export class PostgresTestEntity extends Entity<PostgresTestEntityFields, 'id', V
|
|
|
64
71
|
table.jsonb('maybe_json_array_field');
|
|
65
72
|
table.bigint('bigint_field');
|
|
66
73
|
table.binary('binary_field');
|
|
74
|
+
table.dateTime('created_at', { useTz: true }).defaultTo(knex.fn.now());
|
|
67
75
|
});
|
|
68
76
|
}
|
|
69
77
|
await knex.into(tableName).truncate();
|
|
@@ -132,6 +140,9 @@ export const postgresTestEntityConfiguration = new EntityConfiguration<
|
|
|
132
140
|
name: new StringField({
|
|
133
141
|
columnName: 'name',
|
|
134
142
|
}),
|
|
143
|
+
label: new StringField({
|
|
144
|
+
columnName: 'label',
|
|
145
|
+
}),
|
|
135
146
|
hasADog: new BooleanField({
|
|
136
147
|
columnName: 'has_a_dog',
|
|
137
148
|
}),
|
|
@@ -159,6 +170,9 @@ export const postgresTestEntityConfiguration = new EntityConfiguration<
|
|
|
159
170
|
binaryField: new BufferField({
|
|
160
171
|
columnName: 'binary_field',
|
|
161
172
|
}),
|
|
173
|
+
createdAt: new DateField({
|
|
174
|
+
columnName: 'created_at',
|
|
175
|
+
}),
|
|
162
176
|
},
|
|
163
177
|
databaseAdapterFlavor: 'postgres',
|
|
164
178
|
cacheAdapterFlavor: 'redis',
|