@snowtop/ent 0.1.0-alpha14 → 0.1.0-alpha140

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 (169) hide show
  1. package/action/action.d.ts +27 -16
  2. package/action/action.js +22 -7
  3. package/action/executor.d.ts +16 -3
  4. package/action/executor.js +88 -21
  5. package/action/experimental_action.d.ts +25 -16
  6. package/action/experimental_action.js +35 -9
  7. package/action/index.d.ts +3 -1
  8. package/action/index.js +7 -1
  9. package/action/operations.d.ts +125 -0
  10. package/action/operations.js +684 -0
  11. package/action/orchestrator.d.ts +34 -11
  12. package/action/orchestrator.js +355 -92
  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 +51 -21
  19. package/core/base.js +7 -1
  20. package/core/clause.d.ts +85 -40
  21. package/core/clause.js +375 -64
  22. package/core/config.d.ts +12 -1
  23. package/core/config.js +7 -1
  24. package/core/const.d.ts +3 -0
  25. package/core/const.js +6 -0
  26. package/core/context.d.ts +4 -2
  27. package/core/context.js +20 -2
  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 +18 -8
  32. package/core/ent.d.ts +66 -93
  33. package/core/ent.js +517 -577
  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 +1 -0
  37. package/core/loaders/assoc_count_loader.js +10 -2
  38. package/core/loaders/assoc_edge_loader.d.ts +1 -1
  39. package/core/loaders/assoc_edge_loader.js +8 -11
  40. package/core/loaders/index.d.ts +1 -1
  41. package/core/loaders/index.js +1 -3
  42. package/core/loaders/index_loader.d.ts +3 -3
  43. package/core/loaders/loader.d.ts +2 -2
  44. package/core/loaders/loader.js +5 -5
  45. package/core/loaders/object_loader.d.ts +30 -9
  46. package/core/loaders/object_loader.js +225 -78
  47. package/core/loaders/query_loader.d.ts +6 -12
  48. package/core/loaders/query_loader.js +52 -11
  49. package/core/loaders/raw_count_loader.js +5 -1
  50. package/core/logger.d.ts +1 -1
  51. package/core/logger.js +1 -0
  52. package/core/privacy.d.ts +7 -6
  53. package/core/privacy.js +21 -25
  54. package/core/query/assoc_query.d.ts +3 -2
  55. package/core/query/assoc_query.js +9 -1
  56. package/core/query/custom_clause_query.d.ts +27 -0
  57. package/core/query/custom_clause_query.js +84 -0
  58. package/core/query/custom_query.d.ts +17 -2
  59. package/core/query/custom_query.js +87 -12
  60. package/core/query/index.d.ts +1 -0
  61. package/core/query/index.js +3 -1
  62. package/core/query/query.d.ts +7 -3
  63. package/core/query/query.js +101 -53
  64. package/core/query/shared_assoc_test.d.ts +2 -1
  65. package/core/query/shared_assoc_test.js +35 -45
  66. package/core/query/shared_test.d.ts +8 -1
  67. package/core/query/shared_test.js +470 -236
  68. package/core/viewer.js +1 -1
  69. package/graphql/graphql.d.ts +52 -19
  70. package/graphql/graphql.js +174 -136
  71. package/graphql/graphql_field_helpers.d.ts +7 -1
  72. package/graphql/graphql_field_helpers.js +21 -1
  73. package/graphql/index.d.ts +2 -2
  74. package/graphql/index.js +3 -5
  75. package/graphql/query/connection_type.d.ts +9 -9
  76. package/graphql/query/shared_assoc_test.js +1 -1
  77. package/graphql/query/shared_edge_connection.js +1 -19
  78. package/graphql/scalars/orderby_direction.d.ts +2 -0
  79. package/graphql/scalars/orderby_direction.js +15 -0
  80. package/imports/dataz/example1/_auth.js +128 -47
  81. package/imports/dataz/example1/_viewer.js +87 -39
  82. package/imports/index.d.ts +6 -1
  83. package/imports/index.js +19 -4
  84. package/index.d.ts +14 -5
  85. package/index.js +26 -10
  86. package/package.json +18 -17
  87. package/parse_schema/parse.d.ts +31 -9
  88. package/parse_schema/parse.js +156 -13
  89. package/schema/base_schema.d.ts +9 -3
  90. package/schema/base_schema.js +12 -0
  91. package/schema/field.d.ts +78 -21
  92. package/schema/field.js +231 -71
  93. package/schema/index.d.ts +2 -2
  94. package/schema/index.js +5 -1
  95. package/schema/json_field.d.ts +16 -4
  96. package/schema/json_field.js +32 -2
  97. package/schema/schema.d.ts +94 -19
  98. package/schema/schema.js +11 -13
  99. package/schema/struct_field.d.ts +15 -3
  100. package/schema/struct_field.js +117 -22
  101. package/schema/union_field.d.ts +1 -1
  102. package/scripts/custom_compiler.js +10 -6
  103. package/scripts/custom_graphql.js +142 -31
  104. package/scripts/migrate_v0.1.js +36 -0
  105. package/scripts/move_types.js +120 -0
  106. package/scripts/read_schema.js +20 -5
  107. package/testutils/action/complex_schemas.d.ts +69 -0
  108. package/testutils/action/complex_schemas.js +405 -0
  109. package/testutils/builder.d.ts +39 -43
  110. package/testutils/builder.js +75 -49
  111. package/testutils/db/fixture.d.ts +10 -0
  112. package/testutils/db/fixture.js +26 -0
  113. package/testutils/db/{test_db.d.ts → temp_db.d.ts} +25 -8
  114. package/testutils/db/{test_db.js → temp_db.js} +224 -47
  115. package/testutils/db/value.d.ts +7 -0
  116. package/testutils/db/value.js +251 -0
  117. package/testutils/db_mock.d.ts +16 -4
  118. package/testutils/db_mock.js +52 -7
  119. package/testutils/db_time_zone.d.ts +4 -0
  120. package/testutils/db_time_zone.js +41 -0
  121. package/testutils/ent-graphql-tests/index.d.ts +7 -1
  122. package/testutils/ent-graphql-tests/index.js +52 -23
  123. package/testutils/fake_comms.js +1 -1
  124. package/testutils/fake_data/const.d.ts +2 -1
  125. package/testutils/fake_data/const.js +3 -0
  126. package/testutils/fake_data/fake_contact.d.ts +7 -3
  127. package/testutils/fake_data/fake_contact.js +13 -7
  128. package/testutils/fake_data/fake_event.d.ts +4 -1
  129. package/testutils/fake_data/fake_event.js +7 -6
  130. package/testutils/fake_data/fake_tag.d.ts +36 -0
  131. package/testutils/fake_data/fake_tag.js +89 -0
  132. package/testutils/fake_data/fake_user.d.ts +8 -5
  133. package/testutils/fake_data/fake_user.js +16 -15
  134. package/testutils/fake_data/index.js +5 -1
  135. package/testutils/fake_data/internal.d.ts +2 -0
  136. package/testutils/fake_data/internal.js +7 -1
  137. package/testutils/fake_data/tag_query.d.ts +13 -0
  138. package/testutils/fake_data/tag_query.js +43 -0
  139. package/testutils/fake_data/test_helpers.d.ts +11 -4
  140. package/testutils/fake_data/test_helpers.js +28 -12
  141. package/testutils/fake_data/user_query.d.ts +11 -4
  142. package/testutils/fake_data/user_query.js +54 -22
  143. package/testutils/fake_log.js +1 -1
  144. package/testutils/parse_sql.d.ts +6 -0
  145. package/testutils/parse_sql.js +16 -2
  146. package/testutils/test_edge_global_schema.d.ts +15 -0
  147. package/testutils/test_edge_global_schema.js +62 -0
  148. package/testutils/write.d.ts +2 -2
  149. package/testutils/write.js +33 -7
  150. package/tsc/ast.d.ts +25 -2
  151. package/tsc/ast.js +141 -17
  152. package/tsc/compilerOptions.js +5 -1
  153. package/tsc/move_generated.d.ts +1 -0
  154. package/tsc/move_generated.js +164 -0
  155. package/tsc/transform.d.ts +22 -0
  156. package/tsc/transform.js +181 -0
  157. package/tsc/transform_action.d.ts +22 -0
  158. package/tsc/transform_action.js +183 -0
  159. package/tsc/transform_ent.d.ts +17 -0
  160. package/tsc/transform_ent.js +60 -0
  161. package/tsc/transform_schema.d.ts +27 -0
  162. package/{scripts → tsc}/transform_schema.js +146 -117
  163. package/graphql/enums.d.ts +0 -3
  164. package/graphql/enums.js +0 -25
  165. package/scripts/move_generated.js +0 -142
  166. package/scripts/transform_code.js +0 -113
  167. package/scripts/transform_schema.d.ts +0 -1
  168. /package/scripts/{move_generated.d.ts → migrate_v0.1.d.ts} +0 -0
  169. /package/scripts/{transform_code.d.ts → move_types.d.ts} +0 -0
@@ -1,11 +1,12 @@
1
- import { ID, Data, Ent, Viewer, EntConstructor, LoadEntOptions } from "../core/base";
2
- import { AssocEdgeInputOptions, DataOperation } from "../core/ent";
1
+ import { ID, Data, Ent, Viewer, LoadEntOptions, CreateRowOptions } from "../core/base";
3
2
  import { SchemaInputType, FieldInfoMap } from "../schema/schema";
4
- import { Changeset, Executor } from "../action/action";
3
+ import { Changeset, ChangesetOptions, Executor } from "../action/action";
4
+ import { AssocEdgeInputOptions, DataOperation, AssocEdgeOptions } from "./operations";
5
5
  import { WriteOperation, Builder, Action } from "../action";
6
- declare type MaybeNull<T extends Ent> = T | null;
7
- declare type TMaybleNullableEnt<T extends Ent> = T | MaybeNull<T>;
8
- export interface OrchestratorOptions<TEnt extends Ent<TViewer>, TViewer extends Viewer, TInput extends Data, TExistingEnt extends TMaybleNullableEnt<TEnt> = MaybeNull<TEnt>> {
6
+ import * as clause from "../core/clause";
7
+ type MaybeNull<T extends Ent> = T | null;
8
+ type TMaybleNullableEnt<T extends Ent> = T | MaybeNull<T>;
9
+ export interface OrchestratorOptions<TEnt extends Ent<TViewer>, TInput extends Data, TViewer extends Viewer, TExistingEnt extends TMaybleNullableEnt<TEnt> = MaybeNull<TEnt>> {
9
10
  viewer: Viewer;
10
11
  operation: WriteOperation;
11
12
  tableName: string;
@@ -16,6 +17,7 @@ export interface OrchestratorOptions<TEnt extends Ent<TViewer>, TViewer extends
16
17
  schema: SchemaInputType;
17
18
  editedFields(): Map<string, any> | Promise<Map<string, any>>;
18
19
  updateInput?: (data: TInput) => void;
20
+ expressions?: Map<string, clause.Clause>;
19
21
  fieldInfo: FieldInfoMap;
20
22
  }
21
23
  interface edgeInputDataOpts {
@@ -35,6 +37,7 @@ export declare class Orchestrator<TEnt extends Ent<TViewer>, TInput extends Data
35
37
  private options;
36
38
  private edgeSet;
37
39
  private edges;
40
+ private conditionalEdges;
38
41
  private validatedFields;
39
42
  private logValues;
40
43
  private changesets;
@@ -47,14 +50,17 @@ export declare class Orchestrator<TEnt extends Ent<TViewer>, TInput extends Data
47
50
  private actualOperation;
48
51
  private existingEnt;
49
52
  private disableTransformations;
53
+ private onConflict;
50
54
  private memoizedGetFields;
51
- constructor(options: OrchestratorOptions<TEnt, TViewer, TInput, TExistingEnt>);
55
+ constructor(options: OrchestratorOptions<TEnt, TInput, TViewer, TExistingEnt>);
56
+ __getOptions(): OrchestratorOptions<any, any, any, any>;
52
57
  private addEdge;
53
58
  setDisableTransformations(val: boolean): void;
59
+ setOnConflictOptions(onConflict: CreateRowOptions["onConflict"]): void;
54
60
  addInboundEdge<T2 extends Ent>(id1: ID | Builder<T2, any>, edgeType: string, nodeType: string, options?: AssocEdgeInputOptions): void;
55
61
  addOutboundEdge<T2 extends Ent>(id2: ID | Builder<T2, any>, edgeType: string, nodeType: string, options?: AssocEdgeInputOptions): void;
56
- removeInboundEdge(id1: ID, edgeType: string): void;
57
- removeOutboundEdge(id2: ID, edgeType: string): void;
62
+ removeInboundEdge(id1: ID, edgeType: string, options?: AssocEdgeOptions): void;
63
+ removeOutboundEdge(id2: ID, edgeType: string, options?: AssocEdgeOptions): void;
58
64
  getInputEdges(edgeType: string, op: WriteOperation): EdgeInputData[];
59
65
  clearInputEdges(edgeType: string, op: WriteOperation, id?: ID): void;
60
66
  private buildMainOp;
@@ -66,6 +72,11 @@ export declare class Orchestrator<TEnt extends Ent<TViewer>, TInput extends Data
66
72
  private getWriteOpForSQLStamentOp;
67
73
  getPossibleUnsafeEntForPrivacy(): Promise<TEnt>;
68
74
  getEditedData(): Promise<Data>;
75
+ /**
76
+ * @returns validated and formatted fields that would be written to the db
77
+ * throws an error if called before valid() or validX() has been called
78
+ */
79
+ getValidatedFields(): Data;
69
80
  private getFieldsInfo;
70
81
  private validate;
71
82
  private triggers;
@@ -79,7 +90,17 @@ export declare class Orchestrator<TEnt extends Ent<TViewer>, TInput extends Data
79
90
  private formatAndValidateFields;
80
91
  valid(): Promise<boolean>;
81
92
  validX(): Promise<void>;
93
+ /**
94
+ * @experimental API that's not guaranteed to remain in the future which returns
95
+ * a list of errors encountered
96
+ * 0 errors indicates valid
97
+ * NOTE that this currently doesn't catch errors returned by validators().
98
+ * If those throws, this still throws and doesn't return them
99
+ */
100
+ validWithErrors(): Promise<Error[]>;
101
+ private buildPlusChangeset;
82
102
  build(): Promise<EntChangeset<TEnt>>;
103
+ buildWithOptions_BETA(options: ChangesetOptions): Promise<EntChangeset<TEnt>>;
83
104
  private viewerForEntLoad;
84
105
  returnedRow(): Promise<Data | null>;
85
106
  editedEnt(): Promise<TEnt | null>;
@@ -87,14 +108,16 @@ export declare class Orchestrator<TEnt extends Ent<TViewer>, TInput extends Data
87
108
  }
88
109
  export declare class EntChangeset<T extends Ent> implements Changeset {
89
110
  viewer: Viewer;
111
+ private builder;
90
112
  readonly placeholderID: ID;
91
- readonly ent: EntConstructor<T>;
113
+ private conditionalOverride;
92
114
  operations: DataOperation[];
93
115
  dependencies?: Map<ID, Builder<Ent<Viewer<Ent<any> | null, ID | null>>, Viewer<Ent<any> | null, ID | null>, Ent<Viewer<Ent<any> | null, ID | null>> | null>> | undefined;
94
116
  changesets?: Changeset[] | undefined;
95
117
  private options?;
96
118
  private _executor;
97
- constructor(viewer: Viewer, placeholderID: ID, ent: EntConstructor<T>, operations: DataOperation[], dependencies?: Map<ID, Builder<Ent<Viewer<Ent<any> | null, ID | null>>, Viewer<Ent<any> | null, ID | null>, Ent<Viewer<Ent<any> | null, ID | null>> | null>> | undefined, changesets?: Changeset[] | undefined, options?: OrchestratorOptions<T, Viewer<Ent<any> | null, ID | null>, Data, MaybeNull<T>> | undefined);
119
+ constructor(viewer: Viewer, builder: Builder<T>, placeholderID: ID, conditionalOverride: boolean, operations: DataOperation[], dependencies?: Map<ID, Builder<Ent<Viewer<Ent<any> | null, ID | null>>, Viewer<Ent<any> | null, ID | null>, Ent<Viewer<Ent<any> | null, ID | null>> | null>> | undefined, changesets?: Changeset[] | undefined, options?: OrchestratorOptions<T, Data, Viewer<Ent<any> | null, ID | null>, MaybeNull<T>> | undefined);
120
+ static changesetFrom(builder: Builder<any, any, any>, ops: DataOperation[]): EntChangeset<any>;
98
121
  executor(): Executor;
99
122
  }
100
123
  export {};