@expo/entity-database-adapter-knex 0.41.0 → 0.43.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.
Files changed (63) hide show
  1. package/build/EntityFields.d.ts +3 -3
  2. package/build/EntityFields.js.map +1 -1
  3. package/build/PostgresEntityDatabaseAdapter.d.ts +2 -2
  4. package/build/PostgresEntityDatabaseAdapter.js +31 -5
  5. package/build/PostgresEntityDatabaseAdapter.js.map +1 -1
  6. package/build/PostgresEntityDatabaseAdapterProvider.d.ts +1 -1
  7. package/build/PostgresEntityDatabaseAdapterProvider.js.map +1 -1
  8. package/build/tsconfig.build.tsbuildinfo +1 -0
  9. package/package.json +9 -7
  10. package/src/EntityFields.ts +11 -3
  11. package/src/PostgresEntityDatabaseAdapter.ts +38 -7
  12. package/src/PostgresEntityDatabaseAdapterProvider.ts +3 -3
  13. package/src/__integration-tests__/PostgresEntityIntegration-test.ts +63 -10
  14. package/src/__integration-tests__/PostgresEntityQueryContextProvider-test.ts +2 -2
  15. package/src/__integration-tests__/PostgresInvalidSetup-test.ts +2 -2
  16. package/src/__integration-tests__/errors-test.ts +2 -2
  17. package/src/{testfixtures → __testfixtures__}/ErrorsTestEntity.ts +9 -12
  18. package/src/{testfixtures → __testfixtures__}/InvalidTestEntity.ts +12 -8
  19. package/src/{testfixtures → __testfixtures__}/PostgresTestEntity.ts +13 -9
  20. package/src/{testfixtures → __testfixtures__}/PostgresTriggerTestEntity.ts +29 -27
  21. package/src/{testfixtures → __testfixtures__}/PostgresUniqueTestEntity.ts +26 -24
  22. package/src/{testfixtures → __testfixtures__}/PostgresValidatorTestEntity.ts +28 -26
  23. package/src/{testfixtures → __testfixtures__}/createKnexIntegrationTestEntityCompanionProvider.ts +1 -1
  24. package/src/__tests__/EntityFields-test.ts +1 -1
  25. package/build/__integration-tests__/PostgresEntityIntegration-test.d.ts +0 -1
  26. package/build/__integration-tests__/PostgresEntityIntegration-test.js +0 -463
  27. package/build/__integration-tests__/PostgresEntityIntegration-test.js.map +0 -1
  28. package/build/__integration-tests__/PostgresEntityQueryContextProvider-test.d.ts +0 -1
  29. package/build/__integration-tests__/PostgresEntityQueryContextProvider-test.js +0 -80
  30. package/build/__integration-tests__/PostgresEntityQueryContextProvider-test.js.map +0 -1
  31. package/build/__integration-tests__/PostgresInvalidSetup-test.d.ts +0 -1
  32. package/build/__integration-tests__/PostgresInvalidSetup-test.js +0 -69
  33. package/build/__integration-tests__/PostgresInvalidSetup-test.js.map +0 -1
  34. package/build/__integration-tests__/errors-test.d.ts +0 -1
  35. package/build/__integration-tests__/errors-test.js +0 -127
  36. package/build/__integration-tests__/errors-test.js.map +0 -1
  37. package/build/__tests__/EntityFields-test.d.ts +0 -1
  38. package/build/__tests__/EntityFields-test.js +0 -8
  39. package/build/__tests__/EntityFields-test.js.map +0 -1
  40. package/build/errors/__tests__/wrapNativePostgresCallAsync-test.d.ts +0 -1
  41. package/build/errors/__tests__/wrapNativePostgresCallAsync-test.js +0 -24
  42. package/build/errors/__tests__/wrapNativePostgresCallAsync-test.js.map +0 -1
  43. package/build/testfixtures/ErrorsTestEntity.d.ts +0 -24
  44. package/build/testfixtures/ErrorsTestEntity.js +0 -106
  45. package/build/testfixtures/ErrorsTestEntity.js.map +0 -1
  46. package/build/testfixtures/InvalidTestEntity.d.ts +0 -19
  47. package/build/testfixtures/InvalidTestEntity.js +0 -61
  48. package/build/testfixtures/InvalidTestEntity.js.map +0 -1
  49. package/build/testfixtures/PostgresTestEntity.d.ts +0 -31
  50. package/build/testfixtures/PostgresTestEntity.js +0 -95
  51. package/build/testfixtures/PostgresTestEntity.js.map +0 -1
  52. package/build/testfixtures/PostgresTriggerTestEntity.d.ts +0 -19
  53. package/build/testfixtures/PostgresTriggerTestEntity.js +0 -101
  54. package/build/testfixtures/PostgresTriggerTestEntity.js.map +0 -1
  55. package/build/testfixtures/PostgresUniqueTestEntity.d.ts +0 -19
  56. package/build/testfixtures/PostgresUniqueTestEntity.js +0 -62
  57. package/build/testfixtures/PostgresUniqueTestEntity.js.map +0 -1
  58. package/build/testfixtures/PostgresValidatorTestEntity.d.ts +0 -19
  59. package/build/testfixtures/PostgresValidatorTestEntity.js +0 -77
  60. package/build/testfixtures/PostgresValidatorTestEntity.js.map +0 -1
  61. package/build/testfixtures/createKnexIntegrationTestEntityCompanionProvider.d.ts +0 -3
  62. package/build/testfixtures/createKnexIntegrationTestEntityCompanionProvider.js +0 -29
  63. package/build/testfixtures/createKnexIntegrationTestEntityCompanionProvider.js.map +0 -1
@@ -1,19 +0,0 @@
1
- import { AlwaysAllowPrivacyPolicyRule, EntityPrivacyPolicy, ViewerContext, EntityConfiguration, EntityCompanionDefinition, Entity } from '@expo/entity';
2
- import { Knex } from 'knex';
3
- type PostgresTriggerTestEntityFields = {
4
- id: string;
5
- name: string | null;
6
- };
7
- export default class PostgresTriggerTestEntity extends Entity<PostgresTriggerTestEntityFields, string, ViewerContext> {
8
- static defineCompanionDefinition(): EntityCompanionDefinition<PostgresTriggerTestEntityFields, string, ViewerContext, PostgresTriggerTestEntity, PostgresTriggerTestEntityPrivacyPolicy>;
9
- static createOrTruncatePostgresTableAsync(knex: Knex): Promise<void>;
10
- static dropPostgresTableAsync(knex: Knex): Promise<void>;
11
- }
12
- declare class PostgresTriggerTestEntityPrivacyPolicy extends EntityPrivacyPolicy<PostgresTriggerTestEntityFields, string, ViewerContext, PostgresTriggerTestEntity> {
13
- protected readonly createRules: AlwaysAllowPrivacyPolicyRule<PostgresTriggerTestEntityFields, string, ViewerContext, PostgresTriggerTestEntity, keyof PostgresTriggerTestEntityFields>[];
14
- protected readonly readRules: AlwaysAllowPrivacyPolicyRule<PostgresTriggerTestEntityFields, string, ViewerContext, PostgresTriggerTestEntity, keyof PostgresTriggerTestEntityFields>[];
15
- protected readonly updateRules: AlwaysAllowPrivacyPolicyRule<PostgresTriggerTestEntityFields, string, ViewerContext, PostgresTriggerTestEntity, keyof PostgresTriggerTestEntityFields>[];
16
- protected readonly deleteRules: AlwaysAllowPrivacyPolicyRule<PostgresTriggerTestEntityFields, string, ViewerContext, PostgresTriggerTestEntity, keyof PostgresTriggerTestEntityFields>[];
17
- }
18
- export declare const postgresTestEntityConfiguration: EntityConfiguration<PostgresTriggerTestEntityFields>;
19
- export {};
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.postgresTestEntityConfiguration = void 0;
4
- const entity_1 = require("@expo/entity");
5
- class PostgresTriggerTestEntity extends entity_1.Entity {
6
- static defineCompanionDefinition() {
7
- return {
8
- entityClass: PostgresTriggerTestEntity,
9
- entityConfiguration: exports.postgresTestEntityConfiguration,
10
- privacyPolicyClass: PostgresTriggerTestEntityPrivacyPolicy,
11
- mutationTriggers: {
12
- beforeCreate: [new ThrowConditionallyTrigger('name', 'beforeCreate')],
13
- afterCreate: [new ThrowConditionallyTrigger('name', 'afterCreate')],
14
- beforeUpdate: [new ThrowConditionallyTrigger('name', 'beforeUpdate')],
15
- afterUpdate: [new ThrowConditionallyTrigger('name', 'afterUpdate')],
16
- beforeDelete: [new ThrowConditionallyTrigger('name', 'beforeDelete')],
17
- afterDelete: [new ThrowConditionallyTrigger('name', 'afterDelete')],
18
- beforeAll: [new ThrowConditionallyTrigger('name', 'beforeAll')],
19
- afterAll: [new ThrowConditionallyTrigger('name', 'afterAll')],
20
- afterCommit: [new ThrowConditionallyNonTransactionalTrigger('name', 'afterCommit')],
21
- },
22
- };
23
- }
24
- static async createOrTruncatePostgresTableAsync(knex) {
25
- const tableName = 'postgres_test_entities';
26
- const hasTable = await knex.schema.hasTable(tableName);
27
- if (!hasTable) {
28
- await knex.schema.createTable(tableName, (table) => {
29
- table.uuid('id').defaultTo(knex.raw('gen_random_uuid()')).primary();
30
- table.string('name');
31
- });
32
- }
33
- await knex.into(tableName).truncate();
34
- }
35
- static async dropPostgresTableAsync(knex) {
36
- const tableName = 'postgres_test_entities';
37
- const hasTable = await knex.schema.hasTable(tableName);
38
- if (hasTable) {
39
- await knex.schema.dropTable(tableName);
40
- }
41
- }
42
- }
43
- exports.default = PostgresTriggerTestEntity;
44
- class PostgresTriggerTestEntityPrivacyPolicy extends entity_1.EntityPrivacyPolicy {
45
- createRules = [
46
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
47
- ];
48
- readRules = [
49
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
50
- ];
51
- updateRules = [
52
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
53
- ];
54
- deleteRules = [
55
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
56
- ];
57
- }
58
- class ThrowConditionallyTrigger extends entity_1.EntityMutationTrigger {
59
- fieldName;
60
- badValue;
61
- constructor(fieldName, badValue) {
62
- super();
63
- this.fieldName = fieldName;
64
- this.badValue = badValue;
65
- }
66
- async executeAsync(_viewerContext, _queryContext, entity, _mutationInfo) {
67
- if (entity.getField(this.fieldName) === this.badValue) {
68
- throw new Error(`${this.fieldName} cannot have value ${this.badValue}`);
69
- }
70
- }
71
- }
72
- class ThrowConditionallyNonTransactionalTrigger extends entity_1.EntityNonTransactionalMutationTrigger {
73
- fieldName;
74
- badValue;
75
- constructor(fieldName, badValue) {
76
- super();
77
- this.fieldName = fieldName;
78
- this.badValue = badValue;
79
- }
80
- async executeAsync(_viewerContext, entity) {
81
- if (entity.getField(this.fieldName) === this.badValue) {
82
- throw new Error(`${this.fieldName} cannot have value ${this.badValue}`);
83
- }
84
- }
85
- }
86
- exports.postgresTestEntityConfiguration = new entity_1.EntityConfiguration({
87
- idField: 'id',
88
- tableName: 'postgres_test_entities',
89
- schema: {
90
- id: new entity_1.UUIDField({
91
- columnName: 'id',
92
- cache: true,
93
- }),
94
- name: new entity_1.StringField({
95
- columnName: 'name',
96
- }),
97
- },
98
- databaseAdapterFlavor: 'postgres',
99
- cacheAdapterFlavor: 'redis',
100
- });
101
- //# sourceMappingURL=PostgresTriggerTestEntity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostgresTrigger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C,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,sBAAsB,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;CACF;AAED,MAAM,yCAA0C,SAAQ,8CAKvD;IAEoB;IACA;IAFnB,YACmB,SAAgD,EAChD,QAAgB;QAEjC,KAAK,EAAE,CAAC;QAHS,cAAS,GAAT,SAAS,CAAuC;QAChD,aAAQ,GAAR,QAAQ,CAAQ;IAGnC,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,cAA6B,EAC7B,MAAiC;QAEjC,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,sBAAsB,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;CACF;AAEY,QAAA,+BAA+B,GAC1C,IAAI,4BAAmB,CAAkC;IACvD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,wBAAwB;IACnC,MAAM,EAAE;QACN,EAAE,EAAE,IAAI,kBAAS,CAAC;YAChB,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI;SACZ,CAAC;QACF,IAAI,EAAE,IAAI,oBAAW,CAAC;YACpB,UAAU,EAAE,MAAM;SACnB,CAAC;KACH;IACD,qBAAqB,EAAE,UAAU;IACjC,kBAAkB,EAAE,OAAO;CAC5B,CAAC,CAAC"}
@@ -1,19 +0,0 @@
1
- import { AlwaysAllowPrivacyPolicyRule, EntityPrivacyPolicy, ViewerContext, EntityConfiguration, EntityCompanionDefinition, Entity } from '@expo/entity';
2
- import { Knex } from 'knex';
3
- type PostgresUniqueTestEntityFields = {
4
- id: string;
5
- name: string | null;
6
- };
7
- export default class PostgresUniqueTestEntity extends Entity<PostgresUniqueTestEntityFields, string, ViewerContext> {
8
- static defineCompanionDefinition(): EntityCompanionDefinition<PostgresUniqueTestEntityFields, string, ViewerContext, PostgresUniqueTestEntity, PostgresUniqueTestEntityPrivacyPolicy>;
9
- static createOrTruncatePostgresTableAsync(knex: Knex): Promise<void>;
10
- static dropPostgresTableAsync(knex: Knex): Promise<void>;
11
- }
12
- declare class PostgresUniqueTestEntityPrivacyPolicy extends EntityPrivacyPolicy<PostgresUniqueTestEntityFields, string, ViewerContext, PostgresUniqueTestEntity> {
13
- protected readonly createRules: AlwaysAllowPrivacyPolicyRule<PostgresUniqueTestEntityFields, string, ViewerContext, PostgresUniqueTestEntity, keyof PostgresUniqueTestEntityFields>[];
14
- protected readonly readRules: AlwaysAllowPrivacyPolicyRule<PostgresUniqueTestEntityFields, string, ViewerContext, PostgresUniqueTestEntity, keyof PostgresUniqueTestEntityFields>[];
15
- protected readonly updateRules: AlwaysAllowPrivacyPolicyRule<PostgresUniqueTestEntityFields, string, ViewerContext, PostgresUniqueTestEntity, keyof PostgresUniqueTestEntityFields>[];
16
- protected readonly deleteRules: AlwaysAllowPrivacyPolicyRule<PostgresUniqueTestEntityFields, string, ViewerContext, PostgresUniqueTestEntity, keyof PostgresUniqueTestEntityFields>[];
17
- }
18
- export declare const postgresTestEntityConfiguration: EntityConfiguration<PostgresUniqueTestEntityFields>;
19
- export {};
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.postgresTestEntityConfiguration = void 0;
4
- const entity_1 = require("@expo/entity");
5
- class PostgresUniqueTestEntity extends entity_1.Entity {
6
- static defineCompanionDefinition() {
7
- return {
8
- entityClass: PostgresUniqueTestEntity,
9
- entityConfiguration: exports.postgresTestEntityConfiguration,
10
- privacyPolicyClass: PostgresUniqueTestEntityPrivacyPolicy,
11
- };
12
- }
13
- static async createOrTruncatePostgresTableAsync(knex) {
14
- const tableName = 'postgres_test_entities';
15
- const hasTable = await knex.schema.hasTable(tableName);
16
- if (!hasTable) {
17
- await knex.schema.createTable(tableName, (table) => {
18
- table.uuid('id').defaultTo(knex.raw('gen_random_uuid()')).primary();
19
- table.string('name').unique();
20
- });
21
- }
22
- await knex.into(tableName).truncate();
23
- }
24
- static async dropPostgresTableAsync(knex) {
25
- const tableName = 'postgres_test_entities';
26
- const hasTable = await knex.schema.hasTable(tableName);
27
- if (hasTable) {
28
- await knex.schema.dropTable(tableName);
29
- }
30
- }
31
- }
32
- exports.default = PostgresUniqueTestEntity;
33
- class PostgresUniqueTestEntityPrivacyPolicy extends entity_1.EntityPrivacyPolicy {
34
- createRules = [
35
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
36
- ];
37
- readRules = [
38
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
39
- ];
40
- updateRules = [
41
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
42
- ];
43
- deleteRules = [
44
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
45
- ];
46
- }
47
- exports.postgresTestEntityConfiguration = new entity_1.EntityConfiguration({
48
- idField: 'id',
49
- tableName: 'postgres_test_entities',
50
- schema: {
51
- id: new entity_1.UUIDField({
52
- columnName: 'id',
53
- cache: true,
54
- }),
55
- name: new entity_1.StringField({
56
- columnName: 'name',
57
- }),
58
- },
59
- databaseAdapterFlavor: 'postgres',
60
- cacheAdapterFlavor: 'redis',
61
- });
62
- //# sourceMappingURL=PostgresUniqueTestEntity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostgresUniqueTestEntity.js","sourceRoot":"","sources":["../../src/testfixtures/PostgresUniqueTestEntity.ts"],"names":[],"mappings":";;;AAAA,yCASsB;AAQtB,MAAqB,wBAAyB,SAAQ,eAIrD;IACC,MAAM,CAAC,yBAAyB;QAO9B,OAAO;YACL,WAAW,EAAE,wBAAwB;YACrC,mBAAmB,EAAE,uCAA+B;YACpD,kBAAkB,EAAE,qCAAqC;SAC1D,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,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AAiC;IACtD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,wBAAwB;IACnC,MAAM,EAAE;QACN,EAAE,EAAE,IAAI,kBAAS,CAAC;YAChB,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI;SACZ,CAAC;QACF,IAAI,EAAE,IAAI,oBAAW,CAAC;YACpB,UAAU,EAAE,MAAM;SACnB,CAAC;KACH;IACD,qBAAqB,EAAE,UAAU;IACjC,kBAAkB,EAAE,OAAO;CAC5B,CAAC,CAAC"}
@@ -1,19 +0,0 @@
1
- import { AlwaysAllowPrivacyPolicyRule, EntityPrivacyPolicy, ViewerContext, EntityConfiguration, EntityCompanionDefinition, Entity } from '@expo/entity';
2
- import { Knex } from 'knex';
3
- type PostgresValidatorTestEntityFields = {
4
- id: string;
5
- name: string | null;
6
- };
7
- export default class PostgresValidatorTestEntity extends Entity<PostgresValidatorTestEntityFields, string, ViewerContext> {
8
- static defineCompanionDefinition(): EntityCompanionDefinition<PostgresValidatorTestEntityFields, string, ViewerContext, PostgresValidatorTestEntity, PostgresValidatorTestEntityPrivacyPolicy>;
9
- static createOrTruncatePostgresTableAsync(knex: Knex): Promise<void>;
10
- static dropPostgresTableAsync(knex: Knex): Promise<void>;
11
- }
12
- declare class PostgresValidatorTestEntityPrivacyPolicy extends EntityPrivacyPolicy<PostgresValidatorTestEntityFields, string, ViewerContext, PostgresValidatorTestEntity> {
13
- protected readonly createRules: AlwaysAllowPrivacyPolicyRule<PostgresValidatorTestEntityFields, string, ViewerContext, PostgresValidatorTestEntity, keyof PostgresValidatorTestEntityFields>[];
14
- protected readonly readRules: AlwaysAllowPrivacyPolicyRule<PostgresValidatorTestEntityFields, string, ViewerContext, PostgresValidatorTestEntity, keyof PostgresValidatorTestEntityFields>[];
15
- protected readonly updateRules: AlwaysAllowPrivacyPolicyRule<PostgresValidatorTestEntityFields, string, ViewerContext, PostgresValidatorTestEntity, keyof PostgresValidatorTestEntityFields>[];
16
- protected readonly deleteRules: AlwaysAllowPrivacyPolicyRule<PostgresValidatorTestEntityFields, string, ViewerContext, PostgresValidatorTestEntity, keyof PostgresValidatorTestEntityFields>[];
17
- }
18
- export declare const postgresTestEntityConfiguration: EntityConfiguration<PostgresValidatorTestEntityFields>;
19
- export {};
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.postgresTestEntityConfiguration = void 0;
4
- const entity_1 = require("@expo/entity");
5
- class PostgresValidatorTestEntity extends entity_1.Entity {
6
- static defineCompanionDefinition() {
7
- return {
8
- entityClass: PostgresValidatorTestEntity,
9
- entityConfiguration: exports.postgresTestEntityConfiguration,
10
- privacyPolicyClass: PostgresValidatorTestEntityPrivacyPolicy,
11
- mutationValidators: [new ThrowConditionallyTrigger('name', 'beforeCreateAndBeforeUpdate')],
12
- };
13
- }
14
- static async createOrTruncatePostgresTableAsync(knex) {
15
- const tableName = 'postgres_test_entities';
16
- const hasTable = await knex.schema.hasTable(tableName);
17
- if (!hasTable) {
18
- await knex.schema.createTable(tableName, (table) => {
19
- table.uuid('id').defaultTo(knex.raw('gen_random_uuid()')).primary();
20
- table.string('name');
21
- });
22
- }
23
- await knex.into(tableName).truncate();
24
- }
25
- static async dropPostgresTableAsync(knex) {
26
- const tableName = 'postgres_test_entities';
27
- const hasTable = await knex.schema.hasTable(tableName);
28
- if (hasTable) {
29
- await knex.schema.dropTable(tableName);
30
- }
31
- }
32
- }
33
- exports.default = PostgresValidatorTestEntity;
34
- class PostgresValidatorTestEntityPrivacyPolicy extends entity_1.EntityPrivacyPolicy {
35
- createRules = [
36
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
37
- ];
38
- readRules = [
39
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
40
- ];
41
- updateRules = [
42
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
43
- ];
44
- deleteRules = [
45
- new entity_1.AlwaysAllowPrivacyPolicyRule(),
46
- ];
47
- }
48
- class ThrowConditionallyTrigger extends entity_1.EntityMutationTrigger {
49
- fieldName;
50
- badValue;
51
- constructor(fieldName, badValue) {
52
- super();
53
- this.fieldName = fieldName;
54
- this.badValue = badValue;
55
- }
56
- async executeAsync(_viewerContext, _queryContext, entity, _mutationInfo) {
57
- if (entity.getField(this.fieldName) === this.badValue) {
58
- throw new Error(`${this.fieldName} cannot have value ${this.badValue}`);
59
- }
60
- }
61
- }
62
- exports.postgresTestEntityConfiguration = new entity_1.EntityConfiguration({
63
- idField: 'id',
64
- tableName: 'postgres_test_entities',
65
- schema: {
66
- id: new entity_1.UUIDField({
67
- columnName: 'id',
68
- cache: true,
69
- }),
70
- name: new entity_1.StringField({
71
- columnName: 'name',
72
- }),
73
- },
74
- databaseAdapterFlavor: 'postgres',
75
- cacheAdapterFlavor: 'redis',
76
- });
77
- //# sourceMappingURL=PostgresValidatorTestEntity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostgresValidatorTestEntity.js","sourceRoot":"","sources":["../../src/testfixtures/PostgresValidatorTestEntity.ts"],"names":[],"mappings":";;;AAAA,yCAYsB;AAQtB,MAAqB,2BAA4B,SAAQ,eAIxD;IACC,MAAM,CAAC,yBAAyB;QAO9B,OAAO;YACL,WAAW,EAAE,2BAA2B;YACxC,mBAAmB,EAAE,uCAA+B;YACpD,kBAAkB,EAAE,wCAAwC;YAC5D,kBAAkB,EAAE,CAAC,IAAI,yBAAyB,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;SAC3F,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,kCAAkC,CAAC,IAAU;QAC/D,MAAM,SAAS,GAAG,wBAAwB,CAAC;QAC3C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;gBACjD,KAAK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AC;YACtD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,sBAAsB,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;CACF;AAEY,QAAA,+BAA+B,GAC1C,IAAI,4BAAmB,CAAoC;IACzD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,wBAAwB;IACnC,MAAM,EAAE;QACN,EAAE,EAAE,IAAI,kBAAS,CAAC;YAChB,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI;SACZ,CAAC;QACF,IAAI,EAAE,IAAI,oBAAW,CAAC;YACpB,UAAU,EAAE,MAAM;SACnB,CAAC;KACH;IACD,qBAAqB,EAAE,UAAU;IACjC,kBAAkB,EAAE,OAAO;CAC5B,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { IEntityMetricsAdapter, EntityCompanionProvider } from '@expo/entity';
2
- import { Knex } from 'knex';
3
- export declare const createKnexIntegrationTestEntityCompanionProvider: (knex: Knex, metricsAdapter?: IEntityMetricsAdapter) => EntityCompanionProvider;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createKnexIntegrationTestEntityCompanionProvider = void 0;
7
- const entity_1 = require("@expo/entity");
8
- const PostgresEntityDatabaseAdapterProvider_1 = __importDefault(require("../PostgresEntityDatabaseAdapterProvider"));
9
- const PostgresEntityQueryContextProvider_1 = __importDefault(require("../PostgresEntityQueryContextProvider"));
10
- const createKnexIntegrationTestEntityCompanionProvider = (knex, metricsAdapter = new entity_1.NoOpEntityMetricsAdapter()) => {
11
- return new entity_1.EntityCompanionProvider(metricsAdapter, new Map([
12
- [
13
- 'postgres',
14
- {
15
- adapterProvider: new PostgresEntityDatabaseAdapterProvider_1.default(),
16
- queryContextProvider: new PostgresEntityQueryContextProvider_1.default(knex),
17
- },
18
- ],
19
- ]), new Map([
20
- [
21
- 'redis',
22
- {
23
- cacheAdapterProvider: new entity_1.InMemoryFullCacheStubCacheAdapterProvider(),
24
- },
25
- ],
26
- ]));
27
- };
28
- exports.createKnexIntegrationTestEntityCompanionProvider = createKnexIntegrationTestEntityCompanionProvider;
29
- //# sourceMappingURL=createKnexIntegrationTestEntityCompanionProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createKnexIntegrationTestEntityCompanionProvider.js","sourceRoot":"","sources":["../../src/testfixtures/createKnexIntegrationTestEntityCompanionProvider.ts"],"names":[],"mappings":";;;;;;AAAA,yCAKsB;AAGtB,qHAA6F;AAC7F,+GAAuF;AAEhF,MAAM,gDAAgD,GAAG,CAC9D,IAAU,EACV,iBAAwC,IAAI,iCAAwB,EAAE,EAC7C,EAAE;IAC3B,OAAO,IAAI,gCAAuB,CAChC,cAAc,EACd,IAAI,GAAG,CAAC;QACN;YACE,UAAU;YACV;gBACE,eAAe,EAAE,IAAI,+CAAqC,EAAE;gBAC5D,oBAAoB,EAAE,IAAI,4CAAkC,CAAC,IAAI,CAAC;aACnE;SACF;KACF,CAAC,EACF,IAAI,GAAG,CAAC;QACN;YACE,OAAO;YACP;gBACE,oBAAoB,EAAE,IAAI,kDAAyC,EAAE;aACtE;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAxBW,QAAA,gDAAgD,oDAwB3D"}