@snowtop/ent 0.2.0-alpha.10 → 0.2.0-alpha.11-test1
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.js +5 -5
- package/action/executor.d.ts +1 -1
- package/action/executor.js +4 -4
- package/action/experimental_action.js +5 -5
- package/action/orchestrator.d.ts +2 -2
- package/action/privacy.d.ts +2 -2
- package/action/relative_value.js +3 -3
- package/auth/auth.d.ts +0 -1
- package/auth/auth.js +4 -5
- package/core/base.js +5 -5
- package/core/clause.js +59 -60
- package/core/config.d.ts +0 -1
- package/core/config.js +1 -2
- package/core/context.d.ts +0 -1
- package/core/convert.d.ts +0 -1
- package/core/convert.js +16 -17
- package/core/date.js +1 -2
- package/core/ent.js +50 -51
- package/core/global_schema.js +6 -7
- package/core/loaders/assoc_count_loader.d.ts +2 -2
- package/core/loaders/assoc_edge_loader.d.ts +2 -2
- package/core/loaders/loader.js +3 -3
- package/core/loaders/object_loader.d.ts +4 -4
- package/core/loaders/query_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.js +2 -2
- package/core/logger.js +6 -7
- package/core/privacy.d.ts +2 -2
- package/core/privacy.js +4 -4
- package/core/query/shared_assoc_test.js +1 -2
- package/core/query_impl.js +4 -5
- package/core/viewer.d.ts +2 -2
- package/graphql/graphql_field_helpers.js +22 -22
- package/graphql/mutations/union.js +1 -2
- package/graphql/node_resolver.js +7 -7
- package/graphql/query/shared_assoc_test.js +1 -2
- package/graphql/scalars/time.d.ts +1 -1
- package/imports/dataz/example1/_auth.js +14 -10
- package/imports/index.js +1 -2
- package/names/names.js +5 -6
- package/package.json +13 -13
- package/parse_schema/parse.js +2 -3
- package/schema/binary_field.d.ts +2 -2
- package/schema/binary_field.js +3 -3
- package/schema/field.js +28 -28
- package/schema/json_field.js +7 -7
- package/schema/schema.js +12 -12
- package/schema/struct_field.js +4 -4
- package/schema/union_field.js +3 -3
- package/testutils/action/complex_schemas.js +11 -11
- package/testutils/builder.d.ts +1 -1
- package/testutils/builder.js +7 -7
- package/testutils/db/fixture.js +1 -2
- package/testutils/db/temp_db.js +37 -37
- package/testutils/db/value.js +3 -4
- package/testutils/db_mock.js +38 -6
- package/testutils/ent-graphql-tests/index.d.ts +3 -3
- package/testutils/ent-graphql-tests/index.js +10 -11
- package/testutils/fake_data/const.js +2 -2
- package/testutils/fake_data/fake_contact.js +3 -3
- package/testutils/fake_data/fake_event.js +3 -3
- package/testutils/fake_data/fake_tag.js +4 -4
- package/testutils/fake_data/fake_user.js +4 -4
- package/testutils/fake_data/test_helpers.js +17 -17
- package/testutils/fake_data/user_query.js +2 -2
- package/testutils/parse_sql.js +3 -3
- package/testutils/query.js +2 -3
- package/testutils/write.js +3 -4
- package/tsc/ast.js +10 -11
- package/tsc/compilerOptions.js +4 -5
- package/tsc/move_generated.js +1 -2
- package/tsc/transform.js +1 -2
package/action/action.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WriteOperation = void 0;
|
|
4
|
+
exports.saveBuilder = saveBuilder;
|
|
5
|
+
exports.saveBuilderX = saveBuilderX;
|
|
6
|
+
exports.setEdgeTypeInGroup = setEdgeTypeInGroup;
|
|
7
|
+
exports.clearEdgeTypeInGroup = clearEdgeTypeInGroup;
|
|
4
8
|
const base_1 = require("../core/base");
|
|
5
9
|
Object.defineProperty(exports, "WriteOperation", { enumerable: true, get: function () { return base_1.WriteOperation; } });
|
|
6
10
|
const ent_1 = require("../core/ent");
|
|
@@ -8,11 +12,9 @@ const logger_1 = require("../core/logger");
|
|
|
8
12
|
async function saveBuilder(builder) {
|
|
9
13
|
await saveBuilderImpl(builder, false);
|
|
10
14
|
}
|
|
11
|
-
exports.saveBuilder = saveBuilder;
|
|
12
15
|
async function saveBuilderX(builder) {
|
|
13
16
|
await saveBuilderImpl(builder, true);
|
|
14
17
|
}
|
|
15
|
-
exports.saveBuilderX = saveBuilderX;
|
|
16
18
|
async function saveBuilderImpl(builder, throwErr) {
|
|
17
19
|
let changeset;
|
|
18
20
|
try {
|
|
@@ -83,7 +85,6 @@ async function setEdgeTypeInGroup(orchestrator, inputEnumValue, id1, id2, id2Nod
|
|
|
83
85
|
}
|
|
84
86
|
await Promise.all(promises);
|
|
85
87
|
}
|
|
86
|
-
exports.setEdgeTypeInGroup = setEdgeTypeInGroup;
|
|
87
88
|
async function clearEdgeTypeInGroup(orchestrator, id1, id2, m) {
|
|
88
89
|
let promises = [];
|
|
89
90
|
for (const [_, edgeType] of m) {
|
|
@@ -102,4 +103,3 @@ async function clearEdgeTypeInGroup(orchestrator, id1, id2, m) {
|
|
|
102
103
|
}
|
|
103
104
|
await Promise.all(promises);
|
|
104
105
|
}
|
|
105
|
-
exports.clearEdgeTypeInGroup = clearEdgeTypeInGroup;
|
package/action/executor.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare class ListBasedExecutor<T extends Ent> implements Executor {
|
|
|
12
12
|
private complexOptions?;
|
|
13
13
|
private idx;
|
|
14
14
|
builder?: Builder<Ent> | undefined;
|
|
15
|
-
constructor(viewer: Viewer, placeholderID: ID, operations: DataOperation<T>[], options?: OrchestratorOptions<T, Data, Viewer
|
|
15
|
+
constructor(viewer: Viewer, placeholderID: ID, operations: DataOperation<T>[], options?: OrchestratorOptions<T, Data, Viewer> | undefined, complexOptions?: ComplexExecutorOptions | undefined);
|
|
16
16
|
private lastOp;
|
|
17
17
|
private createdEnt;
|
|
18
18
|
private changedOps;
|
package/action/executor.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.ComplexExecutor = exports.ListBasedExecutor = void 0;
|
|
7
|
+
exports.executeOperations = executeOperations;
|
|
7
8
|
const graph_data_structure_1 = require("graph-data-structure");
|
|
8
9
|
const ent_1 = require("../core/ent");
|
|
9
10
|
const db_1 = __importDefault(require("../core/db"));
|
|
@@ -122,7 +123,7 @@ class ComplexExecutor {
|
|
|
122
123
|
this.executors = [];
|
|
123
124
|
this.changedOps = new Map();
|
|
124
125
|
this.builder = options?.builder;
|
|
125
|
-
let graph =
|
|
126
|
+
let graph = new graph_data_structure_1.Graph();
|
|
126
127
|
const changesetMap = new Map();
|
|
127
128
|
const impl = (c) => {
|
|
128
129
|
changesetMap.set(c.placeholderID.toString(), c);
|
|
@@ -155,7 +156,7 @@ class ComplexExecutor {
|
|
|
155
156
|
// TODO: can this logic be rewritten to not have a set yet avoid duplicates?
|
|
156
157
|
let nodeOps = new Set();
|
|
157
158
|
let remainOps = new Set();
|
|
158
|
-
let sorted =
|
|
159
|
+
let sorted = (0, graph_data_structure_1.topologicalSort)(graph);
|
|
159
160
|
sorted.forEach((node) => {
|
|
160
161
|
let c = changesetMap.get(node);
|
|
161
162
|
if (!c) {
|
|
@@ -338,7 +339,6 @@ async function executeOperations(executor, context, trackOps) {
|
|
|
338
339
|
}
|
|
339
340
|
return operations;
|
|
340
341
|
}
|
|
341
|
-
exports.executeOperations = executeOperations;
|
|
342
342
|
function maybeChangeOp(op, complexOptions) {
|
|
343
343
|
if (!op ||
|
|
344
344
|
!complexOptions?.conditionalOverride ||
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.BaseAction = void 0;
|
|
4
|
+
exports.updateRawObject = updateRawObject;
|
|
5
|
+
exports.getSimpleEditAction = getSimpleEditAction;
|
|
6
|
+
exports.getSimpleDeleteAction = getSimpleDeleteAction;
|
|
7
|
+
exports.getSimpleInsertAction = getSimpleInsertAction;
|
|
4
8
|
const privacy_1 = require("../core/privacy");
|
|
5
9
|
const action_1 = require("./action");
|
|
6
10
|
class BaseAction {
|
|
@@ -87,7 +91,6 @@ async function updateRawObject(viewer, builderCtr, existingEnt, input) {
|
|
|
87
91
|
});
|
|
88
92
|
return action.saveX();
|
|
89
93
|
}
|
|
90
|
-
exports.updateRawObject = updateRawObject;
|
|
91
94
|
// TODO need to fix types for all these
|
|
92
95
|
// creates an action which has no privacy, triggers, observers etc
|
|
93
96
|
// does do field validation
|
|
@@ -100,7 +103,6 @@ function getSimpleEditAction(viewer, builderCtr, existingEnt, input) {
|
|
|
100
103
|
input,
|
|
101
104
|
});
|
|
102
105
|
}
|
|
103
|
-
exports.getSimpleEditAction = getSimpleEditAction;
|
|
104
106
|
function getSimpleDeleteAction(viewer, builderCtr, existingEnt, input) {
|
|
105
107
|
return new BaseAction(viewer, builderCtr, {
|
|
106
108
|
existingEnt: existingEnt,
|
|
@@ -108,7 +110,6 @@ function getSimpleDeleteAction(viewer, builderCtr, existingEnt, input) {
|
|
|
108
110
|
input,
|
|
109
111
|
});
|
|
110
112
|
}
|
|
111
|
-
exports.getSimpleDeleteAction = getSimpleDeleteAction;
|
|
112
113
|
function getSimpleInsertAction(viewer, builderCtr, input) {
|
|
113
114
|
return new BaseAction(viewer, builderCtr, {
|
|
114
115
|
operation: action_1.WriteOperation.Insert,
|
|
@@ -116,4 +117,3 @@ function getSimpleInsertAction(viewer, builderCtr, input) {
|
|
|
116
117
|
existingEnt: null,
|
|
117
118
|
});
|
|
118
119
|
}
|
|
119
|
-
exports.getSimpleInsertAction = getSimpleInsertAction;
|
package/action/orchestrator.d.ts
CHANGED
|
@@ -114,11 +114,11 @@ export declare class EntChangeset<TEnt extends Ent<TViewer>, TViewer extends Vie
|
|
|
114
114
|
readonly placeholderID: ID;
|
|
115
115
|
private conditionalOverride;
|
|
116
116
|
operations: DataOperation<any, TViewer>[];
|
|
117
|
-
dependencies?: Map<ID, Builder<Ent
|
|
117
|
+
dependencies?: Map<ID, Builder<Ent>> | undefined;
|
|
118
118
|
changesets?: Changeset[] | undefined;
|
|
119
119
|
private options?;
|
|
120
120
|
private _executor;
|
|
121
|
-
constructor(viewer: Viewer, builder: Builder<TEnt, TViewer>, placeholderID: ID, conditionalOverride: boolean, operations: DataOperation<any, TViewer>[], dependencies?: Map<ID, Builder<Ent
|
|
121
|
+
constructor(viewer: Viewer, builder: Builder<TEnt, TViewer>, placeholderID: ID, conditionalOverride: boolean, operations: DataOperation<any, TViewer>[], dependencies?: Map<ID, Builder<Ent>> | undefined, changesets?: Changeset[] | undefined, options?: OrchestratorOptions<TEnt, Data, TViewer> | undefined);
|
|
122
122
|
static changesetFrom<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<TEnt, TViewer, any>, ops: DataOperation<any, TViewer>[]): EntChangeset<any, TViewer>;
|
|
123
123
|
static changesetFromQueries<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<TEnt, TViewer, any>, queries: Array<string | parameterizedQueryOptions>): EntChangeset<any, TViewer>;
|
|
124
124
|
private static changesetFromEdgeOp;
|
package/action/privacy.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { Builder } from "./action";
|
|
|
2
2
|
import { Viewer, ID, Ent, PrivacyResult, PrivacyPolicyRule } from "../core/base";
|
|
3
3
|
export declare class DenyIfBuilder implements PrivacyPolicyRule {
|
|
4
4
|
private id?;
|
|
5
|
-
constructor(id?: ID | Builder<Ent
|
|
5
|
+
constructor(id?: (ID | Builder<Ent, any>) | undefined);
|
|
6
6
|
apply(_v: Viewer, _ent: Ent): Promise<PrivacyResult>;
|
|
7
7
|
}
|
|
8
8
|
export declare class AllowIfBuilder implements PrivacyPolicyRule {
|
|
9
9
|
private id?;
|
|
10
|
-
constructor(id?: ID | Builder<Ent
|
|
10
|
+
constructor(id?: (ID | Builder<Ent, any>) | undefined);
|
|
11
11
|
apply(_v: Viewer, _ent: Ent): Promise<PrivacyResult>;
|
|
12
12
|
}
|
package/action/relative_value.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.NumberOps = void 0;
|
|
4
|
+
exports.convertRelativeInput = convertRelativeInput;
|
|
5
|
+
exports.maybeConvertRelativeInputPlusExpressions = maybeConvertRelativeInputPlusExpressions;
|
|
4
6
|
const clause_1 = require("../core/clause");
|
|
5
7
|
function addNumber(delta) {
|
|
6
8
|
return {
|
|
@@ -101,7 +103,6 @@ function convertRelativeInput(rel, col, existing) {
|
|
|
101
103
|
}
|
|
102
104
|
throw new Error(`error in convertRelativeInput. shouldn't have gotten here`);
|
|
103
105
|
}
|
|
104
|
-
exports.convertRelativeInput = convertRelativeInput;
|
|
105
106
|
function maybeConvertRelativeInputPlusExpressions(rel, col, existing, expressions) {
|
|
106
107
|
if (rel === null) {
|
|
107
108
|
return rel;
|
|
@@ -122,4 +123,3 @@ function maybeConvertRelativeInputPlusExpressions(rel, col, existing, expression
|
|
|
122
123
|
expressions.set(col, clause);
|
|
123
124
|
return value;
|
|
124
125
|
}
|
|
125
|
-
exports.maybeConvertRelativeInputPlusExpressions = maybeConvertRelativeInputPlusExpressions;
|
package/auth/auth.d.ts
CHANGED
package/auth/auth.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.registerAuthHandler = registerAuthHandler;
|
|
4
|
+
exports.clearAuthHandlers = clearAuthHandlers;
|
|
5
|
+
exports.getLoggedInViewer = getLoggedInViewer;
|
|
6
|
+
exports.buildContext = buildContext;
|
|
4
7
|
const viewer_1 = require("../core/viewer");
|
|
5
8
|
const context_1 = require("../core/context");
|
|
6
9
|
const logger_1 = require("../core/logger");
|
|
@@ -8,11 +11,9 @@ let handlers = new Map();
|
|
|
8
11
|
async function registerAuthHandler(name, auth) {
|
|
9
12
|
handlers.set(name, auth);
|
|
10
13
|
}
|
|
11
|
-
exports.registerAuthHandler = registerAuthHandler;
|
|
12
14
|
async function clearAuthHandlers() {
|
|
13
15
|
handlers.clear();
|
|
14
16
|
}
|
|
15
|
-
exports.clearAuthHandlers = clearAuthHandlers;
|
|
16
17
|
async function getLoggedInViewer(context) {
|
|
17
18
|
for (const [name, authHandler] of handlers) {
|
|
18
19
|
let v = await authHandler.authViewer(context);
|
|
@@ -24,7 +25,6 @@ async function getLoggedInViewer(context) {
|
|
|
24
25
|
(0, logger_1.log)("info", "no auth handler returned viewer. default to logged out viewer");
|
|
25
26
|
return null;
|
|
26
27
|
}
|
|
27
|
-
exports.getLoggedInViewer = getLoggedInViewer;
|
|
28
28
|
async function buildContext(request, response) {
|
|
29
29
|
const ctx = new contextImpl(request, response);
|
|
30
30
|
let viewer = await getLoggedInViewer(ctx);
|
|
@@ -34,7 +34,6 @@ async function buildContext(request, response) {
|
|
|
34
34
|
}
|
|
35
35
|
return ctx;
|
|
36
36
|
}
|
|
37
|
-
exports.buildContext = buildContext;
|
|
38
37
|
class contextImpl {
|
|
39
38
|
constructor(request, response) {
|
|
40
39
|
this.request = request;
|
package/core/base.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WriteOperation =
|
|
3
|
+
exports.WriteOperation = void 0;
|
|
4
|
+
exports.Allow = Allow;
|
|
5
|
+
exports.Skip = Skip;
|
|
6
|
+
exports.Deny = Deny;
|
|
7
|
+
exports.DenyWithReason = DenyWithReason;
|
|
4
8
|
// Privacy
|
|
5
9
|
var privacyResult;
|
|
6
10
|
(function (privacyResult) {
|
|
@@ -15,21 +19,18 @@ const allow = {
|
|
|
15
19
|
function Allow() {
|
|
16
20
|
return allow;
|
|
17
21
|
}
|
|
18
|
-
exports.Allow = Allow;
|
|
19
22
|
const skip = {
|
|
20
23
|
result: privacyResult.Skip,
|
|
21
24
|
};
|
|
22
25
|
function Skip() {
|
|
23
26
|
return skip;
|
|
24
27
|
}
|
|
25
|
-
exports.Skip = Skip;
|
|
26
28
|
const deny = {
|
|
27
29
|
result: privacyResult.Deny,
|
|
28
30
|
};
|
|
29
31
|
function Deny() {
|
|
30
32
|
return deny;
|
|
31
33
|
}
|
|
32
|
-
exports.Deny = Deny;
|
|
33
34
|
class DenyWithReasonError extends Error {
|
|
34
35
|
constructor(privacyPolicy, rule, msg, ent) {
|
|
35
36
|
super(msg);
|
|
@@ -52,7 +53,6 @@ function DenyWithReason(e) {
|
|
|
52
53
|
error: e,
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
|
-
exports.DenyWithReason = DenyWithReason;
|
|
56
56
|
var WriteOperation;
|
|
57
57
|
(function (WriteOperation) {
|
|
58
58
|
WriteOperation["Insert"] = "insert";
|