@expo/entity 0.33.0 → 0.35.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/EntityFields.js +3 -2
- package/build/EntityFields.js.map +1 -1
- package/build/EntityMutationTriggerConfiguration.d.ts +5 -7
- package/build/EntityMutationTriggerConfiguration.js +3 -4
- package/build/EntityMutationTriggerConfiguration.js.map +1 -1
- package/build/IEntityCacheAdapterProvider.d.ts +1 -1
- package/build/__tests__/EntityFields-test.js +7 -1
- package/build/__tests__/EntityFields-test.js.map +1 -1
- package/package.json +2 -2
- package/src/EntityFields.ts +5 -3
- package/src/EntityMutationTriggerConfiguration.ts +5 -7
- package/src/IEntityCacheAdapterProvider.ts +1 -1
- package/src/__tests__/EntityFields-test.ts +7 -1
package/build/EntityFields.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnumField = exports.JSONObjectField = exports.StringArrayField = exports.FloatField = exports.IntField = exports.BooleanField = exports.DateField = exports.UUIDField = exports.StringField = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
4
|
const EntityFieldDefinition_1 = require("./EntityFieldDefinition");
|
|
5
|
+
// Use our own regex since the `uuid` package doesn't support validating UUIDv6/7/8 yet
|
|
6
|
+
const UUID_REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
6
7
|
/**
|
|
7
8
|
* EntityFieldDefinition for a column with a JS string type.
|
|
8
9
|
*/
|
|
@@ -18,7 +19,7 @@ exports.StringField = StringField;
|
|
|
18
19
|
*/
|
|
19
20
|
class UUIDField extends StringField {
|
|
20
21
|
validateInputValueInternal(value) {
|
|
21
|
-
return (
|
|
22
|
+
return super.validateInputValueInternal(value) && UUID_REGEX.test(value);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
exports.UUIDField = UUIDField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFields.js","sourceRoot":"","sources":["../src/EntityFields.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"EntityFields.js","sourceRoot":"","sources":["../src/EntityFields.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAEhE,uFAAuF;AACvF,MAAM,UAAU,GACd,0JAA0J,CAAC;AAE7J;;GAEG;AACH,MAAa,WAAY,SAAQ,6CAA6B;IAClD,0BAA0B,CAAC,KAAa;QAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;IACnC,CAAC;CACF;AAJD,kCAIC;AAED;;;GAGG;AACH,MAAa,SAAU,SAAQ,WAAW;IACrB,0BAA0B,CAAC,KAAa;QACzD,OAAO,KAAK,CAAC,0BAA0B,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3E,CAAC;CACF;AAJD,8BAIC;AAED;;GAEG;AACH,MAAa,SAAU,SAAQ,6CAA2B;IAC9C,0BAA0B,CAAC,KAAW;QAC9C,OAAO,KAAK,YAAY,IAAI,CAAC;IAC/B,CAAC;CACF;AAJD,8BAIC;AAED;;GAEG;AACH,MAAa,YAAa,SAAQ,6CAA8B;IACpD,0BAA0B,CAAC,KAAc;QACjD,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;IACpC,CAAC;CACF;AAJD,oCAIC;AAED;;;GAGG;AACH,MAAa,QAAS,SAAQ,6CAA6B;IAC/C,0BAA0B,CAAC,KAAa;QAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;CACF;AAJD,4BAIC;AAED;;;GAGG;AACH,MAAa,UAAW,SAAQ,6CAA6B;IACjD,0BAA0B,CAAC,KAAa;QAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;IACnC,CAAC;CACF;AAJD,gCAIC;AAED;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,6CAA+B;IACzD,0BAA0B,CAAC,KAAe;QAClD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC;IACzF,CAAC;CACF;AAJD,4CAIC;AAED;;GAEG;AACH,MAAa,eAAgB,SAAQ,6CAA6B;IACtD,0BAA0B,CAAC,KAAa;QAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;CACF;AAJD,0CAIC;AAED;;GAEG;AACH,MAAa,SAAU,SAAQ,6CAAsC;IACzD,0BAA0B,CAAC,KAAsB;QACzD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;IAChE,CAAC;CACF;AAJD,8BAIC"}
|
|
@@ -40,23 +40,21 @@ export default interface EntityMutationTriggerConfiguration<TFields extends obje
|
|
|
40
40
|
*/
|
|
41
41
|
afterAll?: EntityMutationTrigger<TFields, TID, TViewerContext, TEntity, TSelectedFields>[];
|
|
42
42
|
/**
|
|
43
|
-
* Trigger set that runs after committing the transaction
|
|
44
|
-
*
|
|
45
|
-
* this too will be within the transaction.
|
|
43
|
+
* Trigger set that runs after committing the mutation transaction. If the call to the mutation is wrapped in a transaction, these
|
|
44
|
+
* will be run after the wrapping transaction is completed.
|
|
46
45
|
*/
|
|
47
46
|
afterCommit?: EntityNonTransactionalMutationTrigger<TFields, TID, TViewerContext, TEntity, TSelectedFields>[];
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
|
-
* A trigger is a way to specify entity mutation operation side-effects that run within the
|
|
51
|
-
* same transaction as the mutation itself.
|
|
52
|
-
* the transaction if a transaction is supplied.
|
|
49
|
+
* A transactional trigger is a way to specify entity mutation operation side-effects that run within the
|
|
50
|
+
* same transaction as the mutation itself.
|
|
53
51
|
*/
|
|
54
52
|
export declare abstract class EntityMutationTrigger<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TSelectedFields extends keyof TFields = keyof TFields> {
|
|
55
53
|
abstract executeAsync(viewerContext: TViewerContext, queryContext: EntityTransactionalQueryContext, entity: TEntity, mutationInfo: EntityTriggerMutationInfo<TFields, TID, TViewerContext, TEntity, TSelectedFields>): Promise<void>;
|
|
56
54
|
}
|
|
57
55
|
/**
|
|
58
56
|
* A non-transactional trigger is like a EntityMutationTrigger but used for afterCommit triggers
|
|
59
|
-
* since they
|
|
57
|
+
* since they run after the transaction is committed.
|
|
60
58
|
*/
|
|
61
59
|
export declare abstract class EntityNonTransactionalMutationTrigger<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TSelectedFields extends keyof TFields = keyof TFields> {
|
|
62
60
|
abstract executeAsync(viewerContext: TViewerContext, entity: TEntity, mutationInfo: EntityTriggerMutationInfo<TFields, TID, TViewerContext, TEntity, TSelectedFields>): Promise<void>;
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EntityNonTransactionalMutationTrigger = exports.EntityMutationTrigger = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* A trigger is a way to specify entity mutation operation side-effects that run within the
|
|
6
|
-
* same transaction as the mutation itself.
|
|
7
|
-
* the transaction if a transaction is supplied.
|
|
5
|
+
* A transactional trigger is a way to specify entity mutation operation side-effects that run within the
|
|
6
|
+
* same transaction as the mutation itself.
|
|
8
7
|
*/
|
|
9
8
|
class EntityMutationTrigger {
|
|
10
9
|
}
|
|
11
10
|
exports.EntityMutationTrigger = EntityMutationTrigger;
|
|
12
11
|
/**
|
|
13
12
|
* A non-transactional trigger is like a EntityMutationTrigger but used for afterCommit triggers
|
|
14
|
-
* since they
|
|
13
|
+
* since they run after the transaction is committed.
|
|
15
14
|
*/
|
|
16
15
|
class EntityNonTransactionalMutationTrigger {
|
|
17
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityMutationTriggerConfiguration.js","sourceRoot":"","sources":["../src/EntityMutationTriggerConfiguration.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"EntityMutationTriggerConfiguration.js","sourceRoot":"","sources":["../src/EntityMutationTriggerConfiguration.ts"],"names":[],"mappings":";;;AAiEA;;;GAGG;AACH,MAAsB,qBAAqB;CAa1C;AAbD,sDAaC;AAED;;;GAGG;AACH,MAAsB,qCAAqC;CAY1D;AAZD,sFAYC"}
|
|
@@ -6,7 +6,7 @@ import IEntityCacheAdapter from './IEntityCacheAdapter';
|
|
|
6
6
|
*/
|
|
7
7
|
export default interface IEntityCacheAdapterProvider {
|
|
8
8
|
/**
|
|
9
|
-
* Vend a cache adapter.
|
|
9
|
+
* Vend a cache adapter for an entity configuration.
|
|
10
10
|
*/
|
|
11
11
|
getCacheAdapter<TFields>(entityConfiguration: EntityConfiguration<TFields>): IEntityCacheAdapter<TFields>;
|
|
12
12
|
}
|
|
@@ -39,7 +39,13 @@ describe(EntityFieldDefinition_1.EntityFieldDefinition, () => {
|
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
(0, describeFieldTestCase_1.default)(new EntityFields_1.StringField({ columnName: 'wat' }), ['hello', ''], [1, true, {}, [[]]]);
|
|
42
|
-
(0, describeFieldTestCase_1.default)(new EntityFields_1.UUIDField({ columnName: 'wat' }), [
|
|
42
|
+
(0, describeFieldTestCase_1.default)(new EntityFields_1.UUIDField({ columnName: 'wat' }), [
|
|
43
|
+
(0, uuid_1.v1)(),
|
|
44
|
+
(0, uuid_1.v3)('wat', uuid_1.v3.DNS),
|
|
45
|
+
(0, uuid_1.v4)(),
|
|
46
|
+
(0, uuid_1.v5)('wat', uuid_1.v5.DNS),
|
|
47
|
+
/* UUIDv7 */ '018ebfda-dc80-782d-a891-22a0aa057d52',
|
|
48
|
+
], [(0, uuid_1.v4)().replace('-', ''), '', 'hello']);
|
|
43
49
|
(0, describeFieldTestCase_1.default)(new EntityFields_1.DateField({ columnName: 'wat' }), [new Date()], [Date.now()]);
|
|
44
50
|
(0, describeFieldTestCase_1.default)(new EntityFields_1.BooleanField({ columnName: 'wat' }), [true, false], [0, 1, '']);
|
|
45
51
|
(0, describeFieldTestCase_1.default)(new EntityFields_1.IntField({ columnName: 'wat' }), [1], ['1', 0.5, true]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFields-test.js","sourceRoot":"","sources":["../../src/__tests__/EntityFields-test.ts"],"names":[],"mappings":";;;;;AAAA,+BAA8E;AAE9E,oEAAiE;AACjE,kDAUyB;AACzB,mGAA2E;AAE3E,MAAM,mBAAoB,SAAQ,6CAA6B;IACnD,0BAA0B,CAAC,KAAa;QAChD,OAAO,KAAK,KAAK,YAAY,CAAC;IAChC,CAAC;CACF;AAED,QAAQ,CAAC,6CAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,gBAAgB,GAAG,IAAI,mBAAmB,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACxE,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACnD,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE9C,MAAM,gBAAgB,GAAG,IAAI,mBAAmB,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC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AC,GAAG,CAAC,CAAC,CAAC;AACpF,IAAA,+BAAqB,EACnB,IAAI,+BAAgB,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAC3C,CAAC,CAAC,CAAC,MAAM,CAAC,CAAQ,EAAE,CAAC,EAAE,CAAQ,CAAC,EAAE,4CAA4C;AAC9E,CAAC,OAAO,CAAC,CACV,CAAC;AACF,IAAA,+BAAqB,EAAC,IAAI,8BAAe,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AACzF,IAAA,+BAAqB,EAAC,IAAI,wBAAS,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/entity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "A privacy-first data model",
|
|
5
5
|
"files": [
|
|
6
6
|
"build",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"invariant": "^2.2.4",
|
|
34
34
|
"uuid": "^8.3.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "33771295c5da92768114c6cdd1f48936435853cc"
|
|
37
37
|
}
|
package/src/EntityFields.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { validate as validateUUID } from 'uuid';
|
|
2
|
-
|
|
3
1
|
import { EntityFieldDefinition } from './EntityFieldDefinition';
|
|
4
2
|
|
|
3
|
+
// Use our own regex since the `uuid` package doesn't support validating UUIDv6/7/8 yet
|
|
4
|
+
const UUID_REGEX =
|
|
5
|
+
/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* EntityFieldDefinition for a column with a JS string type.
|
|
7
9
|
*/
|
|
@@ -17,7 +19,7 @@ export class StringField extends EntityFieldDefinition<string> {
|
|
|
17
19
|
*/
|
|
18
20
|
export class UUIDField extends StringField {
|
|
19
21
|
protected override validateInputValueInternal(value: string): boolean {
|
|
20
|
-
return
|
|
22
|
+
return super.validateInputValueInternal(value) && UUID_REGEX.test(value);
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -51,9 +51,8 @@ export default interface EntityMutationTriggerConfiguration<
|
|
|
51
51
|
afterAll?: EntityMutationTrigger<TFields, TID, TViewerContext, TEntity, TSelectedFields>[];
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* Trigger set that runs after committing the transaction
|
|
55
|
-
*
|
|
56
|
-
* this too will be within the transaction.
|
|
54
|
+
* Trigger set that runs after committing the mutation transaction. If the call to the mutation is wrapped in a transaction, these
|
|
55
|
+
* will be run after the wrapping transaction is completed.
|
|
57
56
|
*/
|
|
58
57
|
afterCommit?: EntityNonTransactionalMutationTrigger<
|
|
59
58
|
TFields,
|
|
@@ -65,9 +64,8 @@ export default interface EntityMutationTriggerConfiguration<
|
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
/**
|
|
68
|
-
* A trigger is a way to specify entity mutation operation side-effects that run within the
|
|
69
|
-
* same transaction as the mutation itself.
|
|
70
|
-
* the transaction if a transaction is supplied.
|
|
67
|
+
* A transactional trigger is a way to specify entity mutation operation side-effects that run within the
|
|
68
|
+
* same transaction as the mutation itself.
|
|
71
69
|
*/
|
|
72
70
|
export abstract class EntityMutationTrigger<
|
|
73
71
|
TFields extends object,
|
|
@@ -86,7 +84,7 @@ export abstract class EntityMutationTrigger<
|
|
|
86
84
|
|
|
87
85
|
/**
|
|
88
86
|
* A non-transactional trigger is like a EntityMutationTrigger but used for afterCommit triggers
|
|
89
|
-
* since they
|
|
87
|
+
* since they run after the transaction is committed.
|
|
90
88
|
*/
|
|
91
89
|
export abstract class EntityNonTransactionalMutationTrigger<
|
|
92
90
|
TFields extends object,
|
|
@@ -7,7 +7,7 @@ import IEntityCacheAdapter from './IEntityCacheAdapter';
|
|
|
7
7
|
*/
|
|
8
8
|
export default interface IEntityCacheAdapterProvider {
|
|
9
9
|
/**
|
|
10
|
-
* Vend a cache adapter.
|
|
10
|
+
* Vend a cache adapter for an entity configuration.
|
|
11
11
|
*/
|
|
12
12
|
getCacheAdapter<TFields>(
|
|
13
13
|
entityConfiguration: EntityConfiguration<TFields>
|
|
@@ -55,7 +55,13 @@ describe(EntityFieldDefinition, () => {
|
|
|
55
55
|
describeFieldTestCase(new StringField({ columnName: 'wat' }), ['hello', ''], [1, true, {}, [[]]]);
|
|
56
56
|
describeFieldTestCase(
|
|
57
57
|
new UUIDField({ columnName: 'wat' }),
|
|
58
|
-
[
|
|
58
|
+
[
|
|
59
|
+
uuidv1(),
|
|
60
|
+
uuidv3('wat', uuidv3.DNS),
|
|
61
|
+
uuidv4(),
|
|
62
|
+
uuidv5('wat', uuidv5.DNS),
|
|
63
|
+
/* UUIDv7 */ '018ebfda-dc80-782d-a891-22a0aa057d52',
|
|
64
|
+
],
|
|
59
65
|
[uuidv4().replace('-', ''), '', 'hello']
|
|
60
66
|
);
|
|
61
67
|
describeFieldTestCase(new DateField({ columnName: 'wat' }), [new Date()], [Date.now()]);
|