@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.
Files changed (176) hide show
  1. package/action/action.d.ts +25 -14
  2. package/action/action.js +22 -7
  3. package/action/executor.d.ts +16 -3
  4. package/action/executor.js +89 -28
  5. package/action/experimental_action.d.ts +25 -16
  6. package/action/experimental_action.js +34 -14
  7. package/action/index.d.ts +4 -1
  8. package/action/index.js +7 -1
  9. package/action/operations.d.ts +126 -0
  10. package/action/operations.js +686 -0
  11. package/action/orchestrator.d.ts +43 -12
  12. package/action/orchestrator.js +461 -101
  13. package/action/relative_value.d.ts +47 -0
  14. package/action/relative_value.js +125 -0
  15. package/action/transaction.d.ts +10 -0
  16. package/action/transaction.js +23 -0
  17. package/auth/auth.d.ts +1 -1
  18. package/core/base.d.ts +56 -23
  19. package/core/base.js +7 -1
  20. package/core/clause.d.ts +103 -39
  21. package/core/clause.js +430 -66
  22. package/core/config.d.ts +13 -3
  23. package/core/config.js +10 -1
  24. package/core/const.d.ts +3 -0
  25. package/core/const.js +6 -0
  26. package/core/context.d.ts +6 -3
  27. package/core/context.js +22 -3
  28. package/core/convert.d.ts +1 -1
  29. package/core/date.js +1 -5
  30. package/core/db.d.ts +12 -8
  31. package/core/db.js +21 -9
  32. package/core/ent.d.ts +99 -95
  33. package/core/ent.js +550 -602
  34. package/core/global_schema.d.ts +7 -0
  35. package/core/global_schema.js +51 -0
  36. package/core/loaders/assoc_count_loader.d.ts +5 -2
  37. package/core/loaders/assoc_count_loader.js +19 -3
  38. package/core/loaders/assoc_edge_loader.d.ts +2 -3
  39. package/core/loaders/assoc_edge_loader.js +23 -17
  40. package/core/loaders/index.d.ts +1 -2
  41. package/core/loaders/index.js +1 -5
  42. package/core/loaders/loader.d.ts +3 -3
  43. package/core/loaders/loader.js +4 -21
  44. package/core/loaders/object_loader.d.ts +30 -9
  45. package/core/loaders/object_loader.js +226 -79
  46. package/core/loaders/query_loader.d.ts +7 -13
  47. package/core/loaders/query_loader.js +60 -24
  48. package/core/loaders/raw_count_loader.d.ts +1 -0
  49. package/core/loaders/raw_count_loader.js +8 -3
  50. package/core/logger.d.ts +1 -1
  51. package/core/logger.js +1 -0
  52. package/core/privacy.d.ts +26 -16
  53. package/core/privacy.js +68 -51
  54. package/core/query/assoc_query.d.ts +3 -2
  55. package/core/query/assoc_query.js +10 -2
  56. package/core/query/custom_clause_query.d.ts +29 -0
  57. package/core/query/custom_clause_query.js +105 -0
  58. package/core/query/custom_query.d.ts +19 -2
  59. package/core/query/custom_query.js +111 -13
  60. package/core/query/index.d.ts +1 -0
  61. package/core/query/index.js +3 -1
  62. package/core/query/query.d.ts +18 -4
  63. package/core/query/query.js +135 -58
  64. package/core/query/shared_assoc_test.d.ts +2 -1
  65. package/core/query/shared_assoc_test.js +186 -55
  66. package/core/query/shared_test.d.ts +9 -2
  67. package/core/query/shared_test.js +529 -236
  68. package/core/query_impl.d.ts +8 -0
  69. package/core/query_impl.js +28 -0
  70. package/core/viewer.d.ts +2 -0
  71. package/core/viewer.js +3 -1
  72. package/graphql/graphql.d.ts +108 -22
  73. package/graphql/graphql.js +183 -137
  74. package/graphql/graphql_field_helpers.d.ts +9 -3
  75. package/graphql/graphql_field_helpers.js +22 -2
  76. package/graphql/index.d.ts +2 -2
  77. package/graphql/index.js +5 -5
  78. package/graphql/query/connection_type.d.ts +9 -9
  79. package/graphql/query/shared_assoc_test.js +1 -1
  80. package/graphql/query/shared_edge_connection.js +1 -19
  81. package/graphql/scalars/orderby_direction.d.ts +2 -0
  82. package/graphql/scalars/orderby_direction.js +15 -0
  83. package/imports/dataz/example1/_auth.js +128 -47
  84. package/imports/dataz/example1/_viewer.js +87 -39
  85. package/imports/index.d.ts +7 -2
  86. package/imports/index.js +20 -5
  87. package/index.d.ts +23 -5
  88. package/index.js +35 -10
  89. package/package.json +20 -19
  90. package/parse_schema/parse.d.ts +33 -9
  91. package/parse_schema/parse.js +182 -33
  92. package/schema/base_schema.d.ts +13 -3
  93. package/schema/base_schema.js +13 -0
  94. package/schema/field.d.ts +78 -21
  95. package/schema/field.js +232 -72
  96. package/schema/index.d.ts +2 -2
  97. package/schema/index.js +7 -2
  98. package/schema/json_field.d.ts +16 -4
  99. package/schema/json_field.js +32 -2
  100. package/schema/schema.d.ts +109 -20
  101. package/schema/schema.js +42 -53
  102. package/schema/struct_field.d.ts +15 -3
  103. package/schema/struct_field.js +117 -22
  104. package/schema/union_field.d.ts +1 -1
  105. package/scripts/custom_compiler.js +12 -8
  106. package/scripts/custom_graphql.js +167 -64
  107. package/scripts/migrate_v0.1.js +36 -0
  108. package/scripts/move_types.js +120 -0
  109. package/scripts/read_schema.js +22 -7
  110. package/testutils/action/complex_schemas.d.ts +69 -0
  111. package/testutils/action/complex_schemas.js +405 -0
  112. package/testutils/builder.d.ts +37 -41
  113. package/testutils/builder.js +66 -46
  114. package/testutils/db/fixture.d.ts +10 -0
  115. package/testutils/db/fixture.js +26 -0
  116. package/testutils/db/{test_db.d.ts → temp_db.d.ts} +32 -8
  117. package/testutils/db/{test_db.js → temp_db.js} +251 -48
  118. package/testutils/db/value.d.ts +7 -0
  119. package/testutils/db/value.js +251 -0
  120. package/testutils/db_mock.d.ts +16 -4
  121. package/testutils/db_mock.js +52 -9
  122. package/testutils/db_time_zone.d.ts +4 -0
  123. package/testutils/db_time_zone.js +41 -0
  124. package/testutils/ent-graphql-tests/index.d.ts +7 -1
  125. package/testutils/ent-graphql-tests/index.js +56 -26
  126. package/testutils/fake_comms.js +1 -1
  127. package/testutils/fake_data/const.d.ts +2 -1
  128. package/testutils/fake_data/const.js +3 -0
  129. package/testutils/fake_data/fake_contact.d.ts +7 -3
  130. package/testutils/fake_data/fake_contact.js +13 -7
  131. package/testutils/fake_data/fake_event.d.ts +4 -1
  132. package/testutils/fake_data/fake_event.js +7 -6
  133. package/testutils/fake_data/fake_tag.d.ts +36 -0
  134. package/testutils/fake_data/fake_tag.js +89 -0
  135. package/testutils/fake_data/fake_user.d.ts +8 -5
  136. package/testutils/fake_data/fake_user.js +31 -19
  137. package/testutils/fake_data/index.js +5 -1
  138. package/testutils/fake_data/internal.d.ts +2 -0
  139. package/testutils/fake_data/internal.js +7 -1
  140. package/testutils/fake_data/tag_query.d.ts +13 -0
  141. package/testutils/fake_data/tag_query.js +48 -0
  142. package/testutils/fake_data/test_helpers.d.ts +14 -6
  143. package/testutils/fake_data/test_helpers.js +31 -15
  144. package/testutils/fake_data/user_query.d.ts +16 -6
  145. package/testutils/fake_data/user_query.js +72 -23
  146. package/testutils/fake_log.js +1 -1
  147. package/testutils/parse_sql.d.ts +6 -0
  148. package/testutils/parse_sql.js +16 -2
  149. package/testutils/test_edge_global_schema.d.ts +15 -0
  150. package/testutils/test_edge_global_schema.js +62 -0
  151. package/testutils/write.d.ts +2 -2
  152. package/testutils/write.js +33 -7
  153. package/tsc/ast.d.ts +15 -3
  154. package/tsc/ast.js +114 -23
  155. package/tsc/compilerOptions.js +5 -1
  156. package/tsc/move_generated.d.ts +1 -0
  157. package/tsc/move_generated.js +164 -0
  158. package/tsc/transform.d.ts +22 -0
  159. package/tsc/transform.js +182 -0
  160. package/tsc/transform_action.d.ts +22 -0
  161. package/tsc/transform_action.js +183 -0
  162. package/tsc/transform_ent.d.ts +17 -0
  163. package/tsc/transform_ent.js +60 -0
  164. package/tsc/transform_schema.d.ts +27 -0
  165. package/{scripts → tsc}/transform_schema.js +146 -117
  166. package/core/loaders/index_loader.d.ts +0 -14
  167. package/core/loaders/index_loader.js +0 -27
  168. package/graphql/enums.d.ts +0 -3
  169. package/graphql/enums.js +0 -25
  170. package/scripts/move_generated.js +0 -141
  171. package/scripts/transform_actions.js +0 -266
  172. package/scripts/transform_code.d.ts +0 -1
  173. package/scripts/transform_code.js +0 -111
  174. package/scripts/transform_schema.d.ts +0 -1
  175. /package/scripts/{move_generated.d.ts → migrate_v0.1.d.ts} +0 -0
  176. /package/scripts/{transform_actions.d.ts → move_types.d.ts} +0 -0
@@ -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 FieldOptions {
28
- min?: number;
29
- max?: number;
28
+ export interface IntegerOptions extends NumberOptions<number> {
30
29
  }
31
- export declare class IntegerField extends BaseField implements Field {
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?: IntegerOptions);
36
- getOptions(): IntegerOptions;
38
+ constructor(options?: NumberOptions<T>);
39
+ getOptions(): NumberOptions<T>;
37
40
  private handleOptions;
38
- min(l: number): this;
39
- max(l: number): this;
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 BaseField implements Field {
50
+ export declare class BigIntegerField extends NumberField<BigInt> implements Field {
45
51
  type: Type;
46
52
  }
47
- export declare function BigIntegerType(options: FieldOptions): BigIntegerField;
48
- export declare class FloatField extends BaseField implements Field {
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?: FieldOptions): FloatField;
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 EnumMap = {
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?: EnumMap;
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: EnumOptions);
136
- convertForGQL(value: string): string;
137
- valid(val: any): boolean;
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 EnumType(options: EnumOptions): EnumField;
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?: FieldOptions);
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: FieldOptions): ListField;
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: EnumOptions): ListField;
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 {};