@snowtop/ent 0.2.0-alpha.10 → 0.2.0-alpha.11-test1
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/action/action.js +5 -5
- package/action/executor.d.ts +1 -1
- package/action/executor.js +4 -4
- package/action/experimental_action.js +5 -5
- package/action/orchestrator.d.ts +2 -2
- package/action/privacy.d.ts +2 -2
- package/action/relative_value.js +3 -3
- package/auth/auth.d.ts +0 -1
- package/auth/auth.js +4 -5
- package/core/base.js +5 -5
- package/core/clause.js +59 -60
- package/core/config.d.ts +0 -1
- package/core/config.js +1 -2
- package/core/context.d.ts +0 -1
- package/core/convert.d.ts +0 -1
- package/core/convert.js +16 -17
- package/core/date.js +1 -2
- package/core/ent.js +50 -51
- package/core/global_schema.js +6 -7
- package/core/loaders/assoc_count_loader.d.ts +2 -2
- package/core/loaders/assoc_edge_loader.d.ts +2 -2
- package/core/loaders/loader.js +3 -3
- package/core/loaders/object_loader.d.ts +4 -4
- package/core/loaders/query_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.js +2 -2
- package/core/logger.js +6 -7
- package/core/privacy.d.ts +2 -2
- package/core/privacy.js +4 -4
- package/core/query/shared_assoc_test.js +1 -2
- package/core/query_impl.js +4 -5
- package/core/viewer.d.ts +2 -2
- package/graphql/graphql_field_helpers.js +22 -22
- package/graphql/mutations/union.js +1 -2
- package/graphql/node_resolver.js +7 -7
- package/graphql/query/shared_assoc_test.js +1 -2
- package/graphql/scalars/time.d.ts +1 -1
- package/imports/dataz/example1/_auth.js +14 -10
- package/imports/index.js +1 -2
- package/names/names.js +5 -6
- package/package.json +13 -13
- package/parse_schema/parse.js +2 -3
- package/schema/binary_field.d.ts +2 -2
- package/schema/binary_field.js +3 -3
- package/schema/field.js +28 -28
- package/schema/json_field.js +7 -7
- package/schema/schema.js +12 -12
- package/schema/struct_field.js +4 -4
- package/schema/union_field.js +3 -3
- package/testutils/action/complex_schemas.js +11 -11
- package/testutils/builder.d.ts +1 -1
- package/testutils/builder.js +7 -7
- package/testutils/db/fixture.js +1 -2
- package/testutils/db/temp_db.js +37 -37
- package/testutils/db/value.js +3 -4
- package/testutils/db_mock.js +38 -6
- package/testutils/ent-graphql-tests/index.d.ts +3 -3
- package/testutils/ent-graphql-tests/index.js +10 -11
- package/testutils/fake_data/const.js +2 -2
- package/testutils/fake_data/fake_contact.js +3 -3
- package/testutils/fake_data/fake_event.js +3 -3
- package/testutils/fake_data/fake_tag.js +4 -4
- package/testutils/fake_data/fake_user.js +4 -4
- package/testutils/fake_data/test_helpers.js +17 -17
- package/testutils/fake_data/user_query.js +2 -2
- package/testutils/parse_sql.js +3 -3
- package/testutils/query.js +2 -3
- package/testutils/write.js +3 -4
- package/tsc/ast.js +10 -11
- package/tsc/compilerOptions.js +4 -5
- package/tsc/move_generated.js +1 -2
- package/tsc/transform.js +1 -2
package/schema/field.js
CHANGED
|
@@ -23,7 +23,34 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.ListField = exports.IntegerEnumField = exports.StringEnumField = exports.EnumField = exports.DateField = exports.TimeField = exports.leftPad = exports.TimestampField = exports.PolymorphicStringField = exports.StringField = exports.BooleanField = exports.FloatField = exports.BigIntegerField = exports.IntegerField = exports.NumberField = exports.UUIDField = exports.BaseField = void 0;
|
|
27
|
+
exports.UUIDType = UUIDType;
|
|
28
|
+
exports.IntegerType = IntegerType;
|
|
29
|
+
exports.BigIntegerType = BigIntegerType;
|
|
30
|
+
exports.FloatType = FloatType;
|
|
31
|
+
exports.BooleanType = BooleanType;
|
|
32
|
+
exports.StringType = StringType;
|
|
33
|
+
exports.TimestampType = TimestampType;
|
|
34
|
+
exports.TimestamptzType = TimestamptzType;
|
|
35
|
+
exports.TimeType = TimeType;
|
|
36
|
+
exports.TimetzType = TimetzType;
|
|
37
|
+
exports.DateType = DateType;
|
|
38
|
+
exports.EnumType = EnumType;
|
|
39
|
+
exports.IntegerEnumType = IntegerEnumType;
|
|
40
|
+
exports.StringListType = StringListType;
|
|
41
|
+
exports.IntListType = IntListType;
|
|
42
|
+
exports.IntegerListType = IntegerListType;
|
|
43
|
+
exports.FloatListType = FloatListType;
|
|
44
|
+
exports.BigIntegerListType = BigIntegerListType;
|
|
45
|
+
exports.BooleanListType = BooleanListType;
|
|
46
|
+
exports.TimestampListType = TimestampListType;
|
|
47
|
+
exports.TimestamptzListType = TimestamptzListType;
|
|
48
|
+
exports.TimeListType = TimeListType;
|
|
49
|
+
exports.TimetzListType = TimetzListType;
|
|
50
|
+
exports.DateListType = DateListType;
|
|
51
|
+
exports.EnumListType = EnumListType;
|
|
52
|
+
exports.IntegerEnumListType = IntegerEnumListType;
|
|
53
|
+
exports.UUIDListType = UUIDListType;
|
|
27
54
|
const luxon_1 = require("luxon");
|
|
28
55
|
const types_1 = require("util/types");
|
|
29
56
|
const uuid_1 = require("uuid");
|
|
@@ -121,7 +148,6 @@ function UUIDType(options) {
|
|
|
121
148
|
let result = new UUIDField(options);
|
|
122
149
|
return Object.assign(result, options);
|
|
123
150
|
}
|
|
124
|
-
exports.UUIDType = UUIDType;
|
|
125
151
|
class NumberField extends BaseField {
|
|
126
152
|
constructor(options) {
|
|
127
153
|
super();
|
|
@@ -181,7 +207,6 @@ function IntegerType(options) {
|
|
|
181
207
|
let result = new IntegerField(options);
|
|
182
208
|
return Object.assign(result, options);
|
|
183
209
|
}
|
|
184
|
-
exports.IntegerType = IntegerType;
|
|
185
210
|
class BigIntegerField extends NumberField {
|
|
186
211
|
constructor() {
|
|
187
212
|
super(...arguments);
|
|
@@ -193,7 +218,6 @@ function BigIntegerType(options) {
|
|
|
193
218
|
let result = new BigIntegerField(options);
|
|
194
219
|
return Object.assign(result, options);
|
|
195
220
|
}
|
|
196
|
-
exports.BigIntegerType = BigIntegerType;
|
|
197
221
|
class FloatField extends NumberField {
|
|
198
222
|
constructor() {
|
|
199
223
|
super(...arguments);
|
|
@@ -205,7 +229,6 @@ function FloatType(options) {
|
|
|
205
229
|
let result = new FloatField(options);
|
|
206
230
|
return Object.assign(result, options);
|
|
207
231
|
}
|
|
208
|
-
exports.FloatType = FloatType;
|
|
209
232
|
class BooleanField extends BaseField {
|
|
210
233
|
constructor() {
|
|
211
234
|
super(...arguments);
|
|
@@ -217,7 +240,6 @@ function BooleanType(options) {
|
|
|
217
240
|
let result = new BooleanField();
|
|
218
241
|
return Object.assign(result, options);
|
|
219
242
|
}
|
|
220
|
-
exports.BooleanType = BooleanType;
|
|
221
243
|
class StringField extends BaseField {
|
|
222
244
|
constructor(options) {
|
|
223
245
|
super();
|
|
@@ -387,7 +409,6 @@ function StringType(options) {
|
|
|
387
409
|
}
|
|
388
410
|
return Object.assign(result, options2);
|
|
389
411
|
}
|
|
390
|
-
exports.StringType = StringType;
|
|
391
412
|
class TimestampField extends BaseField {
|
|
392
413
|
constructor(options) {
|
|
393
414
|
super();
|
|
@@ -420,13 +441,11 @@ function TimestampType(options) {
|
|
|
420
441
|
let result = new TimestampField({ ...options });
|
|
421
442
|
return Object.assign(result, options);
|
|
422
443
|
}
|
|
423
|
-
exports.TimestampType = TimestampType;
|
|
424
444
|
function TimestamptzType(options) {
|
|
425
445
|
let opts = { withTimezone: true, ...options };
|
|
426
446
|
let result = new TimestampField(opts);
|
|
427
447
|
return Object.assign(result, opts);
|
|
428
448
|
}
|
|
429
|
-
exports.TimestamptzType = TimestamptzType;
|
|
430
449
|
const leftPad = (val) => {
|
|
431
450
|
if (val >= 0) {
|
|
432
451
|
if (val < 10) {
|
|
@@ -479,7 +498,6 @@ function TimeType(options) {
|
|
|
479
498
|
let result = new TimeField(options);
|
|
480
499
|
return Object.assign(result, options);
|
|
481
500
|
}
|
|
482
|
-
exports.TimeType = TimeType;
|
|
483
501
|
function TimetzType(options) {
|
|
484
502
|
let opts = {
|
|
485
503
|
withTimezone: true,
|
|
@@ -488,7 +506,6 @@ function TimetzType(options) {
|
|
|
488
506
|
let result = new TimeField(opts);
|
|
489
507
|
return Object.assign(result, opts);
|
|
490
508
|
}
|
|
491
|
-
exports.TimetzType = TimetzType;
|
|
492
509
|
class DateField extends BaseField {
|
|
493
510
|
constructor() {
|
|
494
511
|
super(...arguments);
|
|
@@ -513,7 +530,6 @@ function DateType(options) {
|
|
|
513
530
|
let result = new DateField();
|
|
514
531
|
return Object.assign(result, options);
|
|
515
532
|
}
|
|
516
|
-
exports.DateType = DateType;
|
|
517
533
|
/**
|
|
518
534
|
* @deprecated Use StringEnumField
|
|
519
535
|
*/
|
|
@@ -616,7 +632,6 @@ function EnumType(options) {
|
|
|
616
632
|
let result = new StringEnumField(options);
|
|
617
633
|
return Object.assign(result, options);
|
|
618
634
|
}
|
|
619
|
-
exports.EnumType = EnumType;
|
|
620
635
|
class IntegerEnumField extends BaseField {
|
|
621
636
|
constructor(options) {
|
|
622
637
|
super();
|
|
@@ -691,7 +706,6 @@ function IntegerEnumType(options) {
|
|
|
691
706
|
let result = new IntegerEnumField(options);
|
|
692
707
|
return Object.assign(result, options);
|
|
693
708
|
}
|
|
694
|
-
exports.IntegerEnumType = IntegerEnumType;
|
|
695
709
|
class ListField extends BaseField {
|
|
696
710
|
constructor(field, options) {
|
|
697
711
|
super();
|
|
@@ -815,47 +829,36 @@ exports.ListField = ListField;
|
|
|
815
829
|
function StringListType(options) {
|
|
816
830
|
return new ListField(StringType(options), options);
|
|
817
831
|
}
|
|
818
|
-
exports.StringListType = StringListType;
|
|
819
832
|
function IntListType(options) {
|
|
820
833
|
return new ListField(IntegerType(options), options);
|
|
821
834
|
}
|
|
822
|
-
exports.IntListType = IntListType;
|
|
823
835
|
function IntegerListType(options) {
|
|
824
836
|
return new ListField(IntegerType(options), options);
|
|
825
837
|
}
|
|
826
|
-
exports.IntegerListType = IntegerListType;
|
|
827
838
|
function FloatListType(options) {
|
|
828
839
|
return new ListField(FloatType(options), options);
|
|
829
840
|
}
|
|
830
|
-
exports.FloatListType = FloatListType;
|
|
831
841
|
function BigIntegerListType(options) {
|
|
832
842
|
return new ListField(BigIntegerType(options), options);
|
|
833
843
|
}
|
|
834
|
-
exports.BigIntegerListType = BigIntegerListType;
|
|
835
844
|
function BooleanListType(options) {
|
|
836
845
|
return new ListField(BooleanType(options), options);
|
|
837
846
|
}
|
|
838
|
-
exports.BooleanListType = BooleanListType;
|
|
839
847
|
function TimestampListType(options) {
|
|
840
848
|
return new ListField(TimestampType(options), options);
|
|
841
849
|
}
|
|
842
|
-
exports.TimestampListType = TimestampListType;
|
|
843
850
|
function TimestamptzListType(options) {
|
|
844
851
|
return new ListField(TimestamptzType(options), options);
|
|
845
852
|
}
|
|
846
|
-
exports.TimestamptzListType = TimestamptzListType;
|
|
847
853
|
function TimeListType(options) {
|
|
848
854
|
return new ListField(TimeType(options), options);
|
|
849
855
|
}
|
|
850
|
-
exports.TimeListType = TimeListType;
|
|
851
856
|
function TimetzListType(options) {
|
|
852
857
|
return new ListField(TimetzType(options), options);
|
|
853
858
|
}
|
|
854
|
-
exports.TimetzListType = TimetzListType;
|
|
855
859
|
function DateListType(options) {
|
|
856
860
|
return new ListField(DateType(options), options);
|
|
857
861
|
}
|
|
858
|
-
exports.DateListType = DateListType;
|
|
859
862
|
function EnumListType(options) {
|
|
860
863
|
if (options.createEnumType) {
|
|
861
864
|
throw new Error(`createEnumType is currently unsupported in enum list`);
|
|
@@ -869,7 +872,6 @@ function EnumListType(options) {
|
|
|
869
872
|
// unclear what the behavior is
|
|
870
873
|
return new ListField(EnumType(options), options);
|
|
871
874
|
}
|
|
872
|
-
exports.EnumListType = EnumListType;
|
|
873
875
|
function IntegerEnumListType(options) {
|
|
874
876
|
// not all of these will make sense in a list...
|
|
875
877
|
// can make it work eventually but involves work we're not currently trying to do
|
|
@@ -877,11 +879,9 @@ function IntegerEnumListType(options) {
|
|
|
877
879
|
// unclear what the behavior is
|
|
878
880
|
return new ListField(IntegerEnumType(options), options);
|
|
879
881
|
}
|
|
880
|
-
exports.IntegerEnumListType = IntegerEnumListType;
|
|
881
882
|
function UUIDListType(options) {
|
|
882
883
|
return new ListField(UUIDType(options), {
|
|
883
884
|
...options,
|
|
884
885
|
disableJSONStringify: true,
|
|
885
886
|
});
|
|
886
887
|
}
|
|
887
|
-
exports.UUIDListType = UUIDListType;
|
package/schema/json_field.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.JSONField = void 0;
|
|
4
|
+
exports.JSONType = JSONType;
|
|
5
|
+
exports.JSONBType = JSONBType;
|
|
6
|
+
exports.JSONBListType = JSONBListType;
|
|
7
|
+
exports.JSONListType = JSONListType;
|
|
8
|
+
exports.JSONBTypeAsList = JSONBTypeAsList;
|
|
9
|
+
exports.JSONTypeAsList = JSONTypeAsList;
|
|
4
10
|
const schema_1 = require("./schema");
|
|
5
11
|
const field_1 = require("./field");
|
|
6
12
|
class JSONField extends field_1.BaseField {
|
|
@@ -40,26 +46,22 @@ function JSONType(options) {
|
|
|
40
46
|
let result = new JSONField(false, options);
|
|
41
47
|
return Object.assign(result, options);
|
|
42
48
|
}
|
|
43
|
-
exports.JSONType = JSONType;
|
|
44
49
|
function JSONBType(options) {
|
|
45
50
|
let result = new JSONField(true, options);
|
|
46
51
|
return Object.assign(result, options);
|
|
47
52
|
}
|
|
48
|
-
exports.JSONBType = JSONBType;
|
|
49
53
|
/**
|
|
50
54
|
* @deprecated use JSONBTypeAsList
|
|
51
55
|
*/
|
|
52
56
|
function JSONBListType(options) {
|
|
53
57
|
return new field_1.ListField(JSONBType(options), options);
|
|
54
58
|
}
|
|
55
|
-
exports.JSONBListType = JSONBListType;
|
|
56
59
|
/**
|
|
57
60
|
* @deprecated use JSONTypeAsList
|
|
58
61
|
*/
|
|
59
62
|
function JSONListType(options) {
|
|
60
63
|
return new field_1.ListField(JSONType(options), options);
|
|
61
64
|
}
|
|
62
|
-
exports.JSONListType = JSONListType;
|
|
63
65
|
function JSONBTypeAsList(options) {
|
|
64
66
|
let result = new JSONField(true, {
|
|
65
67
|
...options,
|
|
@@ -67,7 +69,6 @@ function JSONBTypeAsList(options) {
|
|
|
67
69
|
});
|
|
68
70
|
return Object.assign(result, options);
|
|
69
71
|
}
|
|
70
|
-
exports.JSONBTypeAsList = JSONBTypeAsList;
|
|
71
72
|
function JSONTypeAsList(options) {
|
|
72
73
|
let result = new JSONField(false, {
|
|
73
74
|
...options,
|
|
@@ -75,4 +76,3 @@ function JSONTypeAsList(options) {
|
|
|
75
76
|
});
|
|
76
77
|
return Object.assign(result, options);
|
|
77
78
|
}
|
|
78
|
-
exports.JSONTypeAsList = JSONTypeAsList;
|
package/schema/schema.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConstraintType = exports.
|
|
3
|
+
exports.ConstraintType = exports.NoFields = exports.ActionOperation = exports.DBType = exports.SQLStatementOperation = void 0;
|
|
4
|
+
exports.getSchema = getSchema;
|
|
5
|
+
exports.getFields = getFields;
|
|
6
|
+
exports.getStorageKey = getStorageKey;
|
|
7
|
+
exports.getFieldsWithPrivacy = getFieldsWithPrivacy;
|
|
8
|
+
exports.getFieldsWithEditPrivacy = getFieldsWithEditPrivacy;
|
|
9
|
+
exports.getFieldsForCreateAction = getFieldsForCreateAction;
|
|
10
|
+
exports.getTransformedReadClause = getTransformedReadClause;
|
|
11
|
+
exports.getObjectLoaderProperties = getObjectLoaderProperties;
|
|
12
|
+
exports.getTransformedUpdateOp = getTransformedUpdateOp;
|
|
13
|
+
exports.requiredField = requiredField;
|
|
14
|
+
exports.optionalField = optionalField;
|
|
4
15
|
const names_1 = require("../names/names");
|
|
5
16
|
// we also want this transformation to exist on a per-action basis
|
|
6
17
|
// if it exists on an action, we don't do the global schema transformation
|
|
@@ -54,7 +65,6 @@ function getSchema(value) {
|
|
|
54
65
|
return new value();
|
|
55
66
|
}
|
|
56
67
|
}
|
|
57
|
-
exports.getSchema = getSchema;
|
|
58
68
|
function getFields(value) {
|
|
59
69
|
const schema = getSchema(value);
|
|
60
70
|
function addFields(fields) {
|
|
@@ -78,27 +88,22 @@ function getFields(value) {
|
|
|
78
88
|
addFields(schema.fields);
|
|
79
89
|
return m;
|
|
80
90
|
}
|
|
81
|
-
exports.getFields = getFields;
|
|
82
91
|
function getStorageKey(field, fieldName) {
|
|
83
92
|
return field.storageKey || (0, names_1.toDBColumnOrTable)(fieldName);
|
|
84
93
|
}
|
|
85
|
-
exports.getStorageKey = getStorageKey;
|
|
86
94
|
// returns a mapping of storage key to field privacy
|
|
87
95
|
function getFieldsWithPrivacy(value, fieldInfoMap) {
|
|
88
96
|
return getFieldsWithPrivacyImpl(value, fieldInfoMap, ["privacyPolicy"]);
|
|
89
97
|
}
|
|
90
|
-
exports.getFieldsWithPrivacy = getFieldsWithPrivacy;
|
|
91
98
|
function getFieldsWithEditPrivacy(value, fieldInfoMap) {
|
|
92
99
|
return getFieldsWithPrivacyImpl(value, fieldInfoMap, ["editPrivacyPolicy"]);
|
|
93
100
|
}
|
|
94
|
-
exports.getFieldsWithEditPrivacy = getFieldsWithEditPrivacy;
|
|
95
101
|
function getFieldsForCreateAction(value, fieldInfoMap) {
|
|
96
102
|
return getFieldsWithPrivacyImpl(value, fieldInfoMap, [
|
|
97
103
|
"createOnlyOverrideEditPrivacyPolicy",
|
|
98
104
|
"editPrivacyPolicy",
|
|
99
105
|
]);
|
|
100
106
|
}
|
|
101
|
-
exports.getFieldsForCreateAction = getFieldsForCreateAction;
|
|
102
107
|
function getFieldsWithPrivacyImpl(value, fieldInfoMap, keys) {
|
|
103
108
|
const schema = getSchema(value);
|
|
104
109
|
function addFields(fields) {
|
|
@@ -149,7 +154,6 @@ function getTransformedReadClause(value) {
|
|
|
149
154
|
}
|
|
150
155
|
return;
|
|
151
156
|
}
|
|
152
|
-
exports.getTransformedReadClause = getTransformedReadClause;
|
|
153
157
|
// would like to avoid calling this so that itwe don't run into circular dependencies
|
|
154
158
|
// but the fact that it returns a clause makes it hard since we don't control the patterns...
|
|
155
159
|
// we can make each clause return a format that can be extrapolated and used in codegen...
|
|
@@ -159,7 +163,6 @@ function getObjectLoaderProperties(value, tableName) {
|
|
|
159
163
|
instanceKey: `${tableName}:transformedReadClause`,
|
|
160
164
|
};
|
|
161
165
|
}
|
|
162
|
-
exports.getObjectLoaderProperties = getObjectLoaderProperties;
|
|
163
166
|
function getTransformedUpdateOp(value, stmt) {
|
|
164
167
|
const schema = getSchema(value);
|
|
165
168
|
if (!schema.patterns) {
|
|
@@ -172,7 +175,6 @@ function getTransformedUpdateOp(value, stmt) {
|
|
|
172
175
|
}
|
|
173
176
|
return null;
|
|
174
177
|
}
|
|
175
|
-
exports.getTransformedUpdateOp = getTransformedUpdateOp;
|
|
176
178
|
// this maps to ActionOperation in ent/action.go
|
|
177
179
|
var ActionOperation;
|
|
178
180
|
(function (ActionOperation) {
|
|
@@ -207,11 +209,9 @@ exports.NoFields = "__NO_FIELDS__";
|
|
|
207
209
|
function requiredField(field) {
|
|
208
210
|
return `__required__.${field}.__required__`;
|
|
209
211
|
}
|
|
210
|
-
exports.requiredField = requiredField;
|
|
211
212
|
function optionalField(field) {
|
|
212
213
|
return `__optional__.${field}.__optional__`;
|
|
213
214
|
}
|
|
214
|
-
exports.optionalField = optionalField;
|
|
215
215
|
var ConstraintType;
|
|
216
216
|
(function (ConstraintType) {
|
|
217
217
|
ConstraintType["PrimaryKey"] = "primary";
|
package/schema/struct_field.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.StructField = void 0;
|
|
4
|
+
exports.StructType = StructType;
|
|
5
|
+
exports.StructListType = StructListType;
|
|
6
|
+
exports.StructTypeAsList = StructTypeAsList;
|
|
4
7
|
const field_1 = require("./field");
|
|
5
8
|
const schema_1 = require("./schema");
|
|
6
9
|
const global_schema_1 = require("../core/global_schema");
|
|
@@ -249,16 +252,13 @@ function StructType(options) {
|
|
|
249
252
|
let result = new StructField(options);
|
|
250
253
|
return Object.assign(result, options);
|
|
251
254
|
}
|
|
252
|
-
exports.StructType = StructType;
|
|
253
255
|
/**
|
|
254
256
|
* @deprecated use StructTypeAsList
|
|
255
257
|
*/
|
|
256
258
|
function StructListType(options) {
|
|
257
259
|
return new field_1.ListField(StructType(options), options);
|
|
258
260
|
}
|
|
259
|
-
exports.StructListType = StructListType;
|
|
260
261
|
function StructTypeAsList(options) {
|
|
261
262
|
let result = new StructField(options, true);
|
|
262
263
|
return Object.assign(result, options);
|
|
263
264
|
}
|
|
264
|
-
exports.StructTypeAsList = StructTypeAsList;
|
package/schema/union_field.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.UnionField = void 0;
|
|
4
|
+
exports.UnionType = UnionType;
|
|
5
|
+
exports.UnionListType = UnionListType;
|
|
4
6
|
const schema_1 = require("./schema");
|
|
5
7
|
const field_1 = require("./field");
|
|
6
8
|
// used to know which key in the union is valid.
|
|
@@ -72,8 +74,6 @@ function UnionType(options) {
|
|
|
72
74
|
let result = new UnionField(options);
|
|
73
75
|
return Object.assign(result, options);
|
|
74
76
|
}
|
|
75
|
-
exports.UnionType = UnionType;
|
|
76
77
|
function UnionListType(options) {
|
|
77
78
|
return new field_1.ListField(UnionType(options), options);
|
|
78
79
|
}
|
|
79
|
-
exports.UnionListType = UnionListType;
|
|
@@ -23,7 +23,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getTables = exports.GroupMemberOfSchema = exports.GroupMemberOf = exports.
|
|
26
|
+
exports.getTables = exports.GroupMemberOfSchema = exports.GroupMemberOf = exports.EditGroupAction = exports.GroupMembershipTrigger = exports.UserAction = exports.MessageAction = exports.MessageSchema = exports.ChangelogSchema = exports.Changelog = exports.GroupMembershipSchema = exports.GroupMembership = exports.GroupSchema = exports.ContactSchema = exports.AccountSchema = exports.Account = exports.UserBalanceWithCheckSchema = exports.UserWithBalanceWithCheck = exports.UserBalanceSchema = exports.UserWithBalance = exports.UserSchema = void 0;
|
|
27
|
+
exports.setupTest = setupTest;
|
|
28
|
+
exports.getML = getML;
|
|
29
|
+
exports.getOperations = getOperations;
|
|
30
|
+
exports.executeAction = executeAction;
|
|
31
|
+
exports.createGroup = createGroup;
|
|
32
|
+
exports.createUser = createUser;
|
|
33
|
+
exports.verifyGroupMembers = verifyGroupMembers;
|
|
34
|
+
exports.loadMemberships = loadMemberships;
|
|
35
|
+
exports.loadChangelogs = loadChangelogs;
|
|
36
|
+
exports.verifyChangelogFromMeberships = verifyChangelogFromMeberships;
|
|
27
37
|
const ent_1 = require("../../core/ent");
|
|
28
38
|
const object_loader_1 = require("../../core/loaders/object_loader");
|
|
29
39
|
const action_1 = require("../../action/action");
|
|
@@ -88,15 +98,12 @@ function setupTest() {
|
|
|
88
98
|
operations = [];
|
|
89
99
|
});
|
|
90
100
|
}
|
|
91
|
-
exports.setupTest = setupTest;
|
|
92
101
|
function getML() {
|
|
93
102
|
return ml;
|
|
94
103
|
}
|
|
95
|
-
exports.getML = getML;
|
|
96
104
|
function getOperations() {
|
|
97
105
|
return operations;
|
|
98
106
|
}
|
|
99
|
-
exports.getOperations = getOperations;
|
|
100
107
|
exports.UserSchema = (0, builder_1.getBuilderSchemaFromFields)({
|
|
101
108
|
FirstName: (0, field_1.StringType)(),
|
|
102
109
|
LastName: (0, field_1.StringType)(),
|
|
@@ -200,7 +207,6 @@ async function executeAction(action, name) {
|
|
|
200
207
|
operations = await (0, executor_1.executeOperations)(exec, action.builder.viewer.context, true);
|
|
201
208
|
return exec;
|
|
202
209
|
}
|
|
203
|
-
exports.executeAction = executeAction;
|
|
204
210
|
async function executor(builder) {
|
|
205
211
|
const changeset = await builder.build();
|
|
206
212
|
return changeset.executor();
|
|
@@ -220,12 +226,10 @@ async function createGroup() {
|
|
|
220
226
|
});
|
|
221
227
|
return new builder_1.Group(new viewer_1.LoggedOutViewer(), groupFields);
|
|
222
228
|
}
|
|
223
|
-
exports.createGroup = createGroup;
|
|
224
229
|
async function createUser() {
|
|
225
230
|
const id = (0, uuid_1.v4)();
|
|
226
231
|
return new builder_1.User(new viewer_1.IDViewer(id), { id });
|
|
227
232
|
}
|
|
228
|
-
exports.createUser = createUser;
|
|
229
233
|
class MessageAction extends builder_1.SimpleAction {
|
|
230
234
|
constructor(viewer, fields, operation, existingEnt) {
|
|
231
235
|
super(viewer, exports.MessageSchema, fields, operation, existingEnt);
|
|
@@ -322,7 +326,6 @@ async function verifyGroupMembers(group, members) {
|
|
|
322
326
|
.filter((str) => str !== null && str !== undefined);
|
|
323
327
|
return membershipids;
|
|
324
328
|
}
|
|
325
|
-
exports.verifyGroupMembers = verifyGroupMembers;
|
|
326
329
|
async function loadMemberships(viewer, membershipids) {
|
|
327
330
|
const tableName = (0, builder_1.getTableName)(exports.GroupMembershipSchema);
|
|
328
331
|
const ents = await (0, ent_1.loadEnts)(viewer, {
|
|
@@ -337,7 +340,6 @@ async function loadMemberships(viewer, membershipids) {
|
|
|
337
340
|
}, ...membershipids);
|
|
338
341
|
return Array.from(ents.values());
|
|
339
342
|
}
|
|
340
|
-
exports.loadMemberships = loadMemberships;
|
|
341
343
|
async function loadChangelogs(viewer, clids) {
|
|
342
344
|
const ents = await (0, ent_1.loadEnts)(viewer, {
|
|
343
345
|
tableName: "changelogs",
|
|
@@ -351,7 +353,6 @@ async function loadChangelogs(viewer, clids) {
|
|
|
351
353
|
}, ...clids);
|
|
352
354
|
return Array.from(ents.values());
|
|
353
355
|
}
|
|
354
|
-
exports.loadChangelogs = loadChangelogs;
|
|
355
356
|
async function verifyChangelogFromMeberships(user, memberships) {
|
|
356
357
|
await Promise.all(memberships.map(async (membership) => {
|
|
357
358
|
const edges = await (0, ent_1.loadEdges)({
|
|
@@ -371,7 +372,6 @@ async function verifyChangelogFromMeberships(user, memberships) {
|
|
|
371
372
|
});
|
|
372
373
|
}));
|
|
373
374
|
}
|
|
374
|
-
exports.verifyChangelogFromMeberships = verifyChangelogFromMeberships;
|
|
375
375
|
class GroupMemberOf extends builder_1.BaseEnt {
|
|
376
376
|
constructor() {
|
|
377
377
|
super(...arguments);
|
package/testutils/builder.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ export declare class SimpleBuilder<T extends Ent, TExistingEnt extends TMaybleNu
|
|
|
83
83
|
fields: Map<string, any>;
|
|
84
84
|
nodeType: string;
|
|
85
85
|
m: Map<string, any>;
|
|
86
|
-
constructor(viewer: Viewer, schema: BuilderSchema<T>, fields: Map<string, any>, operation: WriteOperation, existingEnt: TExistingEnt, action?: Action<T, SimpleBuilder<T, TExistingEnt>, Viewer, Data, TExistingEnt> | undefined, expressions?: Map<string, Clause>);
|
|
86
|
+
constructor(viewer: Viewer, schema: BuilderSchema<T>, fields: Map<string, any>, operation: WriteOperation | undefined, existingEnt: TExistingEnt, action?: Action<T, SimpleBuilder<T, TExistingEnt>, Viewer, Data, TExistingEnt> | undefined, expressions?: Map<string, Clause>);
|
|
87
87
|
getInput(): Data;
|
|
88
88
|
updateInput(input: Data): void;
|
|
89
89
|
storeData(k: string, v: any): void;
|
package/testutils/builder.js
CHANGED
|
@@ -3,7 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SimpleAction = exports.SimpleBuilder = exports.
|
|
6
|
+
exports.SimpleAction = exports.SimpleBuilder = exports.getDbFields = exports.EntBuilderSchema = exports.Address = exports.Message = exports.Group = exports.Contact = exports.Event = exports.User = exports.AnyEnt = exports.BaseEnt = void 0;
|
|
7
|
+
exports.getBuilderSchema = getBuilderSchema;
|
|
8
|
+
exports.getBuilderSchemaFromFields = getBuilderSchemaFromFields;
|
|
9
|
+
exports.getBuilderSchemaTZFromFields = getBuilderSchemaTZFromFields;
|
|
10
|
+
exports.getSchemaName = getSchemaName;
|
|
11
|
+
exports.getTableName = getTableName;
|
|
12
|
+
exports.getFieldInfo = getFieldInfo;
|
|
7
13
|
const privacy_1 = require("../core/privacy");
|
|
8
14
|
const orchestrator_1 = require("../action/orchestrator");
|
|
9
15
|
const action_1 = require("../action");
|
|
@@ -136,29 +142,24 @@ function getBuilderSchema(cfg, ent) {
|
|
|
136
142
|
ent,
|
|
137
143
|
};
|
|
138
144
|
}
|
|
139
|
-
exports.getBuilderSchema = getBuilderSchema;
|
|
140
145
|
function getBuilderSchemaFromFields(fields, ent, opts) {
|
|
141
146
|
return {
|
|
142
147
|
...new base_schema_1.EntSchema({ ...opts, fields }),
|
|
143
148
|
ent,
|
|
144
149
|
};
|
|
145
150
|
}
|
|
146
|
-
exports.getBuilderSchemaFromFields = getBuilderSchemaFromFields;
|
|
147
151
|
function getBuilderSchemaTZFromFields(fields, ent) {
|
|
148
152
|
return {
|
|
149
153
|
...new base_schema_1.EntSchemaWithTZ({ fields }),
|
|
150
154
|
ent,
|
|
151
155
|
};
|
|
152
156
|
}
|
|
153
|
-
exports.getBuilderSchemaTZFromFields = getBuilderSchemaTZFromFields;
|
|
154
157
|
function getSchemaName(value) {
|
|
155
158
|
return value.ent.name;
|
|
156
159
|
}
|
|
157
|
-
exports.getSchemaName = getSchemaName;
|
|
158
160
|
function getTableName(value) {
|
|
159
161
|
return (0, pluralize_1.default)((0, names_1.toDBColumnOrTable)(value.ent.name)).toLowerCase();
|
|
160
162
|
}
|
|
161
|
-
exports.getTableName = getTableName;
|
|
162
163
|
const getDbFields = (schema) => {
|
|
163
164
|
const fields = (0, schema_1.getFields)(schema);
|
|
164
165
|
const dbFields = [];
|
|
@@ -183,7 +184,6 @@ function getFieldInfo(value) {
|
|
|
183
184
|
}
|
|
184
185
|
return ret;
|
|
185
186
|
}
|
|
186
|
-
exports.getFieldInfo = getFieldInfo;
|
|
187
187
|
// reuses orchestrator and standard things
|
|
188
188
|
class SimpleBuilder {
|
|
189
189
|
constructor(viewer, schema, fields, operation = action_1.WriteOperation.Insert, existingEnt, action, expressions) {
|
package/testutils/db/fixture.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.writeFixture =
|
|
3
|
+
exports.writeFixture = writeFixture;
|
|
4
4
|
const schema_1 = require("../../schema");
|
|
5
5
|
const value_1 = require("./value");
|
|
6
6
|
const ent_1 = require("../../core/ent");
|
|
@@ -23,4 +23,3 @@ async function writeFixture(schema, opts) {
|
|
|
23
23
|
});
|
|
24
24
|
await opts.client.query(q[0], q[1]);
|
|
25
25
|
}
|
|
26
|
-
exports.writeFixture = writeFixture;
|