@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.
- package/action/action.d.ts +8 -1
- package/action/executor.d.ts +16 -3
- package/action/executor.js +83 -27
- package/action/index.d.ts +2 -1
- package/action/operations.d.ts +126 -0
- package/action/operations.js +686 -0
- package/action/orchestrator.d.ts +22 -8
- package/action/orchestrator.js +278 -67
- package/core/base.d.ts +34 -24
- package/core/clause.d.ts +62 -79
- package/core/clause.js +77 -5
- package/core/config.d.ts +5 -1
- package/core/config.js +3 -0
- package/core/const.d.ts +3 -0
- package/core/const.js +6 -0
- package/core/context.d.ts +4 -3
- package/core/context.js +2 -1
- package/core/db.d.ts +1 -0
- package/core/db.js +7 -7
- package/core/ent.d.ts +53 -105
- package/core/ent.js +104 -599
- package/core/global_schema.d.ts +7 -0
- package/core/global_schema.js +51 -0
- package/core/loaders/assoc_count_loader.d.ts +4 -2
- package/core/loaders/assoc_count_loader.js +10 -2
- package/core/loaders/assoc_edge_loader.d.ts +2 -3
- package/core/loaders/assoc_edge_loader.js +16 -7
- package/core/loaders/index.d.ts +0 -1
- package/core/loaders/index.js +1 -3
- package/core/loaders/loader.d.ts +3 -3
- package/core/loaders/loader.js +3 -20
- package/core/loaders/object_loader.d.ts +30 -10
- package/core/loaders/object_loader.js +179 -40
- package/core/loaders/query_loader.d.ts +4 -4
- package/core/loaders/query_loader.js +14 -19
- package/core/loaders/raw_count_loader.d.ts +1 -0
- package/core/loaders/raw_count_loader.js +3 -2
- package/core/privacy.d.ts +19 -10
- package/core/privacy.js +47 -26
- package/core/query/assoc_query.js +1 -1
- package/core/query/custom_clause_query.d.ts +6 -3
- package/core/query/custom_clause_query.js +36 -9
- package/core/query/custom_query.d.ts +3 -1
- package/core/query/custom_query.js +29 -6
- package/core/query/query.d.ts +12 -2
- package/core/query/query.js +67 -38
- package/core/query/shared_assoc_test.js +151 -10
- package/core/query/shared_test.d.ts +2 -2
- package/core/query/shared_test.js +90 -30
- package/core/query_impl.d.ts +8 -0
- package/core/query_impl.js +28 -0
- package/core/viewer.d.ts +2 -0
- package/core/viewer.js +2 -0
- package/graphql/graphql.d.ts +103 -19
- package/graphql/graphql.js +169 -134
- package/graphql/graphql_field_helpers.d.ts +9 -3
- package/graphql/graphql_field_helpers.js +22 -2
- package/graphql/index.d.ts +2 -1
- package/graphql/index.js +5 -2
- package/graphql/scalars/orderby_direction.d.ts +2 -0
- package/graphql/scalars/orderby_direction.js +15 -0
- package/imports/dataz/example1/_auth.js +128 -47
- package/imports/dataz/example1/_viewer.js +87 -39
- package/imports/index.d.ts +1 -1
- package/imports/index.js +2 -2
- package/index.d.ts +12 -1
- package/index.js +18 -6
- package/package.json +20 -17
- package/parse_schema/parse.d.ts +10 -4
- package/parse_schema/parse.js +70 -24
- package/schema/base_schema.d.ts +8 -0
- package/schema/base_schema.js +11 -0
- package/schema/field.d.ts +6 -3
- package/schema/field.js +72 -17
- package/schema/index.d.ts +1 -1
- package/schema/index.js +2 -1
- package/schema/json_field.d.ts +3 -3
- package/schema/json_field.js +4 -1
- package/schema/schema.d.ts +42 -5
- package/schema/schema.js +35 -41
- package/schema/struct_field.d.ts +8 -6
- package/schema/struct_field.js +67 -8
- package/schema/union_field.d.ts +1 -1
- package/scripts/custom_compiler.js +4 -4
- package/scripts/custom_graphql.js +105 -75
- package/scripts/move_types.js +4 -1
- package/scripts/read_schema.js +2 -2
- package/testutils/action/complex_schemas.d.ts +1 -1
- package/testutils/action/complex_schemas.js +10 -3
- package/testutils/builder.d.ts +3 -0
- package/testutils/builder.js +6 -0
- package/testutils/db/temp_db.d.ts +9 -1
- package/testutils/db/temp_db.js +82 -14
- package/testutils/db_mock.js +1 -3
- package/testutils/ent-graphql-tests/index.d.ts +1 -1
- package/testutils/ent-graphql-tests/index.js +30 -19
- package/testutils/fake_comms.js +1 -1
- package/testutils/fake_data/fake_contact.d.ts +1 -1
- package/testutils/fake_data/fake_tag.d.ts +1 -1
- package/testutils/fake_data/fake_user.d.ts +3 -3
- package/testutils/fake_data/fake_user.js +15 -4
- package/testutils/fake_data/tag_query.js +8 -3
- package/testutils/fake_data/test_helpers.d.ts +3 -2
- package/testutils/fake_data/test_helpers.js +4 -4
- package/testutils/fake_data/user_query.d.ts +5 -2
- package/testutils/fake_data/user_query.js +19 -2
- package/testutils/fake_log.js +1 -1
- package/tsc/ast.js +2 -1
- package/tsc/move_generated.js +2 -2
- package/tsc/transform.d.ts +2 -2
- package/tsc/transform.js +4 -3
- package/tsc/transform_ent.js +2 -1
- package/tsc/transform_schema.js +4 -3
- package/core/loaders/index_loader.d.ts +0 -14
- package/core/loaders/index_loader.js +0 -27
package/action/action.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ent, EntConstructor, Viewer, ID, Data, PrivacyPolicy, Context, WriteOperation } from "../core/base";
|
|
2
|
-
import { DataOperation, AssocEdgeInputOptions } from "
|
|
2
|
+
import { DataOperation, AssocEdgeInputOptions } from "./operations";
|
|
3
3
|
import { Queryer } from "../core/db";
|
|
4
4
|
import { TransformedUpdateOperation, UpdateOperation } from "../schema";
|
|
5
5
|
import { FieldInfoMap } from "../schema/schema";
|
|
@@ -17,6 +17,7 @@ export interface Builder<TEnt extends Ent<TViewer>, TViewer extends Viewer = Vie
|
|
|
17
17
|
placeholderID: ID;
|
|
18
18
|
readonly viewer: TViewer;
|
|
19
19
|
build(): Promise<Changeset>;
|
|
20
|
+
buildWithOptions_BETA?(options: ChangesetOptions): Promise<Changeset>;
|
|
20
21
|
operation: WriteOperation;
|
|
21
22
|
editedEnt?(): Promise<TEnt | null>;
|
|
22
23
|
nodeType: string;
|
|
@@ -26,6 +27,8 @@ export interface Builder<TEnt extends Ent<TViewer>, TViewer extends Viewer = Vie
|
|
|
26
27
|
export interface Executor extends Iterable<DataOperation>, Iterator<DataOperation> {
|
|
27
28
|
placeholderID: ID;
|
|
28
29
|
resolveValue(val: any): Ent | null;
|
|
30
|
+
builderOpChanged(builder: Builder<any>): boolean;
|
|
31
|
+
builder?: Builder<Ent>;
|
|
29
32
|
execute(): Promise<void>;
|
|
30
33
|
preFetch?(queryer: Queryer, context?: Context): Promise<void>;
|
|
31
34
|
postFetch?(queryer: Queryer, context?: Context): Promise<void>;
|
|
@@ -48,9 +51,13 @@ export interface Observer<TEnt extends Ent<TViewer>, TBuilder extends Builder<TE
|
|
|
48
51
|
export interface Validator<TEnt extends Ent<TViewer>, TBuilder extends Builder<TEnt, TViewer, TExistingEnt>, TViewer extends Viewer = Viewer, TInput extends Data = Data, TExistingEnt extends TMaybleNullableEnt<TEnt> = MaybeNull<TEnt>> {
|
|
49
52
|
validate(builder: TBuilder, input: TInput): Promise<void | undefined | Error> | void | Error | undefined;
|
|
50
53
|
}
|
|
54
|
+
export interface ChangesetOptions {
|
|
55
|
+
conditionalBuilder: Builder<any, any>;
|
|
56
|
+
}
|
|
51
57
|
export interface Action<TEnt extends Ent<TViewer>, TBuilder extends Builder<TEnt, TViewer, TExistingEnt>, TViewer extends Viewer = Viewer, TInput extends Data = Data, TExistingEnt extends TMaybleNullableEnt<TEnt> = MaybeNull<TEnt>> {
|
|
52
58
|
readonly viewer: Viewer;
|
|
53
59
|
changeset(): Promise<Changeset>;
|
|
60
|
+
changesetWithOptions_BETA?(options: ChangesetOptions): Promise<Changeset>;
|
|
54
61
|
builder: TBuilder;
|
|
55
62
|
getPrivacyPolicy(): PrivacyPolicy<TEnt>;
|
|
56
63
|
getTriggers?(): (Trigger<TEnt, TBuilder, TViewer, TInput, TExistingEnt> | Trigger<TEnt, TBuilder, TViewer, TInput, TExistingEnt>[])[];
|
package/action/executor.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { ID, Ent, Viewer, Context, Data } from "../core/base";
|
|
2
|
-
import { DataOperation } from "../core/ent";
|
|
3
2
|
import { Changeset, Executor } from "../action/action";
|
|
4
3
|
import { Builder } from "../action";
|
|
5
4
|
import { OrchestratorOptions } from "./orchestrator";
|
|
6
5
|
import { Queryer } from "../core/db";
|
|
6
|
+
import { DataOperation } from "./operations";
|
|
7
7
|
export declare class ListBasedExecutor<T extends Ent> implements Executor {
|
|
8
8
|
private viewer;
|
|
9
9
|
placeholderID: ID;
|
|
10
10
|
private operations;
|
|
11
11
|
private options?;
|
|
12
|
+
private complexOptions?;
|
|
12
13
|
private idx;
|
|
13
|
-
|
|
14
|
+
builder?: Builder<Ent> | undefined;
|
|
15
|
+
constructor(viewer: Viewer, placeholderID: ID, operations: DataOperation<T>[], options?: OrchestratorOptions<T, Data, Viewer<Ent<any> | null, ID | null>, T | null> | undefined, complexOptions?: ComplexExecutorOptions | undefined);
|
|
14
16
|
private lastOp;
|
|
15
17
|
private createdEnt;
|
|
18
|
+
private changedOps;
|
|
16
19
|
resolveValue(val: ID): Ent | null;
|
|
20
|
+
builderOpChanged(builder: Builder<any>): boolean;
|
|
17
21
|
[Symbol.iterator](): this;
|
|
18
22
|
next(): IteratorResult<DataOperation<T>>;
|
|
19
23
|
executeObservers(): Promise<void>;
|
|
@@ -21,22 +25,31 @@ export declare class ListBasedExecutor<T extends Ent> implements Executor {
|
|
|
21
25
|
preFetch?(queryer: Queryer, context: Context): Promise<void>;
|
|
22
26
|
postFetch?(queryer: Queryer, context: Context): Promise<void>;
|
|
23
27
|
}
|
|
28
|
+
interface ComplexExecutorOptions {
|
|
29
|
+
conditionalOverride: boolean;
|
|
30
|
+
builder: Builder<any, any>;
|
|
31
|
+
}
|
|
24
32
|
export declare class ComplexExecutor<T extends Ent> implements Executor {
|
|
25
33
|
private viewer;
|
|
26
34
|
placeholderID: ID;
|
|
35
|
+
private complexOptions?;
|
|
27
36
|
private idx;
|
|
28
37
|
private mapper;
|
|
29
38
|
private lastOp;
|
|
30
39
|
private allOperations;
|
|
31
40
|
private executors;
|
|
32
|
-
|
|
41
|
+
private changedOps;
|
|
42
|
+
builder?: Builder<Ent> | undefined;
|
|
43
|
+
constructor(viewer: Viewer, placeholderID: ID, operations: DataOperation[], dependencies: Map<ID, Builder<T>>, changesets: Changeset[], options?: OrchestratorOptions<T, Data, Viewer>, complexOptions?: ComplexExecutorOptions | undefined);
|
|
33
44
|
[Symbol.iterator](): this;
|
|
34
45
|
private handleCreatedEnt;
|
|
35
46
|
next(): IteratorResult<DataOperation<Ent>>;
|
|
36
47
|
resolveValue(val: ID): Ent | null;
|
|
48
|
+
builderOpChanged(builder: Builder<any>): boolean;
|
|
37
49
|
executeObservers(): Promise<void>;
|
|
38
50
|
execute(): Promise<void>;
|
|
39
51
|
preFetch?(queryer: Queryer, context: Context): Promise<void>;
|
|
40
52
|
postFetch?(queryer: Queryer, context: Context): Promise<void>;
|
|
41
53
|
}
|
|
42
54
|
export declare function executeOperations(executor: Executor, context?: Context, trackOps?: true): Promise<DataOperation<Ent<Viewer<Ent<any> | null, ID | null>>>[]>;
|
|
55
|
+
export {};
|
package/action/executor.js
CHANGED
|
@@ -4,19 +4,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.executeOperations = exports.ComplexExecutor = exports.ListBasedExecutor = void 0;
|
|
7
|
-
const graph_data_structure_1 =
|
|
7
|
+
const graph_data_structure_1 = require("graph-data-structure");
|
|
8
8
|
const ent_1 = require("../core/ent");
|
|
9
9
|
const db_1 = __importDefault(require("../core/db"));
|
|
10
10
|
const logger_1 = require("../core/logger");
|
|
11
|
+
const operations_1 = require("./operations");
|
|
11
12
|
// private to ent
|
|
12
13
|
class ListBasedExecutor {
|
|
13
|
-
constructor(viewer, placeholderID, operations, options) {
|
|
14
|
+
constructor(viewer, placeholderID, operations, options, complexOptions) {
|
|
14
15
|
this.viewer = viewer;
|
|
15
16
|
this.placeholderID = placeholderID;
|
|
16
17
|
this.operations = operations;
|
|
17
18
|
this.options = options;
|
|
19
|
+
this.complexOptions = complexOptions;
|
|
18
20
|
this.idx = 0;
|
|
19
21
|
this.createdEnt = null;
|
|
22
|
+
this.changedOps = new Map();
|
|
23
|
+
this.builder = options?.builder;
|
|
20
24
|
}
|
|
21
25
|
resolveValue(val) {
|
|
22
26
|
if (val === this.placeholderID && val !== undefined) {
|
|
@@ -24,6 +28,10 @@ class ListBasedExecutor {
|
|
|
24
28
|
}
|
|
25
29
|
return null;
|
|
26
30
|
}
|
|
31
|
+
builderOpChanged(builder) {
|
|
32
|
+
const v = this.changedOps.get(builder.placeholderID);
|
|
33
|
+
return v !== undefined && v !== builder.operation;
|
|
34
|
+
}
|
|
27
35
|
[Symbol.iterator]() {
|
|
28
36
|
return this;
|
|
29
37
|
}
|
|
@@ -33,17 +41,19 @@ class ListBasedExecutor {
|
|
|
33
41
|
if (createdEnt) {
|
|
34
42
|
this.createdEnt = createdEnt;
|
|
35
43
|
}
|
|
36
|
-
|
|
37
|
-
const
|
|
44
|
+
maybeFlagOpOperationAsChanged(this.lastOp, this.changedOps);
|
|
45
|
+
const done = this.idx >= this.operations.length;
|
|
46
|
+
const op = maybeChangeOp(this.operations[this.idx], this.complexOptions);
|
|
38
47
|
this.idx++;
|
|
39
48
|
this.lastOp = op;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
if (done || op === undefined) {
|
|
50
|
+
return {
|
|
51
|
+
value: op,
|
|
52
|
+
done: true,
|
|
53
|
+
};
|
|
43
54
|
}
|
|
44
55
|
return {
|
|
45
56
|
value: op,
|
|
46
|
-
done: done,
|
|
47
57
|
};
|
|
48
58
|
}
|
|
49
59
|
async executeObservers() {
|
|
@@ -53,7 +63,13 @@ class ListBasedExecutor {
|
|
|
53
63
|
}
|
|
54
64
|
const builder = this.options.builder;
|
|
55
65
|
await Promise.all(action.getObservers().map(async (observer) => {
|
|
56
|
-
|
|
66
|
+
try {
|
|
67
|
+
await observer.observe(builder, action.getInput());
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
// TODO we eventually want a global observer error handler so that this can be logged or whatever...
|
|
71
|
+
// TODO https://github.com/lolopinto/ent/issues/1429
|
|
72
|
+
}
|
|
57
73
|
}));
|
|
58
74
|
}
|
|
59
75
|
async execute() {
|
|
@@ -85,15 +101,28 @@ function getCreatedEnt(viewer, op) {
|
|
|
85
101
|
}
|
|
86
102
|
return null;
|
|
87
103
|
}
|
|
104
|
+
function maybeFlagOpOperationAsChanged(op, changedOps) {
|
|
105
|
+
if (!op || !op.updatedOperation) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const r = op.updatedOperation();
|
|
109
|
+
if (!r || r.builder.operation === r.operation) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
changedOps.set(r.builder.placeholderID, r.operation);
|
|
113
|
+
}
|
|
88
114
|
class ComplexExecutor {
|
|
89
|
-
constructor(viewer, placeholderID, operations, dependencies, changesets, options) {
|
|
115
|
+
constructor(viewer, placeholderID, operations, dependencies, changesets, options, complexOptions) {
|
|
90
116
|
this.viewer = viewer;
|
|
91
117
|
this.placeholderID = placeholderID;
|
|
118
|
+
this.complexOptions = complexOptions;
|
|
92
119
|
this.idx = 0;
|
|
93
120
|
this.mapper = new Map();
|
|
94
121
|
this.allOperations = [];
|
|
95
122
|
this.executors = [];
|
|
96
|
-
|
|
123
|
+
this.changedOps = new Map();
|
|
124
|
+
this.builder = options?.builder;
|
|
125
|
+
let graph = (0, graph_data_structure_1.Graph)();
|
|
97
126
|
const changesetMap = new Map();
|
|
98
127
|
const impl = (c) => {
|
|
99
128
|
changesetMap.set(c.placeholderID.toString(), c);
|
|
@@ -171,25 +200,24 @@ class ComplexExecutor {
|
|
|
171
200
|
}
|
|
172
201
|
const placeholderID = this.lastOp.placeholderID;
|
|
173
202
|
if (!placeholderID) {
|
|
174
|
-
|
|
175
|
-
return;
|
|
203
|
+
throw new Error(`op ${this.lastOp} which implements getCreatedEnt doesn't have a placeholderID`);
|
|
176
204
|
}
|
|
177
205
|
this.mapper.set(placeholderID, createdEnt);
|
|
178
206
|
}
|
|
179
207
|
next() {
|
|
180
208
|
this.handleCreatedEnt();
|
|
181
|
-
|
|
182
|
-
const
|
|
209
|
+
maybeFlagOpOperationAsChanged(this.lastOp, this.changedOps);
|
|
210
|
+
const done = this.idx >= this.allOperations.length;
|
|
211
|
+
const op = maybeChangeOp(this.allOperations[this.idx], this.complexOptions);
|
|
183
212
|
this.idx++;
|
|
184
213
|
this.lastOp = op;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
214
|
+
if (done || op === undefined) {
|
|
215
|
+
return {
|
|
216
|
+
value: op,
|
|
217
|
+
done: true,
|
|
218
|
+
};
|
|
188
219
|
}
|
|
189
|
-
return {
|
|
190
|
-
value: op,
|
|
191
|
-
done: done,
|
|
192
|
-
};
|
|
220
|
+
return { value: op };
|
|
193
221
|
}
|
|
194
222
|
resolveValue(val) {
|
|
195
223
|
let ent = this.mapper.get(val);
|
|
@@ -204,8 +232,15 @@ class ComplexExecutor {
|
|
|
204
232
|
}
|
|
205
233
|
return null;
|
|
206
234
|
}
|
|
235
|
+
builderOpChanged(builder) {
|
|
236
|
+
const v = this.changedOps.get(builder.placeholderID);
|
|
237
|
+
return v !== undefined && v !== builder.operation;
|
|
238
|
+
}
|
|
207
239
|
async executeObservers() {
|
|
208
240
|
await Promise.all(this.executors.map((executor) => {
|
|
241
|
+
if (executor.builder && this.builderOpChanged(executor.builder)) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
209
244
|
if (!executor.executeObservers) {
|
|
210
245
|
return null;
|
|
211
246
|
}
|
|
@@ -248,6 +283,9 @@ async function executeOperations(executor, context, trackOps) {
|
|
|
248
283
|
if (isSyncClient(client)) {
|
|
249
284
|
client.runInTransaction(() => {
|
|
250
285
|
for (const operation of executor) {
|
|
286
|
+
if (operation.shortCircuit && operation.shortCircuit(executor)) {
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
251
289
|
if (trackOps) {
|
|
252
290
|
operations.push(operation);
|
|
253
291
|
}
|
|
@@ -262,6 +300,9 @@ async function executeOperations(executor, context, trackOps) {
|
|
|
262
300
|
(0, ent_1.logQuery)("BEGIN", []);
|
|
263
301
|
await client.query("BEGIN");
|
|
264
302
|
for (const operation of executor) {
|
|
303
|
+
if (operation.shortCircuit && operation.shortCircuit(executor)) {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
265
306
|
if (trackOps) {
|
|
266
307
|
operations.push(operation);
|
|
267
308
|
}
|
|
@@ -277,9 +318,7 @@ async function executeOperations(executor, context, trackOps) {
|
|
|
277
318
|
if (executor.postFetch) {
|
|
278
319
|
await executor.postFetch(client, context);
|
|
279
320
|
}
|
|
280
|
-
|
|
281
|
-
await executor.executeObservers();
|
|
282
|
-
}
|
|
321
|
+
client.release();
|
|
283
322
|
}
|
|
284
323
|
catch (e) {
|
|
285
324
|
if (!isSyncClient(client)) {
|
|
@@ -287,12 +326,29 @@ async function executeOperations(executor, context, trackOps) {
|
|
|
287
326
|
(0, ent_1.logQuery)("ROLLBACK", []);
|
|
288
327
|
await client.query("ROLLBACK");
|
|
289
328
|
}
|
|
329
|
+
client.release(e);
|
|
290
330
|
(0, logger_1.log)("error", e);
|
|
291
331
|
throw e;
|
|
292
332
|
}
|
|
293
|
-
|
|
294
|
-
|
|
333
|
+
if (executor.executeObservers) {
|
|
334
|
+
try {
|
|
335
|
+
await executor.executeObservers();
|
|
336
|
+
}
|
|
337
|
+
catch (e) { }
|
|
295
338
|
}
|
|
296
339
|
return operations;
|
|
297
340
|
}
|
|
298
341
|
exports.executeOperations = executeOperations;
|
|
342
|
+
function maybeChangeOp(op, complexOptions) {
|
|
343
|
+
if (!op ||
|
|
344
|
+
!complexOptions?.conditionalOverride ||
|
|
345
|
+
op instanceof operations_1.ConditionalNodeOperation) {
|
|
346
|
+
return op;
|
|
347
|
+
}
|
|
348
|
+
if (op.createdEnt) {
|
|
349
|
+
return new operations_1.ConditionalNodeOperation(op, complexOptions.builder);
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
return new operations_1.ConditionalOperation(op, complexOptions.builder);
|
|
353
|
+
}
|
|
354
|
+
}
|
package/action/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { WriteOperation, Builder, Changeset, Trigger, Observer, Validator, Action, saveBuilder, saveBuilderX, setEdgeTypeInGroup, TriggerReturn, } from "./action";
|
|
1
|
+
export { WriteOperation, Builder, Changeset, Trigger, Observer, Validator, Action, saveBuilder, saveBuilderX, setEdgeTypeInGroup, TriggerReturn, ChangesetOptions, } from "./action";
|
|
2
2
|
export { OrchestratorOptions, Orchestrator, EntChangeset, EdgeInputData, } from "./orchestrator";
|
|
3
3
|
export { DenyIfBuilder, AllowIfBuilder } from "./privacy";
|
|
4
4
|
export { RelativeFieldValue, RelativeNumberValue, NumberOps, convertRelativeInput, maybeConvertRelativeInputPlusExpressions, } from "./relative_value";
|
|
5
5
|
export { Transaction } from "./transaction";
|
|
6
|
+
export { AssocEdgeOptions } from "./operations";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Queryer, SyncQueryer } from "../core/db";
|
|
2
|
+
import { Viewer, Ent, ID, Data, DataOptions, EditRowOptions, LoadEntOptions, Context, CreateRowOptions } from "../core/base";
|
|
3
|
+
import { Executor } from "../action/action";
|
|
4
|
+
import { WriteOperation, Builder } from "../action";
|
|
5
|
+
import { AssocEdgeData, parameterizedQueryOptions } from "../core/ent";
|
|
6
|
+
export interface UpdatedOperation {
|
|
7
|
+
operation: WriteOperation;
|
|
8
|
+
builder: Builder<any>;
|
|
9
|
+
}
|
|
10
|
+
export interface DataOperation<T extends Ent = Ent> {
|
|
11
|
+
builder: Builder<T>;
|
|
12
|
+
preFetch?(queryer: Queryer, context?: Context): Promise<void>;
|
|
13
|
+
performWriteSync(queryer: SyncQueryer, context?: Context): void;
|
|
14
|
+
performWrite(queryer: Queryer, context?: Context): Promise<void>;
|
|
15
|
+
placeholderID?: ID;
|
|
16
|
+
returnedRow?(): Data | null;
|
|
17
|
+
createdEnt?(viewer: Viewer): T | null;
|
|
18
|
+
shortCircuit?(executor: Executor): boolean;
|
|
19
|
+
updatedOperation?(): UpdatedOperation | null;
|
|
20
|
+
resolve?(executor: Executor): void;
|
|
21
|
+
postFetch?(queryer: Queryer, context?: Context): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export declare class DeleteNodeOperation implements DataOperation {
|
|
24
|
+
private id;
|
|
25
|
+
readonly builder: Builder<Ent>;
|
|
26
|
+
private options;
|
|
27
|
+
constructor(id: ID, builder: Builder<Ent>, options: DataOptions);
|
|
28
|
+
performWrite(queryer: Queryer, context?: Context): Promise<void>;
|
|
29
|
+
performWriteSync(queryer: SyncQueryer, context?: Context): void;
|
|
30
|
+
}
|
|
31
|
+
export declare class RawQueryOperation<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> implements DataOperation<TEnt> {
|
|
32
|
+
builder: Builder<TEnt, TViewer>;
|
|
33
|
+
private queries;
|
|
34
|
+
constructor(builder: Builder<TEnt, TViewer>, queries: (string | parameterizedQueryOptions)[]);
|
|
35
|
+
performWrite(queryer: Queryer, context?: Context): Promise<void>;
|
|
36
|
+
performWriteSync(queryer: SyncQueryer, context?: Context): void;
|
|
37
|
+
}
|
|
38
|
+
export interface EditNodeOptions<T extends Ent> extends EditRowOptions {
|
|
39
|
+
fieldsToResolve: string[];
|
|
40
|
+
loadEntOptions: LoadEntOptions<T>;
|
|
41
|
+
key: string;
|
|
42
|
+
onConflict?: CreateRowOptions["onConflict"];
|
|
43
|
+
builder: Builder<T>;
|
|
44
|
+
}
|
|
45
|
+
export declare class EditNodeOperation<T extends Ent> implements DataOperation {
|
|
46
|
+
options: EditNodeOptions<T>;
|
|
47
|
+
private existingEnt;
|
|
48
|
+
private row;
|
|
49
|
+
placeholderID?: ID | undefined;
|
|
50
|
+
private updatedOp;
|
|
51
|
+
builder: Builder<T>;
|
|
52
|
+
private resolved;
|
|
53
|
+
constructor(options: EditNodeOptions<T>, existingEnt?: Ent | null);
|
|
54
|
+
resolve<T extends Ent>(executor: Executor): void;
|
|
55
|
+
private hasData;
|
|
56
|
+
private buildOnConflictQuery;
|
|
57
|
+
performWrite(queryer: Queryer, context?: Context): Promise<void>;
|
|
58
|
+
private buildReloadQuery;
|
|
59
|
+
private reloadRow;
|
|
60
|
+
performWriteSync(queryer: SyncQueryer, context?: Context): void;
|
|
61
|
+
returnedRow(): Data | null;
|
|
62
|
+
createdEnt(viewer: Viewer): T | null;
|
|
63
|
+
updatedOperation(): UpdatedOperation | null;
|
|
64
|
+
}
|
|
65
|
+
export interface AssocEdgeInputOptions extends AssocEdgeOptions {
|
|
66
|
+
time?: Date;
|
|
67
|
+
data?: string | Builder<Ent>;
|
|
68
|
+
}
|
|
69
|
+
export interface AssocEdgeOptions {
|
|
70
|
+
conditional?: boolean;
|
|
71
|
+
disableTransformations?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface AssocEdgeInput extends AssocEdgeInputOptions {
|
|
74
|
+
id1: ID;
|
|
75
|
+
id1Type: string;
|
|
76
|
+
edgeType: string;
|
|
77
|
+
id2: ID;
|
|
78
|
+
id2Type: string;
|
|
79
|
+
}
|
|
80
|
+
export declare class EdgeOperation implements DataOperation {
|
|
81
|
+
builder: Builder<any>;
|
|
82
|
+
edgeInput: AssocEdgeInput;
|
|
83
|
+
private options;
|
|
84
|
+
private edgeData;
|
|
85
|
+
private constructor();
|
|
86
|
+
preFetch(queryer: Queryer, context?: Context): Promise<void>;
|
|
87
|
+
performWrite(queryer: Queryer, context?: Context): Promise<void>;
|
|
88
|
+
performWriteSync(queryer: SyncQueryer, context?: Context): void;
|
|
89
|
+
private getDeleteRowParams;
|
|
90
|
+
private performDeleteWrite;
|
|
91
|
+
private performDeleteWriteSync;
|
|
92
|
+
private getInsertRowParams;
|
|
93
|
+
private performInsertWrite;
|
|
94
|
+
private performInsertWriteSync;
|
|
95
|
+
private resolveImpl;
|
|
96
|
+
resolve(executor: Executor): void;
|
|
97
|
+
symmetricEdge(): EdgeOperation;
|
|
98
|
+
inverseEdge(edgeData: AssocEdgeData): EdgeOperation;
|
|
99
|
+
private static resolveIDs;
|
|
100
|
+
private static isBuilder;
|
|
101
|
+
private static resolveData;
|
|
102
|
+
static inboundEdge<T extends Ent, T2 extends Ent>(builder: Builder<T>, edgeType: string, id1: Builder<T2> | ID, nodeType: string, options?: AssocEdgeInputOptions): EdgeOperation;
|
|
103
|
+
static outboundEdge<T extends Ent, T2 extends Ent>(builder: Builder<T>, edgeType: string, id2: Builder<T2> | ID, nodeType: string, options?: AssocEdgeInputOptions): EdgeOperation;
|
|
104
|
+
static removeInboundEdge<T extends Ent>(builder: Builder<T>, edgeType: string, id1: ID, options?: AssocEdgeInputOptions): EdgeOperation;
|
|
105
|
+
static removeOutboundEdge<T extends Ent>(builder: Builder<T>, edgeType: string, id2: ID, options?: AssocEdgeInputOptions): EdgeOperation;
|
|
106
|
+
}
|
|
107
|
+
export declare class ConditionalOperation<T extends Ent = Ent> implements DataOperation<T> {
|
|
108
|
+
protected op: DataOperation<T>;
|
|
109
|
+
private conditionalBuilder;
|
|
110
|
+
placeholderID?: ID | undefined;
|
|
111
|
+
protected shortCircuited: boolean;
|
|
112
|
+
readonly builder: Builder<T>;
|
|
113
|
+
constructor(op: DataOperation<T>, conditionalBuilder: Builder<any>);
|
|
114
|
+
shortCircuit(executor: Executor): boolean;
|
|
115
|
+
preFetch(queryer: Queryer, context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined): Promise<void>;
|
|
116
|
+
performWriteSync(queryer: SyncQueryer, context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined): void;
|
|
117
|
+
performWrite(queryer: Queryer, context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined): Promise<void>;
|
|
118
|
+
returnedRow(): Data | null;
|
|
119
|
+
updatedOperation(): UpdatedOperation | null;
|
|
120
|
+
resolve(executor: Executor): void;
|
|
121
|
+
postFetch(queryer: Queryer, context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
export declare class ConditionalNodeOperation<T extends Ent> extends ConditionalOperation<T> {
|
|
124
|
+
createdEnt(viewer: Viewer): T | null;
|
|
125
|
+
updatedOperation(): UpdatedOperation | null;
|
|
126
|
+
}
|