@snowtop/ent 0.1.0-alpha16 → 0.1.0-alpha160-test2
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.d.ts +25 -14
- package/action/action.js +22 -7
- package/action/executor.d.ts +16 -3
- package/action/executor.js +89 -28
- package/action/experimental_action.d.ts +25 -16
- package/action/experimental_action.js +34 -14
- package/action/index.d.ts +4 -1
- package/action/index.js +7 -1
- package/action/operations.d.ts +126 -0
- package/action/operations.js +686 -0
- package/action/orchestrator.d.ts +43 -12
- package/action/orchestrator.js +461 -101
- package/action/relative_value.d.ts +47 -0
- package/action/relative_value.js +125 -0
- package/action/transaction.d.ts +10 -0
- package/action/transaction.js +23 -0
- package/auth/auth.d.ts +1 -1
- package/core/base.d.ts +56 -23
- package/core/base.js +7 -1
- package/core/clause.d.ts +103 -39
- package/core/clause.js +430 -66
- package/core/config.d.ts +13 -3
- package/core/config.js +10 -1
- package/core/const.d.ts +3 -0
- package/core/const.js +6 -0
- package/core/context.d.ts +6 -3
- package/core/context.js +22 -3
- package/core/convert.d.ts +1 -1
- package/core/date.js +1 -5
- package/core/db.d.ts +12 -8
- package/core/db.js +21 -9
- package/core/ent.d.ts +99 -95
- package/core/ent.js +550 -602
- package/core/global_schema.d.ts +7 -0
- package/core/global_schema.js +51 -0
- package/core/loaders/assoc_count_loader.d.ts +5 -2
- package/core/loaders/assoc_count_loader.js +19 -3
- package/core/loaders/assoc_edge_loader.d.ts +2 -3
- package/core/loaders/assoc_edge_loader.js +23 -17
- package/core/loaders/index.d.ts +1 -2
- package/core/loaders/index.js +1 -5
- package/core/loaders/loader.d.ts +3 -3
- package/core/loaders/loader.js +4 -21
- package/core/loaders/object_loader.d.ts +30 -9
- package/core/loaders/object_loader.js +226 -79
- package/core/loaders/query_loader.d.ts +7 -13
- package/core/loaders/query_loader.js +60 -24
- package/core/loaders/raw_count_loader.d.ts +1 -0
- package/core/loaders/raw_count_loader.js +8 -3
- package/core/logger.d.ts +1 -1
- package/core/logger.js +1 -0
- package/core/privacy.d.ts +26 -16
- package/core/privacy.js +68 -51
- package/core/query/assoc_query.d.ts +3 -2
- package/core/query/assoc_query.js +10 -2
- package/core/query/custom_clause_query.d.ts +29 -0
- package/core/query/custom_clause_query.js +105 -0
- package/core/query/custom_query.d.ts +19 -2
- package/core/query/custom_query.js +111 -13
- package/core/query/index.d.ts +1 -0
- package/core/query/index.js +3 -1
- package/core/query/query.d.ts +18 -4
- package/core/query/query.js +135 -58
- package/core/query/shared_assoc_test.d.ts +2 -1
- package/core/query/shared_assoc_test.js +186 -55
- package/core/query/shared_test.d.ts +9 -2
- package/core/query/shared_test.js +529 -236
- package/core/query_impl.d.ts +8 -0
- package/core/query_impl.js +28 -0
- package/core/viewer.d.ts +2 -0
- package/core/viewer.js +3 -1
- package/graphql/graphql.d.ts +108 -22
- package/graphql/graphql.js +183 -137
- package/graphql/graphql_field_helpers.d.ts +9 -3
- package/graphql/graphql_field_helpers.js +22 -2
- package/graphql/index.d.ts +2 -2
- package/graphql/index.js +5 -5
- package/graphql/query/connection_type.d.ts +9 -9
- package/graphql/query/shared_assoc_test.js +1 -1
- package/graphql/query/shared_edge_connection.js +1 -19
- package/graphql/scalars/orderby_direction.d.ts +2 -0
- package/graphql/scalars/orderby_direction.js +15 -0
- package/imports/dataz/example1/_auth.js +128 -47
- package/imports/dataz/example1/_viewer.js +87 -39
- package/imports/index.d.ts +7 -2
- package/imports/index.js +20 -5
- package/index.d.ts +23 -5
- package/index.js +35 -10
- package/package.json +20 -19
- package/parse_schema/parse.d.ts +33 -9
- package/parse_schema/parse.js +182 -33
- package/schema/base_schema.d.ts +13 -3
- package/schema/base_schema.js +13 -0
- package/schema/field.d.ts +78 -21
- package/schema/field.js +232 -72
- package/schema/index.d.ts +2 -2
- package/schema/index.js +7 -2
- package/schema/json_field.d.ts +16 -4
- package/schema/json_field.js +32 -2
- package/schema/schema.d.ts +109 -20
- package/schema/schema.js +42 -53
- package/schema/struct_field.d.ts +15 -3
- package/schema/struct_field.js +117 -22
- package/schema/union_field.d.ts +1 -1
- package/scripts/custom_compiler.js +12 -8
- package/scripts/custom_graphql.js +167 -64
- package/scripts/migrate_v0.1.js +36 -0
- package/scripts/move_types.js +120 -0
- package/scripts/read_schema.js +22 -7
- package/testutils/action/complex_schemas.d.ts +69 -0
- package/testutils/action/complex_schemas.js +405 -0
- package/testutils/builder.d.ts +37 -41
- package/testutils/builder.js +66 -46
- package/testutils/db/fixture.d.ts +10 -0
- package/testutils/db/fixture.js +26 -0
- package/testutils/db/{test_db.d.ts → temp_db.d.ts} +32 -8
- package/testutils/db/{test_db.js → temp_db.js} +251 -48
- package/testutils/db/value.d.ts +7 -0
- package/testutils/db/value.js +251 -0
- package/testutils/db_mock.d.ts +16 -4
- package/testutils/db_mock.js +52 -9
- package/testutils/db_time_zone.d.ts +4 -0
- package/testutils/db_time_zone.js +41 -0
- package/testutils/ent-graphql-tests/index.d.ts +7 -1
- package/testutils/ent-graphql-tests/index.js +56 -26
- package/testutils/fake_comms.js +1 -1
- package/testutils/fake_data/const.d.ts +2 -1
- package/testutils/fake_data/const.js +3 -0
- package/testutils/fake_data/fake_contact.d.ts +7 -3
- package/testutils/fake_data/fake_contact.js +13 -7
- package/testutils/fake_data/fake_event.d.ts +4 -1
- package/testutils/fake_data/fake_event.js +7 -6
- package/testutils/fake_data/fake_tag.d.ts +36 -0
- package/testutils/fake_data/fake_tag.js +89 -0
- package/testutils/fake_data/fake_user.d.ts +8 -5
- package/testutils/fake_data/fake_user.js +31 -19
- package/testutils/fake_data/index.js +5 -1
- package/testutils/fake_data/internal.d.ts +2 -0
- package/testutils/fake_data/internal.js +7 -1
- package/testutils/fake_data/tag_query.d.ts +13 -0
- package/testutils/fake_data/tag_query.js +48 -0
- package/testutils/fake_data/test_helpers.d.ts +14 -6
- package/testutils/fake_data/test_helpers.js +31 -15
- package/testutils/fake_data/user_query.d.ts +16 -6
- package/testutils/fake_data/user_query.js +72 -23
- package/testutils/fake_log.js +1 -1
- package/testutils/parse_sql.d.ts +6 -0
- package/testutils/parse_sql.js +16 -2
- package/testutils/test_edge_global_schema.d.ts +15 -0
- package/testutils/test_edge_global_schema.js +62 -0
- package/testutils/write.d.ts +2 -2
- package/testutils/write.js +33 -7
- package/tsc/ast.d.ts +15 -3
- package/tsc/ast.js +114 -23
- package/tsc/compilerOptions.js +5 -1
- package/tsc/move_generated.d.ts +1 -0
- package/tsc/move_generated.js +164 -0
- package/tsc/transform.d.ts +22 -0
- package/tsc/transform.js +182 -0
- package/tsc/transform_action.d.ts +22 -0
- package/tsc/transform_action.js +183 -0
- package/tsc/transform_ent.d.ts +17 -0
- package/tsc/transform_ent.js +60 -0
- package/tsc/transform_schema.d.ts +27 -0
- package/{scripts → tsc}/transform_schema.js +146 -117
- package/core/loaders/index_loader.d.ts +0 -14
- package/core/loaders/index_loader.js +0 -27
- package/graphql/enums.d.ts +0 -3
- package/graphql/enums.js +0 -25
- package/scripts/move_generated.js +0 -141
- package/scripts/transform_actions.js +0 -266
- package/scripts/transform_code.d.ts +0 -1
- package/scripts/transform_code.js +0 -111
- package/scripts/transform_schema.d.ts +0 -1
- /package/scripts/{move_generated.d.ts → migrate_v0.1.d.ts} +0 -0
- /package/scripts/{transform_actions.d.ts → move_types.d.ts} +0 -0
package/schema/base_schema.js
CHANGED
|
@@ -17,6 +17,7 @@ let tsFields = {
|
|
|
17
17
|
defaultValueOnCreate: () => {
|
|
18
18
|
return new Date();
|
|
19
19
|
},
|
|
20
|
+
onlyUpdateIfOtherFieldsBeingSet_BETA: true,
|
|
20
21
|
defaultValueOnEdit: () => {
|
|
21
22
|
return new Date();
|
|
22
23
|
},
|
|
@@ -74,6 +75,7 @@ class EntSchema {
|
|
|
74
75
|
constructor(cfg) {
|
|
75
76
|
this.patterns = [exports.Node];
|
|
76
77
|
this.fields = cfg.fields;
|
|
78
|
+
this.fieldOverrides = cfg.fieldOverrides;
|
|
77
79
|
this.tableName = cfg.tableName;
|
|
78
80
|
if (cfg.patterns) {
|
|
79
81
|
this.patterns.push(...cfg.patterns);
|
|
@@ -86,6 +88,11 @@ class EntSchema {
|
|
|
86
88
|
this.constraints = cfg.constraints;
|
|
87
89
|
this.indices = cfg.indices;
|
|
88
90
|
this.hideFromGraphQL = cfg.hideFromGraphQL;
|
|
91
|
+
// TODO annoying that have to list these...
|
|
92
|
+
this.customGraphQLInterfaces = cfg.customGraphQLInterfaces;
|
|
93
|
+
this.supportUpsert = cfg.supportUpsert;
|
|
94
|
+
this.showCanViewerSee = cfg.showCanViewerSee;
|
|
95
|
+
this.showCanViewerEdit = cfg.showCanViewerEdit;
|
|
89
96
|
}
|
|
90
97
|
}
|
|
91
98
|
exports.EntSchema = EntSchema;
|
|
@@ -100,6 +107,7 @@ class EntSchemaWithTZ {
|
|
|
100
107
|
},
|
|
101
108
|
];
|
|
102
109
|
this.fields = cfg.fields;
|
|
110
|
+
this.fieldOverrides = cfg.fieldOverrides;
|
|
103
111
|
this.tableName = cfg.tableName;
|
|
104
112
|
if (cfg.patterns) {
|
|
105
113
|
this.patterns.push(...cfg.patterns);
|
|
@@ -112,6 +120,11 @@ class EntSchemaWithTZ {
|
|
|
112
120
|
this.constraints = cfg.constraints;
|
|
113
121
|
this.indices = cfg.indices;
|
|
114
122
|
this.hideFromGraphQL = cfg.hideFromGraphQL;
|
|
123
|
+
// TODO annoying that have to list these...
|
|
124
|
+
this.customGraphQLInterfaces = cfg.customGraphQLInterfaces;
|
|
125
|
+
this.supportUpsert = cfg.supportUpsert;
|
|
126
|
+
this.showCanViewerSee = cfg.showCanViewerSee;
|
|
127
|
+
this.showCanViewerEdit = cfg.showCanViewerEdit;
|
|
115
128
|
}
|
|
116
129
|
}
|
|
117
130
|
exports.EntSchemaWithTZ = EntSchemaWithTZ;
|
package/schema/field.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Builder } from "../action/action";
|
|
1
2
|
import { Field, FieldMap, FieldOptions, ForeignKey, PolymorphicOptions, Type } from "./schema";
|
|
2
3
|
export declare abstract class BaseField {
|
|
3
4
|
name: string;
|
|
@@ -24,31 +25,36 @@ export declare class UUIDField extends BaseField implements Field {
|
|
|
24
25
|
valid(val: any): Promise<boolean>;
|
|
25
26
|
}
|
|
26
27
|
export declare function UUIDType(options?: FieldOptions): UUIDField;
|
|
27
|
-
export interface IntegerOptions extends
|
|
28
|
-
min?: number;
|
|
29
|
-
max?: number;
|
|
28
|
+
export interface IntegerOptions extends NumberOptions<number> {
|
|
30
29
|
}
|
|
31
|
-
export
|
|
30
|
+
export interface NumberOptions<T> extends FieldOptions {
|
|
31
|
+
min?: T;
|
|
32
|
+
max?: T;
|
|
33
|
+
}
|
|
34
|
+
export declare class NumberField<T> extends BaseField {
|
|
32
35
|
type: Type;
|
|
33
36
|
private validators;
|
|
34
37
|
private options;
|
|
35
|
-
constructor(options?:
|
|
36
|
-
getOptions():
|
|
38
|
+
constructor(options?: NumberOptions<T>);
|
|
39
|
+
getOptions(): NumberOptions<T>;
|
|
37
40
|
private handleOptions;
|
|
38
|
-
min(l:
|
|
39
|
-
max(l:
|
|
41
|
+
min(l: T): this;
|
|
42
|
+
max(l: T): this;
|
|
40
43
|
valid(val: any): boolean;
|
|
41
44
|
validate(validator: (str: number) => boolean): this;
|
|
42
45
|
}
|
|
46
|
+
export declare class IntegerField extends NumberField<number> implements Field {
|
|
47
|
+
type: Type;
|
|
48
|
+
}
|
|
43
49
|
export declare function IntegerType(options?: IntegerOptions): IntegerField;
|
|
44
|
-
export declare class BigIntegerField extends
|
|
50
|
+
export declare class BigIntegerField extends NumberField<BigInt> implements Field {
|
|
45
51
|
type: Type;
|
|
46
52
|
}
|
|
47
|
-
export declare function BigIntegerType(options
|
|
48
|
-
export declare class FloatField extends
|
|
53
|
+
export declare function BigIntegerType(options?: NumberOptions<BigInt>): BigIntegerField;
|
|
54
|
+
export declare class FloatField extends NumberField<number> implements Field {
|
|
49
55
|
type: Type;
|
|
50
56
|
}
|
|
51
|
-
export declare function FloatType(options?:
|
|
57
|
+
export declare function FloatType(options?: NumberOptions<number>): FloatField;
|
|
52
58
|
export declare class BooleanField extends BaseField implements Field {
|
|
53
59
|
type: Type;
|
|
54
60
|
}
|
|
@@ -88,6 +94,18 @@ export declare class StringField extends BaseField implements Field {
|
|
|
88
94
|
trimLeft(): this;
|
|
89
95
|
trimRight(): this;
|
|
90
96
|
}
|
|
97
|
+
interface PolymorphicStringOptions extends StringOptions {
|
|
98
|
+
parentFieldToValidate: string;
|
|
99
|
+
types?: string[];
|
|
100
|
+
}
|
|
101
|
+
export declare class PolymorphicStringField extends StringField {
|
|
102
|
+
private opts;
|
|
103
|
+
private camelCaseVals;
|
|
104
|
+
constructor(opts: PolymorphicStringOptions);
|
|
105
|
+
validateWithFullData(val: any, b: Builder<any>): boolean;
|
|
106
|
+
valid(val: any): boolean;
|
|
107
|
+
format(val: any): any;
|
|
108
|
+
}
|
|
91
109
|
export declare function StringType(options?: StringOptions): StringField;
|
|
92
110
|
export interface TimestampOptions extends FieldOptions {
|
|
93
111
|
withTimezone?: boolean;
|
|
@@ -118,31 +136,69 @@ export declare class DateField extends BaseField implements Field {
|
|
|
118
136
|
format(val: any): any;
|
|
119
137
|
}
|
|
120
138
|
export declare function DateType(options?: FieldOptions): DateField;
|
|
121
|
-
declare type
|
|
139
|
+
declare type StringEnumMap = {
|
|
122
140
|
[key: string]: string;
|
|
123
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* @deprecated use StringEnumOptions
|
|
144
|
+
*/
|
|
124
145
|
export interface EnumOptions extends FieldOptions {
|
|
125
146
|
values?: string[];
|
|
126
|
-
map?:
|
|
147
|
+
map?: StringEnumMap;
|
|
127
148
|
tsType?: string;
|
|
128
149
|
graphQLType?: string;
|
|
129
150
|
createEnumType?: boolean;
|
|
151
|
+
disableUnknownType?: boolean;
|
|
152
|
+
globalType?: string;
|
|
130
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated Use StringEnumField
|
|
156
|
+
*/
|
|
131
157
|
export declare class EnumField extends BaseField implements Field {
|
|
132
158
|
type: Type;
|
|
133
159
|
private values?;
|
|
134
160
|
private map?;
|
|
135
|
-
constructor(options:
|
|
136
|
-
|
|
137
|
-
|
|
161
|
+
constructor(options: StringEnumOptions);
|
|
162
|
+
valid(val: any): Promise<boolean>;
|
|
163
|
+
format(val: any): any;
|
|
164
|
+
}
|
|
165
|
+
export declare class StringEnumField extends EnumField {
|
|
166
|
+
}
|
|
167
|
+
export interface PolymorphicStringEnumOptions extends EnumOptions {
|
|
168
|
+
parentFieldToValidate: string;
|
|
169
|
+
}
|
|
170
|
+
export interface StringEnumOptions extends EnumOptions {
|
|
171
|
+
}
|
|
172
|
+
export declare function EnumType(options: StringEnumOptions): EnumField;
|
|
173
|
+
declare type IntEnumMap = {
|
|
174
|
+
[key: string]: number;
|
|
175
|
+
};
|
|
176
|
+
export interface IntegerEnumOptions extends FieldOptions {
|
|
177
|
+
map?: IntEnumMap;
|
|
178
|
+
deprecated?: IntEnumMap;
|
|
179
|
+
tsType?: string;
|
|
180
|
+
graphQLType?: string;
|
|
181
|
+
disableUnknownType?: boolean;
|
|
182
|
+
globalType?: string;
|
|
183
|
+
}
|
|
184
|
+
export declare class IntegerEnumField extends BaseField implements Field {
|
|
185
|
+
type: Type;
|
|
186
|
+
private map;
|
|
187
|
+
constructor(options: IntegerEnumOptions);
|
|
188
|
+
valid(val: any): Promise<boolean>;
|
|
138
189
|
format(val: any): any;
|
|
139
190
|
}
|
|
140
|
-
export declare function
|
|
191
|
+
export declare function IntegerEnumType(options: IntegerEnumOptions): IntegerEnumField;
|
|
192
|
+
interface ListOptions extends FieldOptions {
|
|
193
|
+
disableJSONStringify?: boolean;
|
|
194
|
+
}
|
|
141
195
|
export declare class ListField extends BaseField {
|
|
142
196
|
private field;
|
|
197
|
+
private options?;
|
|
143
198
|
type: Type;
|
|
144
199
|
private validators;
|
|
145
|
-
constructor(field: Field, options?:
|
|
200
|
+
constructor(field: Field, options?: ListOptions | undefined);
|
|
201
|
+
__getElemField(): Field;
|
|
146
202
|
validate(validator: (val: any[]) => boolean): this;
|
|
147
203
|
valid(val: any): Promise<boolean>;
|
|
148
204
|
private postgresVal;
|
|
@@ -153,7 +209,7 @@ export declare class ListField extends BaseField {
|
|
|
153
209
|
range(start: any, stop: any): this;
|
|
154
210
|
}
|
|
155
211
|
export declare function StringListType(options?: StringOptions): ListField;
|
|
156
|
-
export declare function IntListType(options
|
|
212
|
+
export declare function IntListType(options?: FieldOptions): ListField;
|
|
157
213
|
export declare function IntegerListType(options?: FieldOptions): ListField;
|
|
158
214
|
export declare function FloatListType(options?: FieldOptions): ListField;
|
|
159
215
|
export declare function BigIntegerListType(options: FieldOptions): ListField;
|
|
@@ -163,6 +219,7 @@ export declare function TimestamptzListType(options?: TimestampOptions): ListFie
|
|
|
163
219
|
export declare function TimeListType(options?: TimeOptions): ListField;
|
|
164
220
|
export declare function TimetzListType(options: TimeOptions): ListField;
|
|
165
221
|
export declare function DateListType(options?: FieldOptions): ListField;
|
|
166
|
-
export declare function EnumListType(options:
|
|
222
|
+
export declare function EnumListType(options: StringEnumOptions): ListField;
|
|
223
|
+
export declare function IntegerEnumListType(options: IntegerEnumOptions): ListField;
|
|
167
224
|
export declare function UUIDListType(options?: FieldOptions): ListField;
|
|
168
225
|
export {};
|