@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
@@ -0,0 +1,8 @@
1
+ export interface OrderByOption {
2
+ column: string;
3
+ direction: "ASC" | "DESC";
4
+ nullsPlacement?: "first" | "last";
5
+ }
6
+ export type OrderBy = OrderByOption[];
7
+ export declare function getOrderByPhrase(orderby: OrderBy): string;
8
+ export declare function reverseOrderBy(orderby: OrderBy): OrderBy;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reverseOrderBy = exports.getOrderByPhrase = void 0;
4
+ function getOrderByPhrase(orderby) {
5
+ return orderby
6
+ .map((v) => {
7
+ let nullsPlacement = "";
8
+ switch (v.nullsPlacement) {
9
+ case "first":
10
+ nullsPlacement = " NULLS FIRST";
11
+ break;
12
+ case "last":
13
+ nullsPlacement = " NULLS LAST";
14
+ break;
15
+ }
16
+ return `${v.column} ${v.direction}${nullsPlacement}`;
17
+ })
18
+ .join(", ");
19
+ }
20
+ exports.getOrderByPhrase = getOrderByPhrase;
21
+ function reverseOrderBy(orderby) {
22
+ return orderby.map((o) => {
23
+ const o2 = { ...o };
24
+ o2.direction = o.direction === "ASC" ? "DESC" : "ASC";
25
+ return o2;
26
+ });
27
+ }
28
+ exports.reverseOrderBy = reverseOrderBy;
package/core/viewer.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ID, Ent, Viewer, Context } from "./base";
2
2
  export declare class LoggedOutViewer implements Viewer {
3
3
  context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined;
4
+ marker: string;
4
5
  constructor(context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined);
5
6
  viewerID: null;
6
7
  viewer(): Promise<null>;
@@ -12,6 +13,7 @@ export interface IDViewerOptions {
12
13
  ent?: Ent | null;
13
14
  }
14
15
  export declare class IDViewer implements Viewer {
16
+ marker: string;
15
17
  viewerID: ID;
16
18
  private ent;
17
19
  context?: Context;
package/core/viewer.js CHANGED
@@ -4,6 +4,7 @@ exports.IDViewer = exports.LoggedOutViewer = void 0;
4
4
  class LoggedOutViewer {
5
5
  constructor(context) {
6
6
  this.context = context;
7
+ this.marker = "loggedout";
7
8
  this.viewerID = null;
8
9
  }
9
10
  async viewer() {
@@ -16,6 +17,7 @@ class LoggedOutViewer {
16
17
  exports.LoggedOutViewer = LoggedOutViewer;
17
18
  class IDViewer {
18
19
  constructor(args, opts) {
20
+ this.marker = "idviewer";
19
21
  this.ent = null;
20
22
  if (typeof args === "object") {
21
23
  this.viewerID = args.viewerID;
@@ -35,7 +37,7 @@ class IDViewer {
35
37
  return this.ent;
36
38
  }
37
39
  instanceKey() {
38
- return `idViewer: ${this.viewerID}`;
40
+ return `idViewer:${this.viewerID}`;
39
41
  }
40
42
  }
41
43
  exports.IDViewer = IDViewer;
@@ -1,36 +1,112 @@
1
- import "reflect-metadata";
2
1
  import { GraphQLScalarType } from "graphql";
2
+ import type { FieldMap } from "../schema";
3
+ import { ProcessedField as ParsedProcessedField } from "../parse_schema/parse";
4
+ import { ImportPath } from "../schema/schema";
3
5
  interface ClassType<T = any> {
4
6
  new (...args: any[]): T;
5
7
  }
6
- export interface CustomType {
8
+ declare type StringToStringMap = {
9
+ [key: string]: string;
10
+ };
11
+ interface CustomFieldInput {
12
+ graphQLName?: string;
13
+ name?: string;
14
+ functionName?: string;
15
+ args?: Field[];
16
+ results?: Field[];
17
+ fieldType: CustomFieldTypeInput;
18
+ description?: string;
19
+ }
20
+ interface CustomTopLevelInput {
21
+ class?: string;
22
+ graphQLName?: string;
23
+ name?: string;
24
+ functionName?: string;
25
+ edgeName?: string;
26
+ args?: Field[];
27
+ results?: Field[];
28
+ extraImports?: ImportPath[];
29
+ functionContents?: string;
30
+ fieldType: CustomFieldTypeInput;
31
+ description?: string;
32
+ list?: boolean;
33
+ connection?: boolean;
34
+ resultType?: string;
35
+ }
36
+ type CustomFieldInputMap = {
37
+ [key: string]: CustomFieldInput[];
38
+ };
39
+ type CustomTypeInputMap = {
40
+ [key: string]: CustomTypeInput;
41
+ };
42
+ interface CustomObjectInput {
43
+ name: string;
44
+ graphQLName?: string;
45
+ fields?: CustomFieldInput[];
46
+ }
47
+ export interface CustomGraphQLInput {
48
+ fields?: CustomFieldInputMap;
49
+ inputs?: CustomObjectInput[];
50
+ objects?: CustomObjectInput[];
51
+ args?: CustomObjectInput[];
52
+ queries?: CustomTopLevelInput[];
53
+ mutations?: CustomTopLevelInput[];
54
+ customTypes?: CustomTypeInputMap;
55
+ }
56
+ export interface CustomTypeInput {
7
57
  type: string;
8
58
  importPath: string;
9
59
  tsType?: string;
10
60
  tsImportPath?: string;
61
+ enumMap?: StringToStringMap;
62
+ structFields?: FieldMap;
63
+ inputType?: boolean;
11
64
  [x: string]: any;
12
65
  }
13
- declare type Type = GraphQLScalarType | ClassType | string | CustomType;
14
- export declare type GraphQLConnection<T> = {
66
+ export type CustomType = Omit<CustomTypeInput, "structFields"> & {
67
+ structFields?: ParsedProcessedField[];
68
+ };
69
+ type Type = GraphQLScalarType | ClassType | string | CustomTypeInput;
70
+ export type GraphQLConnection<T> = {
15
71
  node: T;
16
72
  };
17
- export interface gqlFieldOptions {
73
+ interface gqlFieldOptionsBase {
18
74
  name?: string;
19
75
  nullable?: boolean | NullableListOptions;
20
76
  description?: string;
21
77
  type?: Type | Array<Type> | GraphQLConnection<Type>;
22
78
  }
79
+ interface gqlFieldArg extends Omit<gqlFieldOptionsBase, "name"> {
80
+ isContextArg?: boolean;
81
+ name: string;
82
+ }
83
+ export interface gqlFieldOptions extends gqlFieldOptionsBase {
84
+ class: string;
85
+ args?: gqlFieldArg[];
86
+ async?: boolean;
87
+ type: NonNullable<gqlFieldOptionsBase["type"]>;
88
+ }
23
89
  export interface gqlObjectOptions {
24
90
  name?: string;
25
91
  description?: string;
26
92
  }
27
- declare type gqlTopLevelOptions = Exclude<gqlFieldOptions, "nullable">;
93
+ export interface gqlObjectWithInterfaceOptions extends gqlObjectOptions {
94
+ interfaces?: string[];
95
+ }
96
+ export interface gqlObjectWithUnionOptions extends gqlObjectOptions {
97
+ unionTypes: string[];
98
+ }
99
+ type gqlMutationOptions = Omit<gqlFieldOptions, "nullable" | "type"> & {
100
+ type?: gqlFieldOptionsBase["type"];
101
+ };
102
+ type gqlQueryOptions = gqlFieldOptions;
28
103
  export declare enum CustomFieldType {
29
104
  Accessor = "ACCESSOR",
30
105
  Field = "FIELD",
31
106
  Function = "FUNCTION",
32
107
  AsyncFunction = "ASYNC_FUNCTION"
33
108
  }
109
+ export type CustomFieldTypeInput = "ACCESSOR" | "FIELD" | "FUNCTION" | "ASYNC_FUNCTION";
34
110
  interface CustomFieldImpl {
35
111
  nodeName: string;
36
112
  gqlName: string;
@@ -42,6 +118,9 @@ interface CustomFieldImpl {
42
118
  export interface CustomField extends CustomFieldImpl {
43
119
  args: Field[];
44
120
  results: Field[];
121
+ extraImports?: ImportPath[];
122
+ functionContents?: string;
123
+ edgeName?: string;
45
124
  }
46
125
  export interface CustomMutation extends CustomField {
47
126
  }
@@ -51,15 +130,17 @@ export interface ProcessedCustomField extends CustomFieldImpl {
51
130
  args: ProcessedField[];
52
131
  results: ProcessedField[];
53
132
  }
54
- export declare type ProcessCustomFieldMap = {
55
- [key: string]: ProcessedCustomField;
133
+ export type ProcessCustomFieldMap = {
134
+ [key: string]: ProcessedCustomField[];
56
135
  };
57
136
  export interface CustomObject {
58
137
  nodeName: string;
59
138
  className: string;
60
139
  description?: string;
140
+ interfaces?: string[];
141
+ unionTypes?: string[];
61
142
  }
62
- declare type NullableListOptions = "contents" | "contentsAndList";
143
+ type NullableListOptions = "contents" | "contentsAndList";
63
144
  interface FieldImpl {
64
145
  type: string;
65
146
  tsType?: string;
@@ -84,8 +165,9 @@ declare enum NullableResult {
84
165
  }
85
166
  export declare const knownAllowedNames: Map<string, string>;
86
167
  export declare const knownDisAllowedNames: Map<string, boolean>;
87
- export declare const isCustomType: (type: Type) => type is CustomType;
88
- export declare const addCustomType: (type: CustomType) => void;
168
+ export declare const knownInterfaces: Map<string, boolean>;
169
+ export declare const isCustomType: (type: Type) => type is CustomTypeInput;
170
+ export declare const addCustomType: (type: CustomTypeInput, gqlCapture: typeof GQLCapture) => Promise<void>;
89
171
  export declare class GQLCapture {
90
172
  private static enabled;
91
173
  static enable(enabled: boolean): void;
@@ -96,6 +178,8 @@ export declare class GQLCapture {
96
178
  private static customArgs;
97
179
  private static customInputObjects;
98
180
  private static customObjects;
181
+ private static customInterfaces;
182
+ private static customUnions;
99
183
  private static customTypes;
100
184
  static clear(): void;
101
185
  static getCustomFields(): Map<string, CustomField[]>;
@@ -104,36 +188,38 @@ export declare class GQLCapture {
104
188
  static getCustomArgs(): Map<string, CustomObject>;
105
189
  static getCustomInputObjects(): Map<string, CustomObject>;
106
190
  static getCustomObjects(): Map<string, CustomObject>;
191
+ static getCustomInterfaces(): Map<string, CustomObject>;
192
+ static getCustomUnions(): Map<string, CustomObject>;
107
193
  static getCustomTypes(): Map<string, CustomType>;
108
194
  private static getNullableArg;
109
195
  static getProcessedCustomFields(): ProcessCustomFieldMap;
110
196
  static getProcessedCustomMutations(): ProcessedCustomField[];
111
197
  static getProcessedCustomQueries(): ProcessedCustomField[];
112
198
  private static getProcessedCustomFieldsImpl;
113
- private static getResultFromMetadata;
114
- static gqlField(options?: gqlFieldOptions): any;
199
+ private static getField;
200
+ static gqlField(options: gqlFieldOptions): any;
115
201
  private static getCustomField;
116
- private static argMap;
117
- private static argImpl;
118
- static gqlArg(name: string, options?: gqlFieldOptions): any;
119
- static gqlContextType(): any;
202
+ static gqlContextType(): gqlFieldArg;
120
203
  static gqlArgType(options?: gqlObjectOptions): any;
121
204
  static gqlInputObjectType(options?: gqlObjectOptions): any;
122
- static gqlObjectType(options?: gqlObjectOptions): any;
205
+ static gqlObjectType(options?: gqlObjectWithInterfaceOptions): any;
206
+ static gqlUnionType(options: gqlObjectWithUnionOptions): any;
207
+ static gqlInterfaceType(options?: gqlObjectOptions): any;
123
208
  private static customGQLObject;
124
- static gqlQuery(options?: gqlTopLevelOptions): any;
125
- static gqlMutation(options?: gqlTopLevelOptions): any;
209
+ static gqlQuery(options: gqlQueryOptions): any;
210
+ static gqlMutation(options: gqlMutationOptions): any;
126
211
  static gqlConnection(type: Type): any;
127
212
  static resolve(objects: string[]): void;
128
213
  }
129
214
  export declare const gqlField: typeof GQLCapture.gqlField;
130
- export declare const gqlArg: typeof GQLCapture.gqlArg;
131
215
  export declare const gqlArgType: typeof GQLCapture.gqlArgType;
132
216
  export declare const gqlInputObjectType: typeof GQLCapture.gqlInputObjectType;
133
217
  export declare const gqlObjectType: typeof GQLCapture.gqlObjectType;
218
+ export declare const gqlInterfaceType: typeof GQLCapture.gqlInterfaceType;
219
+ export declare const gqlUnionType: typeof GQLCapture.gqlUnionType;
134
220
  export declare const gqlQuery: typeof GQLCapture.gqlQuery;
135
221
  export declare const gqlMutation: typeof GQLCapture.gqlMutation;
136
222
  export declare const gqlContextType: typeof GQLCapture.gqlContextType;
137
223
  export declare const gqlConnection: typeof GQLCapture.gqlConnection;
138
- declare const gqlFileUpload: CustomType;
224
+ declare const gqlFileUpload: CustomTypeInput;
139
225
  export { gqlFileUpload };