@snowtop/ent 0.1.0-alpha99 → 0.1.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.
Files changed (115) hide show
  1. package/action/action.d.ts +8 -1
  2. package/action/executor.d.ts +16 -3
  3. package/action/executor.js +83 -27
  4. package/action/index.d.ts +2 -1
  5. package/action/operations.d.ts +126 -0
  6. package/action/operations.js +686 -0
  7. package/action/orchestrator.d.ts +22 -8
  8. package/action/orchestrator.js +278 -67
  9. package/core/base.d.ts +34 -24
  10. package/core/clause.d.ts +62 -79
  11. package/core/clause.js +77 -5
  12. package/core/config.d.ts +5 -1
  13. package/core/config.js +3 -0
  14. package/core/const.d.ts +3 -0
  15. package/core/const.js +6 -0
  16. package/core/context.d.ts +4 -3
  17. package/core/context.js +2 -1
  18. package/core/db.d.ts +1 -0
  19. package/core/db.js +7 -7
  20. package/core/ent.d.ts +53 -105
  21. package/core/ent.js +104 -599
  22. package/core/global_schema.d.ts +7 -0
  23. package/core/global_schema.js +51 -0
  24. package/core/loaders/assoc_count_loader.d.ts +4 -2
  25. package/core/loaders/assoc_count_loader.js +10 -2
  26. package/core/loaders/assoc_edge_loader.d.ts +2 -3
  27. package/core/loaders/assoc_edge_loader.js +16 -7
  28. package/core/loaders/index.d.ts +0 -1
  29. package/core/loaders/index.js +1 -3
  30. package/core/loaders/loader.d.ts +3 -3
  31. package/core/loaders/loader.js +3 -20
  32. package/core/loaders/object_loader.d.ts +30 -10
  33. package/core/loaders/object_loader.js +179 -40
  34. package/core/loaders/query_loader.d.ts +4 -4
  35. package/core/loaders/query_loader.js +14 -19
  36. package/core/loaders/raw_count_loader.d.ts +1 -0
  37. package/core/loaders/raw_count_loader.js +3 -2
  38. package/core/privacy.d.ts +19 -10
  39. package/core/privacy.js +47 -26
  40. package/core/query/assoc_query.js +1 -1
  41. package/core/query/custom_clause_query.d.ts +6 -3
  42. package/core/query/custom_clause_query.js +36 -9
  43. package/core/query/custom_query.d.ts +3 -1
  44. package/core/query/custom_query.js +29 -6
  45. package/core/query/query.d.ts +12 -2
  46. package/core/query/query.js +67 -38
  47. package/core/query/shared_assoc_test.js +151 -10
  48. package/core/query/shared_test.d.ts +2 -2
  49. package/core/query/shared_test.js +90 -30
  50. package/core/query_impl.d.ts +8 -0
  51. package/core/query_impl.js +28 -0
  52. package/core/viewer.d.ts +2 -0
  53. package/core/viewer.js +2 -0
  54. package/graphql/graphql.d.ts +103 -19
  55. package/graphql/graphql.js +169 -134
  56. package/graphql/graphql_field_helpers.d.ts +9 -3
  57. package/graphql/graphql_field_helpers.js +22 -2
  58. package/graphql/index.d.ts +2 -1
  59. package/graphql/index.js +5 -2
  60. package/graphql/scalars/orderby_direction.d.ts +2 -0
  61. package/graphql/scalars/orderby_direction.js +15 -0
  62. package/imports/dataz/example1/_auth.js +128 -47
  63. package/imports/dataz/example1/_viewer.js +87 -39
  64. package/imports/index.d.ts +1 -1
  65. package/imports/index.js +2 -2
  66. package/index.d.ts +12 -1
  67. package/index.js +18 -6
  68. package/package.json +20 -17
  69. package/parse_schema/parse.d.ts +10 -4
  70. package/parse_schema/parse.js +70 -24
  71. package/schema/base_schema.d.ts +8 -0
  72. package/schema/base_schema.js +11 -0
  73. package/schema/field.d.ts +6 -3
  74. package/schema/field.js +72 -17
  75. package/schema/index.d.ts +1 -1
  76. package/schema/index.js +2 -1
  77. package/schema/json_field.d.ts +3 -3
  78. package/schema/json_field.js +4 -1
  79. package/schema/schema.d.ts +42 -5
  80. package/schema/schema.js +35 -41
  81. package/schema/struct_field.d.ts +8 -6
  82. package/schema/struct_field.js +67 -8
  83. package/schema/union_field.d.ts +1 -1
  84. package/scripts/custom_compiler.js +4 -4
  85. package/scripts/custom_graphql.js +105 -75
  86. package/scripts/move_types.js +4 -1
  87. package/scripts/read_schema.js +2 -2
  88. package/testutils/action/complex_schemas.d.ts +1 -1
  89. package/testutils/action/complex_schemas.js +10 -3
  90. package/testutils/builder.d.ts +3 -0
  91. package/testutils/builder.js +6 -0
  92. package/testutils/db/temp_db.d.ts +9 -1
  93. package/testutils/db/temp_db.js +82 -14
  94. package/testutils/db_mock.js +1 -3
  95. package/testutils/ent-graphql-tests/index.d.ts +1 -1
  96. package/testutils/ent-graphql-tests/index.js +30 -19
  97. package/testutils/fake_comms.js +1 -1
  98. package/testutils/fake_data/fake_contact.d.ts +1 -1
  99. package/testutils/fake_data/fake_tag.d.ts +1 -1
  100. package/testutils/fake_data/fake_user.d.ts +3 -3
  101. package/testutils/fake_data/fake_user.js +15 -4
  102. package/testutils/fake_data/tag_query.js +8 -3
  103. package/testutils/fake_data/test_helpers.d.ts +3 -2
  104. package/testutils/fake_data/test_helpers.js +4 -4
  105. package/testutils/fake_data/user_query.d.ts +5 -2
  106. package/testutils/fake_data/user_query.js +19 -2
  107. package/testutils/fake_log.js +1 -1
  108. package/tsc/ast.js +2 -1
  109. package/tsc/move_generated.js +2 -2
  110. package/tsc/transform.d.ts +2 -2
  111. package/tsc/transform.js +4 -3
  112. package/tsc/transform_ent.js +2 -1
  113. package/tsc/transform_schema.js +4 -3
  114. package/core/loaders/index_loader.d.ts +0 -14
  115. package/core/loaders/index_loader.js +0 -27
@@ -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
- type Type = GraphQLScalarType | ClassType | string | CustomType;
66
+ export type CustomType = Omit<CustomTypeInput, "structFields"> & {
67
+ structFields?: ParsedProcessedField[];
68
+ };
69
+ type Type = GraphQLScalarType | ClassType | string | CustomTypeInput;
14
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
- 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,8 +118,9 @@ interface CustomFieldImpl {
42
118
  export interface CustomField extends CustomFieldImpl {
43
119
  args: Field[];
44
120
  results: Field[];
45
- extraImports?: any[];
121
+ extraImports?: ImportPath[];
46
122
  functionContents?: string;
123
+ edgeName?: string;
47
124
  }
48
125
  export interface CustomMutation extends CustomField {
49
126
  }
@@ -60,6 +137,8 @@ export interface CustomObject {
60
137
  nodeName: string;
61
138
  className: string;
62
139
  description?: string;
140
+ interfaces?: string[];
141
+ unionTypes?: string[];
63
142
  }
64
143
  type NullableListOptions = "contents" | "contentsAndList";
65
144
  interface FieldImpl {
@@ -86,8 +165,9 @@ declare enum NullableResult {
86
165
  }
87
166
  export declare const knownAllowedNames: Map<string, string>;
88
167
  export declare const knownDisAllowedNames: Map<string, boolean>;
89
- export declare const isCustomType: (type: Type) => type is CustomType;
90
- 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>;
91
171
  export declare class GQLCapture {
92
172
  private static enabled;
93
173
  static enable(enabled: boolean): void;
@@ -98,6 +178,8 @@ export declare class GQLCapture {
98
178
  private static customArgs;
99
179
  private static customInputObjects;
100
180
  private static customObjects;
181
+ private static customInterfaces;
182
+ private static customUnions;
101
183
  private static customTypes;
102
184
  static clear(): void;
103
185
  static getCustomFields(): Map<string, CustomField[]>;
@@ -106,36 +188,38 @@ export declare class GQLCapture {
106
188
  static getCustomArgs(): Map<string, CustomObject>;
107
189
  static getCustomInputObjects(): Map<string, CustomObject>;
108
190
  static getCustomObjects(): Map<string, CustomObject>;
191
+ static getCustomInterfaces(): Map<string, CustomObject>;
192
+ static getCustomUnions(): Map<string, CustomObject>;
109
193
  static getCustomTypes(): Map<string, CustomType>;
110
194
  private static getNullableArg;
111
195
  static getProcessedCustomFields(): ProcessCustomFieldMap;
112
196
  static getProcessedCustomMutations(): ProcessedCustomField[];
113
197
  static getProcessedCustomQueries(): ProcessedCustomField[];
114
198
  private static getProcessedCustomFieldsImpl;
115
- private static getResultFromMetadata;
116
- static gqlField(options?: gqlFieldOptions): any;
199
+ private static getField;
200
+ static gqlField(options: gqlFieldOptions): any;
117
201
  private static getCustomField;
118
- private static argMap;
119
- private static argImpl;
120
- static gqlArg(name: string, options?: gqlFieldOptions): any;
121
- static gqlContextType(): any;
202
+ static gqlContextType(): gqlFieldArg;
122
203
  static gqlArgType(options?: gqlObjectOptions): any;
123
204
  static gqlInputObjectType(options?: gqlObjectOptions): any;
124
- static gqlObjectType(options?: gqlObjectOptions): any;
205
+ static gqlObjectType(options?: gqlObjectWithInterfaceOptions): any;
206
+ static gqlUnionType(options: gqlObjectWithUnionOptions): any;
207
+ static gqlInterfaceType(options?: gqlObjectOptions): any;
125
208
  private static customGQLObject;
126
- static gqlQuery(options?: gqlTopLevelOptions): any;
127
- static gqlMutation(options?: gqlTopLevelOptions): any;
209
+ static gqlQuery(options: gqlQueryOptions): any;
210
+ static gqlMutation(options: gqlMutationOptions): any;
128
211
  static gqlConnection(type: Type): any;
129
212
  static resolve(objects: string[]): void;
130
213
  }
131
214
  export declare const gqlField: typeof GQLCapture.gqlField;
132
- export declare const gqlArg: typeof GQLCapture.gqlArg;
133
215
  export declare const gqlArgType: typeof GQLCapture.gqlArgType;
134
216
  export declare const gqlInputObjectType: typeof GQLCapture.gqlInputObjectType;
135
217
  export declare const gqlObjectType: typeof GQLCapture.gqlObjectType;
218
+ export declare const gqlInterfaceType: typeof GQLCapture.gqlInterfaceType;
219
+ export declare const gqlUnionType: typeof GQLCapture.gqlUnionType;
136
220
  export declare const gqlQuery: typeof GQLCapture.gqlQuery;
137
221
  export declare const gqlMutation: typeof GQLCapture.gqlMutation;
138
222
  export declare const gqlContextType: typeof GQLCapture.gqlContextType;
139
223
  export declare const gqlConnection: typeof GQLCapture.gqlConnection;
140
- declare const gqlFileUpload: CustomType;
224
+ declare const gqlFileUpload: CustomTypeInput;
141
225
  export { gqlFileUpload };