@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,13 +1,14 @@
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";
2
+ import { parameterizedQueryOptions } from "../core/ent";
3
3
  import { SchemaInputType, FieldInfoMap } from "../schema/schema";
4
- import { Changeset, Executor } from "../action/action";
4
+ import { Changeset, ChangesetOptions, Executor } from "../action/action";
5
+ import { AssocEdgeInputOptions, DataOperation, AssocEdgeOptions } from "./operations";
5
6
  import { WriteOperation, Builder, Action } from "../action";
6
7
  import * as clause from "../core/clause";
7
8
  type MaybeNull<T extends Ent> = T | null;
8
9
  type TMaybleNullableEnt<T extends Ent> = T | MaybeNull<T>;
9
10
  export interface OrchestratorOptions<TEnt extends Ent<TViewer>, TInput extends Data, TViewer extends Viewer, TExistingEnt extends TMaybleNullableEnt<TEnt> = MaybeNull<TEnt>> {
10
- viewer: Viewer;
11
+ viewer: TViewer;
11
12
  operation: WriteOperation;
12
13
  tableName: string;
13
14
  loaderOptions: LoadEntOptions<TEnt, TViewer>;
@@ -37,6 +38,7 @@ export declare class Orchestrator<TEnt extends Ent<TViewer>, TInput extends Data
37
38
  private options;
38
39
  private edgeSet;
39
40
  private edges;
41
+ private conditionalEdges;
40
42
  private validatedFields;
41
43
  private logValues;
42
44
  private changesets;
@@ -49,21 +51,24 @@ export declare class Orchestrator<TEnt extends Ent<TViewer>, TInput extends Data
49
51
  private actualOperation;
50
52
  private existingEnt;
51
53
  private disableTransformations;
54
+ private onConflict;
52
55
  private memoizedGetFields;
53
56
  constructor(options: OrchestratorOptions<TEnt, TInput, TViewer, TExistingEnt>);
54
57
  __getOptions(): OrchestratorOptions<any, any, any, any>;
55
58
  private addEdge;
56
59
  setDisableTransformations(val: boolean): void;
60
+ setOnConflictOptions(onConflict: CreateRowOptions["onConflict"]): void;
57
61
  addInboundEdge<T2 extends Ent>(id1: ID | Builder<T2, any>, edgeType: string, nodeType: string, options?: AssocEdgeInputOptions): void;
58
62
  addOutboundEdge<T2 extends Ent>(id2: ID | Builder<T2, any>, edgeType: string, nodeType: string, options?: AssocEdgeInputOptions): void;
59
- removeInboundEdge(id1: ID, edgeType: string): void;
60
- removeOutboundEdge(id2: ID, edgeType: string): void;
63
+ removeInboundEdge(id1: ID, edgeType: string, options?: AssocEdgeOptions): void;
64
+ removeOutboundEdge(id2: ID, edgeType: string, options?: AssocEdgeOptions): void;
61
65
  getInputEdges(edgeType: string, op: WriteOperation): EdgeInputData[];
62
66
  clearInputEdges(edgeType: string, op: WriteOperation, id?: ID): void;
63
67
  private buildMainOp;
64
68
  private getEdgeOperation;
65
69
  private buildEdgeOps;
66
70
  private throwError;
71
+ private getRowForPrivacyPolicyImpl;
67
72
  private getEntForPrivacyPolicyImpl;
68
73
  private getSQLStatementOperation;
69
74
  private getWriteOpForSQLStamentOp;
@@ -95,7 +100,9 @@ export declare class Orchestrator<TEnt extends Ent<TViewer>, TInput extends Data
95
100
  * If those throws, this still throws and doesn't return them
96
101
  */
97
102
  validWithErrors(): Promise<Error[]>;
103
+ private buildPlusChangeset;
98
104
  build(): Promise<EntChangeset<TEnt>>;
105
+ buildWithOptions_BETA(options: ChangesetOptions): Promise<EntChangeset<TEnt>>;
99
106
  private viewerForEntLoad;
100
107
  returnedRow(): Promise<Data | null>;
101
108
  editedEnt(): Promise<TEnt | null>;
@@ -103,15 +110,22 @@ export declare class Orchestrator<TEnt extends Ent<TViewer>, TInput extends Data
103
110
  }
104
111
  export declare class EntChangeset<T extends Ent> implements Changeset {
105
112
  viewer: Viewer;
113
+ private builder;
106
114
  readonly placeholderID: ID;
107
- readonly ent: EntConstructor<T>;
115
+ private conditionalOverride;
108
116
  operations: DataOperation[];
109
117
  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;
110
118
  changesets?: Changeset[] | undefined;
111
119
  private options?;
112
120
  private _executor;
113
- 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, Data, Viewer<Ent<any> | null, ID | null>, MaybeNull<T>> | undefined);
121
+ 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);
114
122
  static changesetFrom(builder: Builder<any, any, any>, ops: DataOperation[]): EntChangeset<any>;
123
+ static changesetFromQueries(builder: Builder<any, any, any>, queries: Array<string | parameterizedQueryOptions>): EntChangeset<any>;
124
+ private static changesetFromEdgeOp;
125
+ static changesetFromOutboundEdge(builder: Builder<any, any, any>, edgeType: string, id2: Builder<any> | ID, nodeType: string, options?: AssocEdgeInputOptions): Promise<EntChangeset<any>>;
126
+ static changesetFromInboundEdge(builder: Builder<any, any, any>, edgeType: string, id1: Builder<any> | ID, nodeType: string, options?: AssocEdgeInputOptions): Promise<EntChangeset<any>>;
127
+ static changesetRemoveFromOutboundEdge(builder: Builder<any, any, any>, edgeType: string, id2: ID, options?: AssocEdgeInputOptions): Promise<EntChangeset<any>>;
128
+ static changesetRemoveFromInboundEdge(builder: Builder<any, any, any>, edgeType: string, id1: ID, options?: AssocEdgeInputOptions): Promise<EntChangeset<any>>;
115
129
  executor(): Executor;
116
130
  }
117
131
  export {};